Skip to content

Commit 33917dd

Browse files
authored
Add ability to mute and mute flaky fixture (#40630)
1 parent 963c9b8 commit 33917dd

File tree

2 files changed

+26
-6
lines changed

2 files changed

+26
-6
lines changed

buildSrc/src/main/java/org/elasticsearch/gradle/testfixtures/TestFixturesPlugin.java

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@ public void apply(Project project) {
7171
pullFixture.setEnabled(false);
7272
return;
7373
}
74+
preProcessFixture.onlyIf(spec -> buildFixture.getEnabled());
75+
postProcessFixture.onlyIf(spec -> buildFixture.getEnabled());
7476

7577
project.apply(spec -> spec.plugin(BasePlugin.class));
7678
project.apply(spec -> spec.plugin(DockerComposePlugin.class));
@@ -94,21 +96,26 @@ public void apply(Project project) {
9496
(name, port) -> postProcessFixture.getExtensions()
9597
.getByType(ExtraPropertiesExtension.class).set(name, port)
9698
);
99+
extension.fixtures.add(project);
97100
}
98101

99-
extension.fixtures.all(fixtureProject -> project.evaluationDependsOn(fixtureProject.getPath()));
102+
extension.fixtures
103+
.matching(fixtureProject -> fixtureProject.equals(project) == false)
104+
.all(fixtureProject -> project.evaluationDependsOn(fixtureProject.getPath()));
105+
106+
conditionTaskByType(tasks, extension, getTaskClass("com.carrotsearch.gradle.junit4.RandomizedTestingTask"));
107+
conditionTaskByType(tasks, extension, getTaskClass("org.elasticsearch.gradle.test.RestIntegTestTask"));
108+
conditionTaskByType(tasks, extension, TestingConventionsTasks.class);
109+
conditionTaskByType(tasks, extension, ComposeUp.class);
110+
100111
if (dockerComposeSupported(project) == false) {
101112
project.getLogger().warn(
102113
"Tests for {} require docker-compose at /usr/local/bin/docker-compose or /usr/bin/docker-compose " +
103114
"but none could be found so these will be skipped", project.getPath()
104115
);
105-
disableTaskByType(tasks, getTaskClass("com.carrotsearch.gradle.junit4.RandomizedTestingTask"));
106-
disableTaskByType(tasks, getTaskClass("org.elasticsearch.gradle.test.RestIntegTestTask"));
107-
// conventions are not honored when the tasks are disabled
108-
disableTaskByType(tasks, TestingConventionsTasks.class);
109-
disableTaskByType(tasks, ComposeUp.class);
110116
return;
111117
}
118+
112119
tasks.withType(getTaskClass("com.carrotsearch.gradle.junit4.RandomizedTestingTask"), task ->
113120
extension.fixtures.all(fixtureProject -> {
114121
fixtureProject.getTasks().matching(it -> it.getName().equals("buildFixture")).all(buildFixture ->
@@ -128,6 +135,16 @@ public void apply(Project project) {
128135

129136
}
130137

138+
private void conditionTaskByType(TaskContainer tasks, TestFixtureExtension extension, Class<? extends DefaultTask> taskClass) {
139+
tasks.withType(
140+
taskClass,
141+
task -> task.onlyIf(spec ->
142+
extension.fixtures.stream()
143+
.anyMatch(fixtureProject -> fixtureProject.getTasks().getByName("buildFixture").getEnabled() == false) == false
144+
)
145+
);
146+
}
147+
131148
private void configureServiceInfoForTask(Task task, Project fixtureProject, BiConsumer<String, Integer> consumer) {
132149
// Configure ports for the tests as system properties.
133150
// We only know these at execution time so we need to do it in doFirst

test/fixtures/krb5kdc-fixture/build.gradle

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@ postProcessFixture {
4747
}
4848
}
4949

50+
// https://github.com/elastic/elasticsearch/issues/40624
51+
buildFixture.enabled = false
52+
5053
project.ext.krb5Conf = { service -> file("$buildDir/shared/${service}/krb5.conf") }
5154
project.ext.krb5Keytabs = { service, fileName -> file("$buildDir/shared/${service}/keytabs/${fileName}") }
5255

0 commit comments

Comments
 (0)