Skip to content

Consolidate testclusters tests into a single project #37362

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 24, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -39,34 +39,34 @@ public void testListClusters() {
}

public void testUseClusterByOne() {
BuildResult result = getTestClustersRunner("user1").build();
BuildResult result = getTestClustersRunner(":user1").build();
assertTaskSuccessful(result, ":user1");
assertStartedAndStoppedOnce(result);
}

public void testUseClusterByOneWithDryRun() {
BuildResult result = getTestClustersRunner("--dry-run", "user1").build();
BuildResult result = getTestClustersRunner("--dry-run", ":user1").build();
assertNull(result.task(":user1"));
assertNotStarted(result);
}

public void testUseClusterByTwo() {
BuildResult result = getTestClustersRunner("user1", "user2").build();
BuildResult result = getTestClustersRunner(":user1", ":user2").build();
assertTaskSuccessful(result, ":user1", ":user2");
assertStartedAndStoppedOnce(result);
}

public void testUseClusterByUpToDateTask() {
// Run it once, ignoring the result and again to make sure it's considered up to date.
// Gradle randomly considers tasks without inputs and outputs as as up-to-date or success on the first run
getTestClustersRunner("upToDate1", "upToDate2").build();
BuildResult result = getTestClustersRunner("upToDate1", "upToDate2").build();
getTestClustersRunner(":upToDate1", ":upToDate2").build();
BuildResult result = getTestClustersRunner(":upToDate1", ":upToDate2").build();
assertTaskUpToDate(result, ":upToDate1", ":upToDate2");
assertNotStarted(result);
}

public void testUseClusterBySkippedTask() {
BuildResult result = getTestClustersRunner("skipped1", "skipped2").build();
BuildResult result = getTestClustersRunner(":skipped1", ":skipped2").build();
assertTaskSkipped(result, ":skipped1", ":skipped2");
assertNotStarted(result);
}
Expand All @@ -84,17 +84,44 @@ public void testUseClusterBySkippedAndWorkingTask() {
}

public void testMultiProject() {
BuildResult result = GradleRunner.create()
.withProjectDir(getProjectDir("testclusters_multiproject"))
.withArguments("user1", "user2", "-s", "-i", "--parallel", "-Dlocal.repo.path=" + getLocalTestRepoPath())
.withPluginClasspath()
.build();
assertTaskSuccessful(result, ":user1", ":user2");
BuildResult result = getTestClustersRunner(
"user1", "user2", "-s", "-i", "--parallel", "-Dlocal.repo.path=" + getLocalTestRepoPath()
).build();

assertTaskSuccessful(
result,
":user1", ":user2", ":alpha:user1", ":alpha:user2", ":bravo:user1", ":bravo:user2"
);
assertStartedAndStoppedOnce(result);
assertOutputOnlyOnce(
result.getOutput(),
"Starting `node{:alpha:myTestCluster}`",
"Stopping `node{::myTestCluster}`"
);
assertOutputOnlyOnce(
result.getOutput(),
"Starting `node{::myTestCluster}`",
"Stopping `node{:bravo:myTestCluster}`"
);
}

public void testIncremental() {
BuildResult result = getTestClustersRunner("clean", ":user1").build();
assertTaskSuccessful(result, ":user1");
assertStartedAndStoppedOnce(result);

result = getTestClustersRunner(":user1").build();
assertTaskSuccessful(result, ":user1");
assertStartedAndStoppedOnce(result);

result = getTestClustersRunner("clean", ":user1").build();
assertTaskSuccessful(result, ":user1");
assertStartedAndStoppedOnce(result);
assertStartedAndStoppedOnce(result);
}

public void testUseClusterByFailingOne() {
BuildResult result = getTestClustersRunner("itAlwaysFails").buildAndFail();
BuildResult result = getTestClustersRunner(":itAlwaysFails").buildAndFail();
assertTaskFailed(result, ":itAlwaysFails");
assertStartedAndStoppedOnce(result);
assertOutputContains(
Expand All @@ -105,7 +132,7 @@ public void testUseClusterByFailingOne() {
}

public void testUseClusterByFailingDependency() {
BuildResult result = getTestClustersRunner("dependsOnFailed").buildAndFail();
BuildResult result = getTestClustersRunner(":dependsOnFailed").buildAndFail();
assertTaskFailed(result, ":itAlwaysFails");
assertNull(result.task(":dependsOnFailed"));
assertStartedAndStoppedOnce(result);
Expand All @@ -117,7 +144,7 @@ public void testUseClusterByFailingDependency() {
}

public void testConfigurationLocked() {
BuildResult result = getTestClustersRunner("illegalConfigAlter").buildAndFail();
BuildResult result = getTestClustersRunner(":illegalConfigAlter").buildAndFail();
assertTaskFailed(result, ":illegalConfigAlter");
assertOutputContains(
result.getOutput(),
Expand Down
54 changes: 34 additions & 20 deletions buildSrc/src/testKit/testclusters/build.gradle
Original file line number Diff line number Diff line change
@@ -1,31 +1,45 @@
plugins {
id 'elasticsearch.testclusters'
id 'base'
}

testClusters {
myTestCluster {
distribution = 'ZIP'
version = System.getProperty("test.version_under_test")
allprojects { all ->
repositories {
maven {
url System.getProperty("local.repo.path")
}
String luceneSnapshotRevision = System.getProperty("test.lucene-snapshot-revision")
if (luceneSnapshotRevision != null) {
maven {
url "http://s3.amazonaws.com/download.elasticsearch.org/lucenesnapshots/" + luceneSnapshotRevision
}
}
jcenter()
}
}

repositories {
maven {
url System.getProperty("local.repo.path")
}
}
if (project == rootProject || project.name == "alpha" || project.name == "bravo") {
apply plugin: 'elasticsearch.testclusters'

task user1 {
useCluster testClusters.myTestCluster
doLast {
println "$path: Cluster running @ ${testClusters.myTestCluster.httpSocketURI}"
}
}
all.testClusters {
myTestCluster {
distribution = 'ZIP'
version = System.getProperty("test.version_under_test")
javaHome = file(System.getProperty('java.home'))
}
}

task user2 {
useCluster testClusters.myTestCluster
doLast {
println "$path: Cluster running @ ${testClusters.myTestCluster.httpSocketURI}"
task user1 {
useCluster testClusters.myTestCluster
doFirst {
println "$path: Cluster running @ ${testClusters.myTestCluster.httpSocketURI}"
}
}
task user2 {
useCluster testClusters.myTestCluster
doFirst {
println "$path: Cluster running @ ${testClusters.myTestCluster.httpSocketURI}"
}
}
}
}

Expand Down
4 changes: 4 additions & 0 deletions buildSrc/src/testKit/testclusters/settings.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
include 'dummyPlugin'
include ':alpha'
include ':bravo'
include ':charlie'
21 changes: 0 additions & 21 deletions buildSrc/src/testKit/testclusters_multiproject/alpha/build.gradle

This file was deleted.

24 changes: 0 additions & 24 deletions buildSrc/src/testKit/testclusters_multiproject/bravo/build.gradle

This file was deleted.

32 changes: 0 additions & 32 deletions buildSrc/src/testKit/testclusters_multiproject/build.gradle

This file was deleted.

This file was deleted.

This file was deleted.