@@ -183,7 +183,8 @@ private void runAction(
183183 /*handler=*/ null ,
184184 metadataHandler ,
185185 /*artifactExpander=*/ null ,
186- platform );
186+ platform ,
187+ /*isRemoteCacheEnabled=*/ true );
187188 if (token != null ) {
188189 // Real action execution would happen here.
189190 ActionExecutionContext context = mock (ActionExecutionContext .class );
@@ -440,7 +441,8 @@ public void testDeletedConstantMetadataOutputCausesReexecution() throws Exceptio
440441 /*handler=*/ null ,
441442 new FakeMetadataHandler (),
442443 /*artifactExpander=*/ null ,
443- /*remoteDefaultPlatformProperties=*/ ImmutableMap .of ()))
444+ /*remoteDefaultPlatformProperties=*/ ImmutableMap .of (),
445+ /*isRemoteCacheEnabled=*/ true ))
444446 .isNotNull ();
445447 }
446448
@@ -557,7 +559,8 @@ public void saveOutputMetadata_remoteFileMetadataLoaded() throws Exception {
557559 /*handler=*/ null ,
558560 metadataHandler ,
559561 /*artifactExpander=*/ null ,
560- /*remoteDefaultPlatformProperties=*/ ImmutableMap .of ());
562+ /*remoteDefaultPlatformProperties=*/ ImmutableMap .of (),
563+ /*isRemoteCacheEnabled=*/ true );
561564
562565 assertThat (output .getPath ().exists ()).isFalse ();
563566 assertThat (token ).isNull ();
@@ -567,6 +570,33 @@ public void saveOutputMetadata_remoteFileMetadataLoaded() throws Exception {
567570 assertThat (metadataHandler .getMetadata (output )).isEqualTo (createRemoteFileMetadata (content ));
568571 }
569572
573+ @ Test
574+ public void saveOutputMetadata_remoteOutputUnavailable_remoteFileMetadataNotLoaded ()
575+ throws Exception {
576+ cacheChecker = createActionCacheChecker (/*storeOutputMetadata=*/ true );
577+ Artifact output = createArtifact (artifactRoot , "bin/dummy" );
578+ String content = "content" ;
579+ Action action = new InjectOutputFileMetadataAction (output , createRemoteFileMetadata (content ));
580+ MetadataHandler metadataHandler = new FakeMetadataHandler ();
581+
582+ runAction (action );
583+ Token token =
584+ cacheChecker .getTokenIfNeedToExecute (
585+ action ,
586+ /*resolvedCacheArtifacts=*/ null ,
587+ /*clientEnv=*/ ImmutableMap .of (),
588+ /*handler=*/ null ,
589+ metadataHandler ,
590+ /*artifactExpander=*/ null ,
591+ /*remoteDefaultPlatformProperties=*/ ImmutableMap .of (),
592+ /*isRemoteCacheEnabled=*/ false );
593+
594+ assertThat (output .getPath ().exists ()).isFalse ();
595+ assertThat (token ).isNotNull ();
596+ ActionCache .Entry entry = cache .get (output .getExecPathString ());
597+ assertThat (entry ).isNull ();
598+ }
599+
570600 @ Test
571601 public void saveOutputMetadata_localMetadataIsSameAsRemoteMetadata_cached () throws Exception {
572602 cacheChecker = createActionCacheChecker (/*storeOutputMetadata=*/ true );
@@ -679,7 +709,8 @@ public void saveOutputMetadata_emptyTreeMetadata_notSaved() throws Exception {
679709 /*handler=*/ null ,
680710 metadataHandler ,
681711 /*artifactExpander=*/ null ,
682- /*remoteDefaultPlatformProperties=*/ ImmutableMap .of ());
712+ /*remoteDefaultPlatformProperties=*/ ImmutableMap .of (),
713+ /*isRemoteCacheEnabled=*/ true );
683714
684715 assertThat (token ).isNull ();
685716 assertThat (output .getPath ().exists ()).isFalse ();
@@ -763,7 +794,8 @@ public void saveOutputMetadata_treeMetadata_remoteFileMetadataLoaded() throws Ex
763794 /*handler=*/ null ,
764795 metadataHandler ,
765796 /*artifactExpander=*/ null ,
766- /*remoteDefaultPlatformProperties=*/ ImmutableMap .of ());
797+ /*remoteDefaultPlatformProperties=*/ ImmutableMap .of (),
798+ /*isRemoteCacheEnabled=*/ true );
767799
768800 TreeArtifactValue expectedMetadata = createTreeMetadata (output , children , Optional .empty ());
769801 assertThat (token ).isNull ();
@@ -890,7 +922,8 @@ public void saveOutputMetadata_treeMetadataWithSameLocalFileMetadata_cached() th
890922 /*handler=*/ null ,
891923 metadataHandler ,
892924 /*artifactExpander=*/ null ,
893- /*remoteDefaultPlatformProperties=*/ ImmutableMap .of ());
925+ /*remoteDefaultPlatformProperties=*/ ImmutableMap .of (),
926+ /*isRemoteCacheEnabled=*/ true );
894927
895928 assertThat (token ).isNull ();
896929 assertStatistics (1 , new MissDetailsBuilder ().set (MissReason .NOT_CACHED , 1 ).build ());
@@ -905,8 +938,9 @@ public void saveOutputMetadata_treeMetadataWithSameLocalFileMetadata_cached() th
905938 output ,
906939 ImmutableMap .of (
907940 "file1" ,
908- FileArtifactValue .createForTesting (output .getPath ().getRelative ("file1" )),
909- "file2" , createRemoteFileMetadata ("content2" )),
941+ FileArtifactValue .createForTesting (output .getPath ().getRelative ("file1" )),
942+ "file2" ,
943+ createRemoteFileMetadata ("content2" )),
910944 Optional .empty ()));
911945 }
912946
0 commit comments