File tree Expand file tree Collapse file tree 1 file changed +12
-5
lines changed
buildSrc/src/main/java/org/elasticsearch/gradle/testclusters Expand file tree Collapse file tree 1 file changed +12
-5
lines changed Original file line number Diff line number Diff line change 55import org .gradle .api .tasks .testing .Test ;
66
77import java .util .Collection ;
8+ import java .util .Collections ;
89import java .util .HashSet ;
910
10- import static org .elasticsearch .gradle .testclusters .TestDistribution .INTEG_TEST ;
11-
1211/**
1312 * Customized version of Gradle {@link Test} task which tracks a collection of {@link ElasticsearchCluster} as a task input. We must do this
1413 * as a custom task type because the current {@link org.gradle.api.tasks.TaskInputs} runtime API does not have a way to register
@@ -20,9 +19,17 @@ public class RestTestRunnerTask extends Test implements TestClustersAware {
2019 private Collection <ElasticsearchCluster > clusters = new HashSet <>();
2120
2221 public RestTestRunnerTask () {
23- super ();
24- this .getOutputs ().doNotCacheIf ("Build cache is only enabled for tests against clusters using the 'integ-test' distribution" ,
25- task -> clusters .stream ().flatMap (c -> c .getNodes ().stream ()).anyMatch (n -> n .getTestDistribution () != INTEG_TEST ));
22+ this .getOutputs ().doNotCacheIf ("Caching disabled for this task since it uses a cluster shared by other tasks" ,
23+ /*
24+ * Look for any other tasks which use the same cluster as this task. Since tests often have side effects for the cluster they
25+ * execute against, this state can cause issues when trying to cache tests results of tasks that share a cluster. To avoid any
26+ * undesired behavior we simply disable the cache if we detect that this task uses a cluster shared between multiple tasks.
27+ */
28+ t -> getProject ().getTasks ().withType (RestTestRunnerTask .class )
29+ .stream ()
30+ .filter (task -> task != this )
31+ .anyMatch (task -> Collections .disjoint (task .getClusters (), getClusters ()) == false )
32+ );
2633 }
2734
2835 @ Override
You can’t perform that action at this time.
0 commit comments