From aaa05108213473c681550ee167b3feb145bcec86 Mon Sep 17 00:00:00 2001 From: Jay Modi Date: Fri, 8 Sep 2017 13:33:33 -0600 Subject: [PATCH] Run core's full cluster restart tests with x-pack (elastic/x-pack-elasticsearch#2433) This change pulls in the o.e.u.FullClusterRestartIT class from core and runs it as part of the x-pack full cluster restart tests. Relates elastic/x-pack-elasticsearch#1629 Original commit: elastic/x-pack-elasticsearch@87da59485fc04d11b9d1c3488881af2af10244b6 --- qa/full-cluster-restart/build.gradle | 25 ++++++++++++++++++- .../restart/CoreFullClusterRestartIT.java | 24 ++++++++++++++++++ .../xpack/restart/FullClusterRestartIT.java | 10 ++++++++ 3 files changed, 58 insertions(+), 1 deletion(-) create mode 100644 qa/full-cluster-restart/src/test/java/org/elasticsearch/xpack/restart/CoreFullClusterRestartIT.java diff --git a/qa/full-cluster-restart/build.gradle b/qa/full-cluster-restart/build.gradle index 2798814745b..c5dd2be4a6c 100644 --- a/qa/full-cluster-restart/build.gradle +++ b/qa/full-cluster-restart/build.gradle @@ -3,6 +3,7 @@ import org.elasticsearch.gradle.test.RestIntegTestTask import org.elasticsearch.gradle.Version import java.nio.charset.StandardCharsets +import java.nio.file.Paths import java.util.regex.Matcher // Apply the java plugin to this project so the sources can be edited in an IDE @@ -59,6 +60,19 @@ Closure waitWithAuth = { NodeInfo node, AntBuilder ant -> Project mainProject = project +String coreFullClusterRestartPath = project(':qa:full-cluster-restart').projectDir.toPath().resolve('src/test/java').toString() +sourceSets { + test { + java { + srcDirs += [coreFullClusterRestartPath] + } + } +} + +licenseHeaders { + approvedLicenses << 'Apache' +} + /** * Subdirectories of this project are test rolling upgrades with various * configuration options based on their name. @@ -76,7 +90,7 @@ subprojects { sourceSets { test { java { - srcDirs = ["${mainProject.projectDir}/src/test/java"] + srcDirs = ["${mainProject.projectDir}/src/test/java", coreFullClusterRestartPath] } resources { srcDirs = ["${mainProject.projectDir}/src/test/resources"] @@ -84,6 +98,10 @@ subprojects { } } + licenseHeaders { + approvedLicenses << 'Apache' + } + String outputDir = "generated-resources/${project.name}" // This is a top level task which we will add dependencies to below. @@ -143,6 +161,8 @@ subprojects { oldClusterTestRunner.configure { systemProperty 'tests.is_old_cluster', 'true' systemProperty 'tests.old_cluster_version', version.toString().minus("-SNAPSHOT") + systemProperty 'tests.path.repo', new File(buildDir, "cluster/shared/repo") + exclude 'org/elasticsearch/upgrades/FullClusterRestartIT.class' } Task upgradedClusterTest = tasks.create(name: "${baseName}#upgradedClusterTest", type: RestIntegTestTask) @@ -156,6 +176,7 @@ subprojects { numNodes = 2 clusterName = 'full-cluster-restart' dataDir = { nodeNum -> oldClusterTest.nodes[nodeNum].dataDir } + cleanShared = false // We want to keep snapshots made by the old cluster! setupCommand 'setupTestUser', 'bin/x-pack/users', 'useradd', 'test_user', '-p', 'x-pack-test-password', '-r', 'superuser' waitCondition = waitWithAuth setting 'xpack.ssl.keystore.path', 'testnode.jks' @@ -174,6 +195,8 @@ subprojects { upgradedClusterTestRunner.configure { systemProperty 'tests.is_old_cluster', 'false' systemProperty 'tests.old_cluster_version', version.toString().minus("-SNAPSHOT") + systemProperty 'tests.path.repo', new File(buildDir, "cluster/shared/repo") + exclude 'org/elasticsearch/upgrades/FullClusterRestartIT.class' } Task versionBwcTest = tasks.create(name: "${baseName}#bwcTest") { diff --git a/qa/full-cluster-restart/src/test/java/org/elasticsearch/xpack/restart/CoreFullClusterRestartIT.java b/qa/full-cluster-restart/src/test/java/org/elasticsearch/xpack/restart/CoreFullClusterRestartIT.java new file mode 100644 index 00000000000..c5091c0d270 --- /dev/null +++ b/qa/full-cluster-restart/src/test/java/org/elasticsearch/xpack/restart/CoreFullClusterRestartIT.java @@ -0,0 +1,24 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ +package org.elasticsearch.xpack.restart; + +import org.elasticsearch.common.settings.Settings; +import org.elasticsearch.common.util.concurrent.ThreadContext; +import org.elasticsearch.upgrades.FullClusterRestartIT; + +import java.nio.charset.StandardCharsets; +import java.util.Base64; + +public class CoreFullClusterRestartIT extends FullClusterRestartIT { + + @Override + protected Settings restClientSettings() { + String token = "Basic " + Base64.getEncoder().encodeToString("test_user:x-pack-test-password".getBytes(StandardCharsets.UTF_8)); + return Settings.builder() + .put(ThreadContext.PREFIX + ".Authorization", token) + .build(); + } +} diff --git a/qa/full-cluster-restart/src/test/java/org/elasticsearch/xpack/restart/FullClusterRestartIT.java b/qa/full-cluster-restart/src/test/java/org/elasticsearch/xpack/restart/FullClusterRestartIT.java index 59b4e19ec8e..342fe0ae167 100644 --- a/qa/full-cluster-restart/src/test/java/org/elasticsearch/xpack/restart/FullClusterRestartIT.java +++ b/qa/full-cluster-restart/src/test/java/org/elasticsearch/xpack/restart/FullClusterRestartIT.java @@ -75,6 +75,16 @@ public class FullClusterRestartIT extends ESRestTestCase { return true; } + @Override + protected boolean preserveSnapshotsUponCompletion() { + return true; + } + + @Override + protected boolean preserveReposUponCompletion() { + return true; + } + @Override protected boolean preserveTemplatesUponCompletion() { return true;