Skip to content
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

Bwc testclusters all #46265

Merged
merged 14 commits into from
Sep 4, 2019
Original file line number Diff line number Diff line change
Expand Up @@ -464,13 +464,6 @@ private void logToProcessStdout(String message) {
public void restart() {
LOGGER.info("Restarting {}", this);
stop(false);
try {
Files.delete(httpPortsFile);
Files.delete(transportPortFile);
} catch (IOException e) {
throw new UncheckedIOException(e);
}

start();
}

Expand All @@ -479,11 +472,11 @@ public void goToNextVersion() {
if (currentDistro + 1 >= distributions.size()) {
throw new TestClustersException("Ran out of versions to go to for " + this);
}
LOGGER.info("Switch version from {} to {} for {}",
getVersion(), distributions.get(currentDistro + 1).getVersion(), this
);
logToProcessStdout("Switch version from " + getVersion() + " to " + distributions.get(currentDistro + 1).getVersion());
stop(false);
currentDistro += 1;
restart();
setting("node.attr.upgraded", "true");
start();
}

private boolean isSettingMissingOrTrue(String name) {
Expand Down Expand Up @@ -716,6 +709,17 @@ public File getAuditLog() {

@Override
public synchronized void stop(boolean tailLogs) {
logToProcessStdout("Stopping node");
try {
if (Files.exists(httpPortsFile)) {
Files.delete(httpPortsFile);
}
if (Files.exists(transportPortFile)) {
Files.delete(transportPortFile);
}
} catch (IOException e) {
throw new UncheckedIOException(e);
}
if (esProcess == null && tailLogs) {
// This is a special case. If start() throws an exception the plugin will still call stop
// Another exception here would eat the orriginal.
Expand Down Expand Up @@ -867,6 +871,8 @@ private void waitForProcessToExit(ProcessHandle processHandle) {

private void createWorkingDir(Path distroExtractDir) throws IOException {
syncWithLinks(distroExtractDir, distroDir);
// Start configuration from scratch in case of a restart
project.delete(configFile.getParent());
Files.createDirectories(configFile.getParent());
Files.createDirectories(confPathRepo);
Files.createDirectories(confPathData);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ public static String getElasticsearch() {
return elasticsearch;
}

public static Version getElasticsearchVersion() {
return Version.fromString(elasticsearch);
}

public static String getLucene() {
return lucene;
}
Expand Down
11 changes: 4 additions & 7 deletions qa/full-cluster-restart/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,10 @@
import org.elasticsearch.gradle.Version
import org.elasticsearch.gradle.testclusters.RestTestRunnerTask

apply plugin: 'elasticsearch.standalone-test'
apply plugin: 'elasticsearch.testclusters'
apply plugin: 'elasticsearch.standalone-test'

// This is a top level task which we will add dependencies to below.
// It is a single task that can be used to backcompat tests against all versions.
task bwcTest {
tasks.register("bwcTest") {
description = 'Runs backwards compatibility tests.'
group = 'verification'
}
Expand Down Expand Up @@ -81,9 +79,6 @@ for (Version bwcVersion : bwcVersions.indexCompatible) {
}
}

test.enabled = false // no unit tests for rolling upgrades, only the rest integration test

// basic integ tests includes testing bwc against the most recent version
task bwcTestSnapshots {
if (project.bwc_tests_enabled) {
for (final def version : bwcVersions.unreleasedIndexCompatible) {
Expand All @@ -106,3 +101,5 @@ task testJar(type: Jar) {
artifacts {
testArtifacts testJar
}

test.enabled = false
85 changes: 58 additions & 27 deletions qa/mixed-cluster/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,58 +17,89 @@
* under the License.
*/

import org.elasticsearch.gradle.test.RestIntegTestTask
import org.elasticsearch.gradle.Version
import org.elasticsearch.gradle.VersionProperties
import org.elasticsearch.gradle.testclusters.RestTestRunnerTask

apply plugin: 'elasticsearch.testclusters'
apply plugin: 'elasticsearch.standalone-test'

// This is a top level task which we will add dependencies to below.
// It is a single task that can be used to backcompat tests against all versions.
task bwcTest {
tasks.register("bwcTest") {
description = 'Runs backwards compatibility tests.'
group = 'verification'
}

for (Version version : bwcVersions.wireCompatible) {
String baseName = "v${version}"
configurations {
mark-vieira marked this conversation as resolved.
Show resolved Hide resolved
restSpec
}

Task mixedClusterTest = tasks.create(name: "${baseName}#mixedClusterTest", type: RestIntegTestTask) {
mustRunAfter(precommit)
includePackaged = true
dependencies {
restSpec project(':rest-api-spec')
}

processTestResources {
from ({ zipTree(configurations.restSpec.singleFile) })
dependsOn configurations.restSpec
}

for (Version bwcVersion : bwcVersions.wireCompatible) {
if (bwcVersion == VersionProperties.getElasticsearchVersion()) {
// Not really a mixed cluster
continue ;
}

String baseName = "v${bwcVersion}"

/* This project runs the core REST tests against a 4 node cluster where two of
the nodes has a different minor. */
Object extension = extensions.findByName("${baseName}#mixedClusterTestCluster")
configure(extension) {
numNodes = 4
numBwcNodes = 2
bwcVersion = version
}
testClusters {
"${baseName}" {
versions = [ bwcVersion.toString(), project.version ]
numberOfNodes = 4

Task versionBwcTest = tasks.create(name: "${baseName}#bwcTest") {
dependsOn = [mixedClusterTest]
setting 'path.repo', "${buildDir}/cluster/shared/repo/${baseName}"
javaHome = project.file(project.ext.runtimeJavaHome)
}
}

if (project.bwc_tests_enabled) {
bwcTest.dependsOn(versionBwcTest)
tasks.register("${baseName}#mixedClusterTest", RestTestRunnerTask) {
useCluster testClusters."${baseName}"
mustRunAfter(precommit)
doFirst {
mark-vieira marked this conversation as resolved.
Show resolved Hide resolved
project.delete("${buildDir}/cluster/shared/repo/${baseName}")
// Getting the endpoints causes a wait for the cluster
println "Test cluster endpoints are: ${-> testClusters."${baseName}".allHttpSocketURI.join(",") }"
println "Upgrading one node to create a mixed cluster"
testClusters."${baseName}".nextNodeToNextVersion()
// Getting the endpoints causes a wait for the cluster
println "Upgrade complete, endpoints are: ${-> testClusters."${baseName}".allHttpSocketURI.join(",") }"
println "Upgrading another node to create a mixed cluster"
testClusters."${baseName}".nextNodeToNextVersion()

nonInputProperties.systemProperty('tests.rest.cluster', "${-> testClusters."${baseName}".allHttpSocketURI.join(",") }")
nonInputProperties.systemProperty('tests.clustername', "${-> testClusters."${baseName}".getName() }")
}
systemProperty 'tests.path.repo', "${buildDir}/cluster/shared/repo/${baseName}"
onlyIf { project.bwc_tests_enabled }
}

tasks.getByName("${baseName}#mixedClusterTestRunner").configure {
/* To support taking index snapshots, we have to set path.repo setting */
systemProperty 'tests.path.repo', new File(buildDir, "cluster/shared/repo")
tasks.register("${baseName}#bwcTest") {
dependsOn "${baseName}#mixedClusterTest"
}
}

test.enabled = false // no unit tests for rolling upgrades, only the rest integration test
tasks.bwcTest.dependsOn "${baseName}#bwcTest"
}

// basic integ tests includes testing bwc against the most recent version
task bwcTestSnapshots {
if (project.bwc_tests_enabled) {
for (final def version : bwcVersions.unreleasedWireCompatible) {
dependsOn "v${version}#bwcTest"
for (Version bwcVersion : bwcVersions.unreleasedWireCompatible) {
if (bwcVersion != VersionProperties.getElasticsearchVersion()) {
dependsOn "v${bwcVersion}#bwcTest"
}
}
}
}

check.dependsOn(bwcTestSnapshots)

test.enabled = false
Loading