From 36ad7e72fd33ef83bfe6a5c3ca640b8b675c85f4 Mon Sep 17 00:00:00 2001 From: Alpar Torok Date: Thu, 28 Feb 2019 16:35:02 +0200 Subject: [PATCH 01/12] Run REST tests against a cluster running on docker Closes #38053 --- .../testfixtures/TestFixturesPlugin.java | 8 +- distribution/docker/build.gradle | 37 +++++++- distribution/docker/docker-compose.yml | 94 +++++++++++++++++-- .../docker/test/DockerYmlTestSuiteIT.java | 59 ++++++++++++ .../test/rest/ESRestTestCase.java | 15 ++- 5 files changed, 196 insertions(+), 17 deletions(-) create mode 100644 distribution/docker/src/test/java/org/elasticsearch/docker/test/DockerYmlTestSuiteIT.java diff --git a/buildSrc/src/main/java/org/elasticsearch/gradle/testfixtures/TestFixturesPlugin.java b/buildSrc/src/main/java/org/elasticsearch/gradle/testfixtures/TestFixturesPlugin.java index 3dfccaf435031..e1e73ba46690f 100644 --- a/buildSrc/src/main/java/org/elasticsearch/gradle/testfixtures/TestFixturesPlugin.java +++ b/buildSrc/src/main/java/org/elasticsearch/gradle/testfixtures/TestFixturesPlugin.java @@ -95,9 +95,15 @@ public void apply(Project project) { (name, port) -> postProcessFixture.getExtensions() .getByType(ExtraPropertiesExtension.class).set(name, port) ); + + // Make it possible to have the both fixture and what's using it in a single place + extension.fixtures.add(project); } - extension.fixtures.all(fixtureProject -> project.evaluationDependsOn(fixtureProject.getPath())); + extension.fixtures + .matching(fixtureProject -> fixtureProject.equals(project) == false) + .all(fixtureProject -> project.evaluationDependsOn(fixtureProject.getPath())); + if (dockerComposeSupported(project) == false) { project.getLogger().warn( "Tests for {} require docker-compose at /usr/local/bin/docker-compose or /usr/bin/docker-compose " + diff --git a/distribution/docker/build.gradle b/distribution/docker/build.gradle index c64601b5a523f..81dab3e6cfacf 100644 --- a/distribution/docker/build.gradle +++ b/distribution/docker/build.gradle @@ -2,8 +2,9 @@ import org.elasticsearch.gradle.BuildPlugin import org.elasticsearch.gradle.LoggedExec import org.elasticsearch.gradle.MavenFilteringHack import org.elasticsearch.gradle.VersionProperties +import com.carrotsearch.gradle.junit4.RandomizedTestingTask -apply plugin: 'base' +apply plugin: 'elasticsearch.standalone-rest-test' apply plugin: 'elasticsearch.test.fixtures' configurations { @@ -96,15 +97,41 @@ preProcessFixture { dependsOn taskName("copy", true, "Dockerfile") dependsOn taskName("copy", false, "DockerContext") dependsOn taskName("copy", false, "Dockerfile") + doLast { + file("${buildDir}/repo").mkdirs(); + file("${buildDir}/repo").setWritable(true, false) + file("${buildDir}/oss-repo").mkdirs(); + file("${buildDir}/oss-repo").setWritable(true, false) + } } postProcessFixture.doLast { - println "docker default distro is on port: ${ext."test.fixtures.elasticsearch-default.tcp.9200"}, " + - "oss is on: ${ext."test.fixtures.elasticsearch-oss.tcp.9200"}" + ["oss", "default"].each { flavor -> + println "Waiting for cluster status for $flavor" + println new URL("http://localhost:${ext."test.fixtures.elasticsearch-${flavor}-1.tcp.9200"}/_cluster/health?wait_for_nodes=>=1&wait_for_status=yellow").getText() + } +} + +configurations { + restSpec +} +dependencies { + restSpec "org.elasticsearch:rest-api-spec:${version}" +} + +task copyRestTests(type: Sync) { + from { zipTree(configurations.restSpec.singleFile) } + into sourceSets.test.output.resourcesDir +} +processTestResources.dependsOn copyRestTests + +task integTest(type: RandomizedTestingTask) { + parallelism = '1' + include '**/*IT.class' + dependsOn postProcessFixture } -// TODO: Add some actual tests, this will just check that the TPC port in the container is up -check.dependsOn postProcessFixture +check.dependsOn integTest void addBuildDockerImage(final boolean oss) { final Task buildDockerImageTask = task(taskName("build", oss, "DockerImage"), type: LoggedExec) { diff --git a/distribution/docker/docker-compose.yml b/distribution/docker/docker-compose.yml index 3f220aa9e91c0..b8aae5facdc62 100644 --- a/distribution/docker/docker-compose.yml +++ b/distribution/docker/docker-compose.yml @@ -1,21 +1,103 @@ # Only used for testing the docker images version: '3' services: - elasticsearch-default: + elasticsearch-default-1: build: context: ./build/docker - dockerfile: Dockerfile environment: + - node.name=elasticsearch-default-1 + - cluster.initial_master_nodes=elasticsearch-default-1,elasticsearch-default-2 + - discovery.seed_hosts=elasticsearch-default-2:9300 - cluster.name=elasticsearch-default - - discovery.type=single-node + - bootstrap.memory_lock=true + - "ES_JAVA_OPTS=-Xms512m -Xmx512m" + - path.repo=/tmp/es-repo + - node.attr.testattr=test + - cluster.routing.allocation.disk.watermark.low=1b + - cluster.routing.allocation.disk.watermark.high=1b + - cluster.routing.allocation.disk.watermark.flood_stage=1b + - script.max_compilations_rate=2048/1m + - node.store.allow_mmap=false + volumes: + - ./build/repo:/tmp/es-repo ports: - "9200" - elasticsearch-oss: + ulimits: + memlock: + soft: -1 + hard: -1 + elasticsearch-default-2: + build: + context: ./build/docker + environment: + - node.name=elasticsearch-default-2 + - cluster.initial_master_nodes=elasticsearch-default-1,elasticsearch-default-2 + - discovery.seed_hosts=elasticsearch-default-1:9300 + - cluster.name=elasticsearch-default + - bootstrap.memory_lock=true + - "ES_JAVA_OPTS=-Xms512m -Xmx512m" + - path.repo=/tmp/es-repo + - node.attr.testattr=test + - cluster.routing.allocation.disk.watermark.low=1b + - cluster.routing.allocation.disk.watermark.high=1b + - cluster.routing.allocation.disk.watermark.flood_stage=1b + - script.max_compilations_rate=2048/1m + - node.store.allow_mmap=false + volumes: + - ./build/repo:/tmp/es-repo + ports: + - "9200" + ulimits: + memlock: + soft: -1 + hard: -1 + elasticsearch-oss-1: + build: + context: ./build/oss-docker + environment: + - node.name=elasticsearch-oss-1 + - cluster.initial_master_nodes=elasticsearch-oss-1,elasticsearch-oss-2 + - discovery.seed_hosts=elasticsearch-oss-2:9300 + - cluster.name=elasticsearch-oss + - bootstrap.memory_lock=true + - "ES_JAVA_OPTS=-Xms512m -Xmx512m" + - path.repo=/tmp/es-repo + - node.attr.testattr=test + - cluster.routing.allocation.disk.watermark.low=1b + - cluster.routing.allocation.disk.watermark.high=1b + - cluster.routing.allocation.disk.watermark.flood_stage=1b + - script.max_compilations_rate=2048/1m + - node.store.allow_mmap=false + volumes: + - ./build/oss-repo:/tmp/es-repo + ports: + - "9200" + ulimits: + memlock: + soft: -1 + hard: -1 + elasticsearch-oss-2: build: context: ./build/oss-docker - dockerfile: Dockerfile environment: + - node.name=elasticsearch-oss-2 + - cluster.initial_master_nodes=elasticsearch-oss-1,elasticsearch-oss-2 + - discovery.seed_hosts=elasticsearch-oss-1:9300 - cluster.name=elasticsearch-oss - - discovery.type=single-node + - bootstrap.memory_lock=true + - "ES_JAVA_OPTS=-Xms512m -Xmx512m" + - path.repo=/tmp/es-repo + - node.attr.testattr=test + - cluster.routing.allocation.disk.watermark.low=1b + - cluster.routing.allocation.disk.watermark.high=1b + - cluster.routing.allocation.disk.watermark.flood_stage=1b + - script.max_compilations_rate=2048/1m + - node.store.allow_mmap=false + volumes: + - ./build/oss-repo:/tmp/es-repo ports: - "9200" + ulimits: + memlock: + soft: -1 + hard: -1 diff --git a/distribution/docker/src/test/java/org/elasticsearch/docker/test/DockerYmlTestSuiteIT.java b/distribution/docker/src/test/java/org/elasticsearch/docker/test/DockerYmlTestSuiteIT.java new file mode 100644 index 0000000000000..b173dd80feacd --- /dev/null +++ b/distribution/docker/src/test/java/org/elasticsearch/docker/test/DockerYmlTestSuiteIT.java @@ -0,0 +1,59 @@ +/* + * Licensed to Elasticsearch under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.elasticsearch.docker.test; + +import com.carrotsearch.randomizedtesting.annotations.ParametersFactory; +import org.elasticsearch.test.rest.yaml.ClientYamlTestCandidate; +import org.elasticsearch.test.rest.yaml.ESClientYamlSuiteTestCase; + +public class DockerYmlTestSuiteIT extends ESClientYamlSuiteTestCase { + + public DockerYmlTestSuiteIT(ClientYamlTestCandidate testCandidate) { + super(testCandidate); + } + + @ParametersFactory + public static Iterable parameters() throws Exception { + return createParameters(); + } + + @Override + protected String getTestRestCluster() { + String distribution = System.getProperty("tests.distribution", "default"); + if (distribution.equals("oss") == false && distribution.equals("default") == false) { + throw new IllegalArgumentException("supported values for tests.distribution are oss or default but it was " + distribution); + } + return new StringBuilder() + .append("localhost:") + .append(getProperty("test.fixtures.elasticsearch-" + distribution + "-1.tcp.9200")) + .append(",") + .append("localhost:") + .append(getProperty("test.fixtures.elasticsearch-" + distribution + "-2.tcp.9200")) + .toString(); + } + + private String getProperty(String key) { + String port = System.getProperty(key); + if (port == null) { + throw new IllegalStateException("Could not find system properties from test.fixtures. " + + "This test expects to run with the elasticsearch.test.fixtures Gradle plugin"); + } + return port; + } +} diff --git a/test/framework/src/main/java/org/elasticsearch/test/rest/ESRestTestCase.java b/test/framework/src/main/java/org/elasticsearch/test/rest/ESRestTestCase.java index de40f325b8f87..54d16a3719384 100644 --- a/test/framework/src/main/java/org/elasticsearch/test/rest/ESRestTestCase.java +++ b/test/framework/src/main/java/org/elasticsearch/test/rest/ESRestTestCase.java @@ -138,11 +138,7 @@ public void initClient() throws IOException { assert clusterHosts == null; assert hasXPack == null; assert nodeVersions == null; - String cluster = System.getProperty("tests.rest.cluster"); - if (cluster == null) { - throw new RuntimeException("Must specify [tests.rest.cluster] system property with a comma delimited list of [host:port] " - + "to which to send REST requests"); - } + String cluster = getTestRestCluster(); String[] stringUrls = cluster.split(","); List hosts = new ArrayList<>(stringUrls.length); for (String stringUrl : stringUrls) { @@ -180,6 +176,15 @@ public void initClient() throws IOException { assert hasXPack != null; assert nodeVersions != null; } + + protected String getTestRestCluster() { + String cluster = System.getProperty("tests.rest.cluster"); + if (cluster == null) { + throw new RuntimeException("Must specify [tests.rest.cluster] system property with a comma delimited list of [host:port] " + + "to which to send REST requests"); + } + return cluster; + } /** * Helper class to check warnings in REST responses with sensitivity to versions From 096258735ab0c2484a7152bc63b4731ded87f254 Mon Sep 17 00:00:00 2001 From: Alpar Torok Date: Fri, 1 Mar 2019 08:04:21 +0200 Subject: [PATCH 02/12] Add missing dependency --- distribution/docker/build.gradle | 1 + 1 file changed, 1 insertion(+) diff --git a/distribution/docker/build.gradle b/distribution/docker/build.gradle index 81dab3e6cfacf..1fd477a373c4e 100644 --- a/distribution/docker/build.gradle +++ b/distribution/docker/build.gradle @@ -122,6 +122,7 @@ dependencies { task copyRestTests(type: Sync) { from { zipTree(configurations.restSpec.singleFile) } into sourceSets.test.output.resourcesDir + dependsOn configurations.restSpec } processTestResources.dependsOn copyRestTests From cf69ae3b1453eb3de4d8ac71c45b0e18b8a39851 Mon Sep 17 00:00:00 2001 From: Alpar Torok Date: Fri, 1 Mar 2019 17:50:40 +0200 Subject: [PATCH 03/12] Add x-pack tests, export logs --- distribution/docker/build.gradle | 61 ++++++++-- distribution/docker/docker-compose.yml | 36 ++++++ .../docker/test/DockerYmlTestSuiteIT.java | 112 +++++++++++++++++- 3 files changed, 193 insertions(+), 16 deletions(-) diff --git a/distribution/docker/build.gradle b/distribution/docker/build.gradle index 1fd477a373c4e..0aa383e0f59b9 100644 --- a/distribution/docker/build.gradle +++ b/distribution/docker/build.gradle @@ -4,6 +4,12 @@ import org.elasticsearch.gradle.MavenFilteringHack import org.elasticsearch.gradle.VersionProperties import com.carrotsearch.gradle.junit4.RandomizedTestingTask +import javax.net.ssl.KeyManager +import javax.net.ssl.SSLContext +import javax.net.ssl.TrustManagerFactory +import java.security.KeyStore +import java.security.SecureRandom + apply plugin: 'elasticsearch.standalone-rest-test' apply plugin: 'elasticsearch.test.fixtures' @@ -92,23 +98,24 @@ void addCopyDockerfileTask(final boolean oss) { } } +Closure createAndSetWritable = {location -> + File file = file(location); + file.mkdirs() + file.setWritable(true, false) +} + preProcessFixture { dependsOn taskName("copy", true, "DockerContext") dependsOn taskName("copy", true, "Dockerfile") dependsOn taskName("copy", false, "DockerContext") dependsOn taskName("copy", false, "Dockerfile") doLast { - file("${buildDir}/repo").mkdirs(); - file("${buildDir}/repo").setWritable(true, false) - file("${buildDir}/oss-repo").mkdirs(); - file("${buildDir}/oss-repo").setWritable(true, false) - } -} - -postProcessFixture.doLast { - ["oss", "default"].each { flavor -> - println "Waiting for cluster status for $flavor" - println new URL("http://localhost:${ext."test.fixtures.elasticsearch-${flavor}-1.tcp.9200"}/_cluster/health?wait_for_nodes=>=1&wait_for_status=yellow").getText() + createAndSetWritable("${buildDir}/repo") + createAndSetWritable("${buildDir}/oss-repo") + createAndSetWritable("${buildDir}/logs/default-1") + createAndSetWritable("${buildDir}/logs/default-2") + createAndSetWritable("${buildDir}/logs/oss-1") + createAndSetWritable("${buildDir}/logs/oss-2") } } @@ -121,15 +128,45 @@ dependencies { task copyRestTests(type: Sync) { from { zipTree(configurations.restSpec.singleFile) } + from project(':x-pack:plugin:core') + .file('src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testnode.jks') into sourceSets.test.output.resourcesDir + if (System.getProperty("tests.distribution", "default") == "default") { + from { project(':x-pack:plugin').sourceSets.test.resources } + into sourceSets.test.output.resourcesDir + } dependsOn configurations.restSpec + // FIXME: check why these tests fail + exclude "**/data_frame/**" + exclude "**/ml/**" } processTestResources.dependsOn copyRestTests +task copyKeystore(type: Sync) { + from project(':x-pack:plugin:core') + .file('src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testnode.jks') + into "${buildDir}/certs" + doLast { + file("${buildDir}/certs").setReadable(true, false) + file("${buildDir}/certs/testnode.jks").setReadable(true, false) + } +} + task integTest(type: RandomizedTestingTask) { parallelism = '1' include '**/*IT.class' - dependsOn postProcessFixture + dependsOn copyKeystore + // FIXME: see why these tests fail + systemProperty 'tests.rest.blacklist', [ + 'snapshot.restore/10_basic/Create a snapshot and then restore it', + 'watcher/execute_watch/60_http_input/HTTP input supports extracting of keys', + 'token/10_basic/Test invalidate realm\'s tokens', + 'monitoring/bulk/10_basic/Bulk indexing of monitoring data on closed indices should throw an export exception', + 'indices.get_alias/10_basic/Get alias against closed indices', + 'cluster.put_settings/10_basic/Test get a default settings', + 'ssl/10_basic/Test get SSL certificates', + 'monitoring/bulk/20_privileges/Monitoring Bulk API' + ].join(",") } check.dependsOn integTest diff --git a/distribution/docker/docker-compose.yml b/distribution/docker/docker-compose.yml index b8aae5facdc62..95e85338dc047 100644 --- a/distribution/docker/docker-compose.yml +++ b/distribution/docker/docker-compose.yml @@ -18,14 +18,31 @@ services: - cluster.routing.allocation.disk.watermark.flood_stage=1b - script.max_compilations_rate=2048/1m - node.store.allow_mmap=false + - xpack.security.enabled=true + - xpack.security.transport.ssl.enabled=true + - xpack.security.http.ssl.enabled=true + - xpack.security.authc.token.enabled=true + - xpack.security.audit.enabled=true + - xpack.security.authc.realms.file.file1.order=0 + - xpack.security.authc.realms.native.native1.order=1 + - xpack.security.transport.ssl.keystore.path=/usr/share/elasticsearch/config/testnode.jks + - xpack.security.transport.ssl.keystore.password=testnode + - xpack.security.http.ssl.keystore.path=/usr/share/elasticsearch/config/testnode.jks + - xpack.security.http.ssl.keystore.password=testnode + - xpack.http.ssl.verification_mode=certificate + - xpack.security.transport.ssl.verification_mode=certificate + - xpack.license.self_generated.type=trial volumes: - ./build/repo:/tmp/es-repo + - ./build/certs/testnode.jks:/usr/share/elasticsearch/config/testnode.jks + - ./build/logs/default-1:/usr/share/elasticsearch/logs ports: - "9200" ulimits: memlock: soft: -1 hard: -1 + entrypoint: /bin/bash -c "/usr/share/elasticsearch/bin/elasticsearch-users useradd x_pack_rest_user -p x-pack-test-password -r superuser ; /usr/local/bin/docker-entrypoint.sh > /usr/share/elasticsearch/logs/console.log" elasticsearch-default-2: build: context: ./build/docker @@ -43,14 +60,31 @@ services: - cluster.routing.allocation.disk.watermark.flood_stage=1b - script.max_compilations_rate=2048/1m - node.store.allow_mmap=false + - xpack.security.enabled=true + - xpack.security.transport.ssl.enabled=true + - xpack.security.http.ssl.enabled=true + - xpack.security.authc.token.enabled=true + - xpack.security.audit.enabled=true + - xpack.security.authc.realms.file.file1.order=0 + - xpack.security.authc.realms.native.native1.order=1 + - xpack.security.transport.ssl.keystore.path=/usr/share/elasticsearch/config/testnode.jks + - xpack.security.transport.ssl.keystore.password=testnode + - xpack.security.http.ssl.keystore.path=/usr/share/elasticsearch/config/testnode.jks + - xpack.security.http.ssl.keystore.password=testnode + - xpack.http.ssl.verification_mode=certificate + - xpack.security.transport.ssl.verification_mode=certificate + - xpack.license.self_generated.type=trial volumes: - ./build/repo:/tmp/es-repo + - ./build/certs/testnode.jks:/usr/share/elasticsearch/config/testnode.jks + - ./build/logs/default-2:/usr/share/elasticsearch/logs ports: - "9200" ulimits: memlock: soft: -1 hard: -1 + entrypoint: /bin/bash -c "/usr/share/elasticsearch/bin/elasticsearch-users useradd x_pack_rest_user -p x-pack-test-password -r superuser ; /usr/local/bin/docker-entrypoint.sh > /usr/share/elasticsearch/logs/console.log" elasticsearch-oss-1: build: context: ./build/oss-docker @@ -70,6 +104,7 @@ services: - node.store.allow_mmap=false volumes: - ./build/oss-repo:/tmp/es-repo + - ./build/logs/oss-1:/usr/share/elasticsearch/logs ports: - "9200" ulimits: @@ -95,6 +130,7 @@ services: - node.store.allow_mmap=false volumes: - ./build/oss-repo:/tmp/es-repo + - ./build/logs/oss-2:/usr/share/elasticsearch/logs ports: - "9200" ulimits: diff --git a/distribution/docker/src/test/java/org/elasticsearch/docker/test/DockerYmlTestSuiteIT.java b/distribution/docker/src/test/java/org/elasticsearch/docker/test/DockerYmlTestSuiteIT.java index b173dd80feacd..53301c72eb6ae 100644 --- a/distribution/docker/src/test/java/org/elasticsearch/docker/test/DockerYmlTestSuiteIT.java +++ b/distribution/docker/src/test/java/org/elasticsearch/docker/test/DockerYmlTestSuiteIT.java @@ -19,11 +19,34 @@ package org.elasticsearch.docker.test; import com.carrotsearch.randomizedtesting.annotations.ParametersFactory; +import org.elasticsearch.ElasticsearchException; +import org.elasticsearch.client.Request; +import org.elasticsearch.common.CharArrays; +import org.elasticsearch.common.io.PathUtils; +import org.elasticsearch.common.settings.SecureString; +import org.elasticsearch.common.settings.Settings; +import org.elasticsearch.common.util.concurrent.ThreadContext; +import org.elasticsearch.test.rest.ESRestTestCase; import org.elasticsearch.test.rest.yaml.ClientYamlTestCandidate; import org.elasticsearch.test.rest.yaml.ESClientYamlSuiteTestCase; +import org.junit.AfterClass; +import org.junit.Before; +import org.junit.BeforeClass; + +import java.io.IOException; +import java.net.URISyntaxException; +import java.nio.CharBuffer; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.Arrays; +import java.util.Base64; public class DockerYmlTestSuiteIT extends ESClientYamlSuiteTestCase { + private static final String USER = "x_pack_rest_user"; + private static final String PASS = "x-pack-test-password"; + private static final String KEYSTORE_PASS = "testnode"; + public DockerYmlTestSuiteIT(ClientYamlTestCandidate testCandidate) { super(testCandidate); } @@ -35,10 +58,7 @@ public static Iterable parameters() throws Exception { @Override protected String getTestRestCluster() { - String distribution = System.getProperty("tests.distribution", "default"); - if (distribution.equals("oss") == false && distribution.equals("default") == false) { - throw new IllegalArgumentException("supported values for tests.distribution are oss or default but it was " + distribution); - } + String distribution = getDistribution(); return new StringBuilder() .append("localhost:") .append(getProperty("test.fixtures.elasticsearch-" + distribution + "-1.tcp.9200")) @@ -48,6 +68,23 @@ protected String getTestRestCluster() { .toString(); } + @Override + protected boolean randomizeContentType() { + return false; + } + + private String getDistribution() { + String distribution = System.getProperty("tests.distribution", "default"); + if (distribution.equals("oss") == false && distribution.equals("default") == false) { + throw new IllegalArgumentException("supported values for tests.distribution are oss or default but it was " + distribution); + } + return distribution; + } + + private boolean isOss() { + return getDistribution().equals("oss"); + } + private String getProperty(String key) { String port = System.getProperty(key); if (port == null) { @@ -56,4 +93,71 @@ private String getProperty(String key) { } return port; } + + @Before + public void waitForCluster() throws IOException { + super.initClient(); + Request health = new Request("GET", "/_cluster/health"); + health.addParameter("wait_for_nodes", "2"); + health.addParameter("wait_for_status", "yellow"); + client().performRequest(health); + } + + static Path keyStore; + + @BeforeClass + public static void getKeyStore() { + try { + keyStore = PathUtils.get(DockerYmlTestSuiteIT.class.getResource("/testnode.jks").toURI()); + } catch (URISyntaxException e) { + throw new ElasticsearchException("exception while reading the store", e); + } + if (!Files.exists(keyStore)) { + throw new IllegalStateException("Keystore file [" + keyStore + "] does not exist."); + } + } + + @AfterClass + public static void clearKeyStore() { + keyStore = null; + } + + @Override + protected Settings restClientSettings() { + if (isOss()) { + return super.restClientSettings(); + } + String token = basicAuthHeaderValue(USER, new SecureString(PASS.toCharArray())); + return Settings.builder() + .put(ThreadContext.PREFIX + ".Authorization", token) + .put(ESRestTestCase.TRUSTSTORE_PATH, keyStore) + .put(ESRestTestCase.TRUSTSTORE_PASSWORD, KEYSTORE_PASS) + .build(); + } + + @Override + protected String getProtocol() { + if (isOss()) { + return "http"; + } + return "https"; + } + + private static String basicAuthHeaderValue(String username, SecureString passwd) { + CharBuffer chars = CharBuffer.allocate(username.length() + passwd.length() + 1); + byte[] charBytes = null; + try { + chars.put(username).put(':').put(passwd.getChars()); + charBytes = CharArrays.toUtf8Bytes(chars.array()); + + //TODO we still have passwords in Strings in headers. Maybe we can look into using a CharSequence? + String basicToken = Base64.getEncoder().encodeToString(charBytes); + return "Basic " + basicToken; + } finally { + Arrays.fill(chars.array(), (char) 0); + if (charBytes != null) { + Arrays.fill(charBytes, (byte) 0); + } + } + } } From 02449555f0a3b2371a9eaf89e0a50f83c5d0cde5 Mon Sep 17 00:00:00 2001 From: Alpar Torok Date: Fri, 1 Mar 2019 18:01:37 +0200 Subject: [PATCH 04/12] Fix repo tests --- distribution/docker/build.gradle | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/distribution/docker/build.gradle b/distribution/docker/build.gradle index 0aa383e0f59b9..6157f41e5cb3a 100644 --- a/distribution/docker/build.gradle +++ b/distribution/docker/build.gradle @@ -110,6 +110,9 @@ preProcessFixture { dependsOn taskName("copy", false, "DockerContext") dependsOn taskName("copy", false, "Dockerfile") doLast { + // tests expect to have an empty repo + project.delete("${buildDir}/repo") + project.delete("${buildDir}/oss-repo") createAndSetWritable("${buildDir}/repo") createAndSetWritable("${buildDir}/oss-repo") createAndSetWritable("${buildDir}/logs/default-1") @@ -158,7 +161,6 @@ task integTest(type: RandomizedTestingTask) { dependsOn copyKeystore // FIXME: see why these tests fail systemProperty 'tests.rest.blacklist', [ - 'snapshot.restore/10_basic/Create a snapshot and then restore it', 'watcher/execute_watch/60_http_input/HTTP input supports extracting of keys', 'token/10_basic/Test invalidate realm\'s tokens', 'monitoring/bulk/10_basic/Bulk indexing of monitoring data on closed indices should throw an export exception', From 02278b6dc6c4ceb5382327f0d14080a75e1fe2fd Mon Sep 17 00:00:00 2001 From: Alpar Torok Date: Fri, 1 Mar 2019 19:57:18 +0200 Subject: [PATCH 05/12] Fix deprecation warnings --- distribution/docker/build.gradle | 3 +-- distribution/docker/docker-compose.yml | 10 ++++------ distribution/docker/docker-test-entrypoint.sh | 7 +++++++ 3 files changed, 12 insertions(+), 8 deletions(-) create mode 100755 distribution/docker/docker-test-entrypoint.sh diff --git a/distribution/docker/build.gradle b/distribution/docker/build.gradle index 6157f41e5cb3a..2ae480c9f3826 100644 --- a/distribution/docker/build.gradle +++ b/distribution/docker/build.gradle @@ -164,10 +164,9 @@ task integTest(type: RandomizedTestingTask) { 'watcher/execute_watch/60_http_input/HTTP input supports extracting of keys', 'token/10_basic/Test invalidate realm\'s tokens', 'monitoring/bulk/10_basic/Bulk indexing of monitoring data on closed indices should throw an export exception', + 'monitoring/bulk/20_privileges/Monitoring Bulk API', 'indices.get_alias/10_basic/Get alias against closed indices', - 'cluster.put_settings/10_basic/Test get a default settings', 'ssl/10_basic/Test get SSL certificates', - 'monitoring/bulk/20_privileges/Monitoring Bulk API' ].join(",") } diff --git a/distribution/docker/docker-compose.yml b/distribution/docker/docker-compose.yml index 95e85338dc047..9a7c6eebc7dd2 100644 --- a/distribution/docker/docker-compose.yml +++ b/distribution/docker/docker-compose.yml @@ -26,9 +26,7 @@ services: - xpack.security.authc.realms.file.file1.order=0 - xpack.security.authc.realms.native.native1.order=1 - xpack.security.transport.ssl.keystore.path=/usr/share/elasticsearch/config/testnode.jks - - xpack.security.transport.ssl.keystore.password=testnode - xpack.security.http.ssl.keystore.path=/usr/share/elasticsearch/config/testnode.jks - - xpack.security.http.ssl.keystore.password=testnode - xpack.http.ssl.verification_mode=certificate - xpack.security.transport.ssl.verification_mode=certificate - xpack.license.self_generated.type=trial @@ -36,13 +34,14 @@ services: - ./build/repo:/tmp/es-repo - ./build/certs/testnode.jks:/usr/share/elasticsearch/config/testnode.jks - ./build/logs/default-1:/usr/share/elasticsearch/logs + - ./docker-test-entrypoint.sh:/docker-test-entrypoint.sh ports: - "9200" ulimits: memlock: soft: -1 hard: -1 - entrypoint: /bin/bash -c "/usr/share/elasticsearch/bin/elasticsearch-users useradd x_pack_rest_user -p x-pack-test-password -r superuser ; /usr/local/bin/docker-entrypoint.sh > /usr/share/elasticsearch/logs/console.log" + entrypoint: /docker-test-entrypoint.sh elasticsearch-default-2: build: context: ./build/docker @@ -68,9 +67,7 @@ services: - xpack.security.authc.realms.file.file1.order=0 - xpack.security.authc.realms.native.native1.order=1 - xpack.security.transport.ssl.keystore.path=/usr/share/elasticsearch/config/testnode.jks - - xpack.security.transport.ssl.keystore.password=testnode - xpack.security.http.ssl.keystore.path=/usr/share/elasticsearch/config/testnode.jks - - xpack.security.http.ssl.keystore.password=testnode - xpack.http.ssl.verification_mode=certificate - xpack.security.transport.ssl.verification_mode=certificate - xpack.license.self_generated.type=trial @@ -78,13 +75,14 @@ services: - ./build/repo:/tmp/es-repo - ./build/certs/testnode.jks:/usr/share/elasticsearch/config/testnode.jks - ./build/logs/default-2:/usr/share/elasticsearch/logs + - ./docker-test-entrypoint.sh:/docker-test-entrypoint.sh ports: - "9200" ulimits: memlock: soft: -1 hard: -1 - entrypoint: /bin/bash -c "/usr/share/elasticsearch/bin/elasticsearch-users useradd x_pack_rest_user -p x-pack-test-password -r superuser ; /usr/local/bin/docker-entrypoint.sh > /usr/share/elasticsearch/logs/console.log" + entrypoint: /docker-test-entrypoint.sh elasticsearch-oss-1: build: context: ./build/oss-docker diff --git a/distribution/docker/docker-test-entrypoint.sh b/distribution/docker/docker-test-entrypoint.sh new file mode 100755 index 0000000000000..dabef6b8d71dd --- /dev/null +++ b/distribution/docker/docker-test-entrypoint.sh @@ -0,0 +1,7 @@ +#!/bin/bash +cd /usr/share/elasticsearch/bin/ +./elasticsearch-users useradd x_pack_rest_user -p x-pack-test-password -r superuser || true +echo "testnode" > /tmp/password +cat /tmp/password | ./elasticsearch-keystore add -x -f -v 'xpack.security.transport.ssl.keystore.secure_password' +cat /tmp/password | ./elasticsearch-keystore add -x -f -v 'xpack.security.http.ssl.keystore.secure_password' +/usr/local/bin/docker-entrypoint.sh > /usr/share/elasticsearch/logs/console.log From 012e88a6c2c0972eb019341f6e2d610c906de4f1 Mon Sep 17 00:00:00 2001 From: Alpar Torok Date: Mon, 4 Mar 2019 10:27:03 +0200 Subject: [PATCH 06/12] Fix task dependencies --- distribution/docker/build.gradle | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/distribution/docker/build.gradle b/distribution/docker/build.gradle index 2ae480c9f3826..8135e695cc6f8 100644 --- a/distribution/docker/build.gradle +++ b/distribution/docker/build.gradle @@ -104,11 +104,22 @@ Closure createAndSetWritable = {location -> file.setWritable(true, false) } +task copyKeystore(type: Sync) { + from project(':x-pack:plugin:core') + .file('src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testnode.jks') + into "${buildDir}/certs" + doLast { + file("${buildDir}/certs").setReadable(true, false) + file("${buildDir}/certs/testnode.jks").setReadable(true, false) + } +} + preProcessFixture { dependsOn taskName("copy", true, "DockerContext") dependsOn taskName("copy", true, "Dockerfile") dependsOn taskName("copy", false, "DockerContext") dependsOn taskName("copy", false, "Dockerfile") + dependsOn copyKeystore doLast { // tests expect to have an empty repo project.delete("${buildDir}/repo") @@ -145,20 +156,9 @@ task copyRestTests(type: Sync) { } processTestResources.dependsOn copyRestTests -task copyKeystore(type: Sync) { - from project(':x-pack:plugin:core') - .file('src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testnode.jks') - into "${buildDir}/certs" - doLast { - file("${buildDir}/certs").setReadable(true, false) - file("${buildDir}/certs/testnode.jks").setReadable(true, false) - } -} - task integTest(type: RandomizedTestingTask) { parallelism = '1' include '**/*IT.class' - dependsOn copyKeystore // FIXME: see why these tests fail systemProperty 'tests.rest.blacklist', [ 'watcher/execute_watch/60_http_input/HTTP input supports extracting of keys', From ef0e33a0ffb5c950148a140a85fa52ec114527ac Mon Sep 17 00:00:00 2001 From: Alpar Torok Date: Wed, 6 Mar 2019 20:53:42 +0200 Subject: [PATCH 07/12] PR review --- distribution/docker/build.gradle | 48 ++++++++----------- distribution/docker/docker-test-entrypoint.sh | 2 +- 2 files changed, 22 insertions(+), 28 deletions(-) diff --git a/distribution/docker/build.gradle b/distribution/docker/build.gradle index 8135e695cc6f8..4616f1e359c75 100644 --- a/distribution/docker/build.gradle +++ b/distribution/docker/build.gradle @@ -4,12 +4,6 @@ import org.elasticsearch.gradle.MavenFilteringHack import org.elasticsearch.gradle.VersionProperties import com.carrotsearch.gradle.junit4.RandomizedTestingTask -import javax.net.ssl.KeyManager -import javax.net.ssl.SSLContext -import javax.net.ssl.TrustManagerFactory -import java.security.KeyStore -import java.security.SecureRandom - apply plugin: 'elasticsearch.standalone-rest-test' apply plugin: 'elasticsearch.test.fixtures' @@ -17,11 +11,13 @@ configurations { dockerPlugins dockerSource ossDockerSource + restSpec } dependencies { dockerSource project(path: ":distribution:archives:linux-tar") ossDockerSource project(path: ":distribution:archives:oss-linux-tar") + restSpec "org.elasticsearch:rest-api-spec:${version}" } ext.expansions = { oss -> @@ -98,10 +94,12 @@ void addCopyDockerfileTask(final boolean oss) { } } -Closure createAndSetWritable = {location -> - File file = file(location); - file.mkdirs() - file.setWritable(true, false) +def createAndSetWritable (Object... locations) { + locations.each { location -> + File file = file(location) + file.mkdirs() + file.setWritable(true, false) + } } task copyKeystore(type: Sync) { @@ -122,33 +120,29 @@ preProcessFixture { dependsOn copyKeystore doLast { // tests expect to have an empty repo - project.delete("${buildDir}/repo") - project.delete("${buildDir}/oss-repo") - createAndSetWritable("${buildDir}/repo") - createAndSetWritable("${buildDir}/oss-repo") - createAndSetWritable("${buildDir}/logs/default-1") - createAndSetWritable("${buildDir}/logs/default-2") - createAndSetWritable("${buildDir}/logs/oss-1") - createAndSetWritable("${buildDir}/logs/oss-2") + project.delete( + "${buildDir}/repo", + "${buildDir}/oss-repo" + ) + createAndSetWritable( + "${buildDir}/repo", + "${buildDir}/oss-repo", + "${buildDir}/logs/default-1", + "${buildDir}/logs/default-2", + "${buildDir}/logs/oss-1", + "${buildDir}/logs/oss-2" + ) } } -configurations { - restSpec -} -dependencies { - restSpec "org.elasticsearch:rest-api-spec:${version}" -} - task copyRestTests(type: Sync) { from { zipTree(configurations.restSpec.singleFile) } from project(':x-pack:plugin:core') .file('src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testnode.jks') - into sourceSets.test.output.resourcesDir if (System.getProperty("tests.distribution", "default") == "default") { from { project(':x-pack:plugin').sourceSets.test.resources } - into sourceSets.test.output.resourcesDir } + into sourceSets.test.output.resourcesDir dependsOn configurations.restSpec // FIXME: check why these tests fail exclude "**/data_frame/**" diff --git a/distribution/docker/docker-test-entrypoint.sh b/distribution/docker/docker-test-entrypoint.sh index dabef6b8d71dd..a1e5dd0ffda2f 100755 --- a/distribution/docker/docker-test-entrypoint.sh +++ b/distribution/docker/docker-test-entrypoint.sh @@ -4,4 +4,4 @@ cd /usr/share/elasticsearch/bin/ echo "testnode" > /tmp/password cat /tmp/password | ./elasticsearch-keystore add -x -f -v 'xpack.security.transport.ssl.keystore.secure_password' cat /tmp/password | ./elasticsearch-keystore add -x -f -v 'xpack.security.http.ssl.keystore.secure_password' -/usr/local/bin/docker-entrypoint.sh > /usr/share/elasticsearch/logs/console.log +/usr/local/bin/docker-entrypoint.sh | tee > /usr/share/elasticsearch/logs/console.log From ef8bbb880e379e0a14cb8e8d202262cbebe4a4ec Mon Sep 17 00:00:00 2001 From: Alpar Torok Date: Thu, 7 Mar 2019 10:12:48 +0200 Subject: [PATCH 08/12] PR review --- distribution/docker/build.gradle | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/distribution/docker/build.gradle b/distribution/docker/build.gradle index 4616f1e359c75..ef706c58e3d99 100644 --- a/distribution/docker/build.gradle +++ b/distribution/docker/build.gradle @@ -135,26 +135,25 @@ preProcessFixture { } } -task copyRestTests(type: Sync) { +processTestResources { from { zipTree(configurations.restSpec.singleFile) } from project(':x-pack:plugin:core') .file('src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testnode.jks') if (System.getProperty("tests.distribution", "default") == "default") { from { project(':x-pack:plugin').sourceSets.test.resources } } - into sourceSets.test.output.resourcesDir dependsOn configurations.restSpec // FIXME: check why these tests fail exclude "**/data_frame/**" exclude "**/ml/**" } -processTestResources.dependsOn copyRestTests task integTest(type: RandomizedTestingTask) { parallelism = '1' include '**/*IT.class' // FIXME: see why these tests fail systemProperty 'tests.rest.blacklist', [ + 'snapshot.restore/10_basic/Create a snapshot and then restore it}', 'watcher/execute_watch/60_http_input/HTTP input supports extracting of keys', 'token/10_basic/Test invalidate realm\'s tokens', 'monitoring/bulk/10_basic/Bulk indexing of monitoring data on closed indices should throw an export exception', From 48eba36e34f5a4894d10e146e1ee2d6293e2ebb0 Mon Sep 17 00:00:00 2001 From: Alpar Torok Date: Thu, 7 Mar 2019 13:10:34 +0200 Subject: [PATCH 09/12] Add distribution as input property --- distribution/docker/build.gradle | 1 + 1 file changed, 1 insertion(+) diff --git a/distribution/docker/build.gradle b/distribution/docker/build.gradle index ef706c58e3d99..9597e17cd9caa 100644 --- a/distribution/docker/build.gradle +++ b/distribution/docker/build.gradle @@ -136,6 +136,7 @@ preProcessFixture { } processTestResources { + inputs.property "distribution", System.getProperty("tests.distribution", "default") from { zipTree(configurations.restSpec.singleFile) } from project(':x-pack:plugin:core') .file('src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testnode.jks') From 5f6b3f883862e42544c610953e9747fc7f922ad3 Mon Sep 17 00:00:00 2001 From: Alpar Torok Date: Thu, 21 Mar 2019 12:17:37 +0200 Subject: [PATCH 10/12] Replace the full test run with a minimal check --- distribution/docker/build.gradle | 21 +--- .../resources/rest-api-spec/test/10_info.yml | 11 ++ .../resources/rest-api-spec/test/11_nodes.yml | 108 ++++++++++++++++++ 3 files changed, 122 insertions(+), 18 deletions(-) create mode 100644 distribution/docker/src/test/resources/rest-api-spec/test/10_info.yml create mode 100644 distribution/docker/src/test/resources/rest-api-spec/test/11_nodes.yml diff --git a/distribution/docker/build.gradle b/distribution/docker/build.gradle index 9597e17cd9caa..5018769123518 100644 --- a/distribution/docker/build.gradle +++ b/distribution/docker/build.gradle @@ -136,32 +136,17 @@ preProcessFixture { } processTestResources { - inputs.property "distribution", System.getProperty("tests.distribution", "default") - from { zipTree(configurations.restSpec.singleFile) } + from ({ zipTree(configurations.restSpec.singleFile) }) { + include 'rest-api-spec/api/**' + } from project(':x-pack:plugin:core') .file('src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testnode.jks') - if (System.getProperty("tests.distribution", "default") == "default") { - from { project(':x-pack:plugin').sourceSets.test.resources } - } dependsOn configurations.restSpec - // FIXME: check why these tests fail - exclude "**/data_frame/**" - exclude "**/ml/**" } task integTest(type: RandomizedTestingTask) { parallelism = '1' include '**/*IT.class' - // FIXME: see why these tests fail - systemProperty 'tests.rest.blacklist', [ - 'snapshot.restore/10_basic/Create a snapshot and then restore it}', - 'watcher/execute_watch/60_http_input/HTTP input supports extracting of keys', - 'token/10_basic/Test invalidate realm\'s tokens', - 'monitoring/bulk/10_basic/Bulk indexing of monitoring data on closed indices should throw an export exception', - 'monitoring/bulk/20_privileges/Monitoring Bulk API', - 'indices.get_alias/10_basic/Get alias against closed indices', - 'ssl/10_basic/Test get SSL certificates', - ].join(",") } check.dependsOn integTest diff --git a/distribution/docker/src/test/resources/rest-api-spec/test/10_info.yml b/distribution/docker/src/test/resources/rest-api-spec/test/10_info.yml new file mode 100644 index 0000000000000..cf746ce5ba0b6 --- /dev/null +++ b/distribution/docker/src/test/resources/rest-api-spec/test/10_info.yml @@ -0,0 +1,11 @@ +--- +"Info": + - do: {info: {}} + - is_true: name + - is_true: cluster_name + - is_true: cluster_uuid + - is_true: tagline + - is_true: version + - is_true: version.number + - match: { version.build_type: "docker" } + diff --git a/distribution/docker/src/test/resources/rest-api-spec/test/11_nodes.yml b/distribution/docker/src/test/resources/rest-api-spec/test/11_nodes.yml new file mode 100644 index 0000000000000..1004e19b6b5ae --- /dev/null +++ b/distribution/docker/src/test/resources/rest-api-spec/test/11_nodes.yml @@ -0,0 +1,108 @@ +--- +"Test cat nodes output": + + - do: + cat.nodes: {} + + - match: + $body: | + / #ip heap.percent ram.percent cpu load_1m load_5m load_15m node.role master name + ^ ((\d{1,3}\.){3}\d{1,3} \s+ \d+ \s+ \d* \s+ (-)?\d* \s+ ((-)?\d*(\.\d+)?)? \s+ ((-)?\d*(\.\d+)?)?\s+ ((-)?\d*(\.\d+)?)? \s+ (-|[dmi]{1,3}) \s+ [-*x] \s+ (\S+\s?)+ \n)+ $/ + + - do: + cat.nodes: + v: true + + - match: + $body: | + /^ ip \s+ heap\.percent \s+ ram\.percent \s+ cpu \s+ load_1m \s+ load_5m \s+ load_15m \s+ node\.role \s+ master \s+ name \n + ((\d{1,3}\.){3}\d{1,3} \s+ \d+ \s+ \d* \s+ (-)?\d* \s+ ((-)?\d*(\.\d+)?)? \s+ ((-)?\d*(\.\d+)?)? \s+ ((-)?\d*(\.\d+)?)? \s+ (-|[dmi]{1,3}) \s+ [-*x] \s+ (\S+\s?)+ \n)+ $/ + + - do: + cat.nodes: + h: heap.current,heap.percent,heap.max + v: true + + - match: + $body: | + /^ heap\.current \s+ heap\.percent \s+ heap\.max \n + (\s+ \d+(\.\d+)?[ptgmk]?b \s+ \d+ \s+ \d+(\.\d+)?[ptgmk]?b \n)+ $/ + + - do: + cat.nodes: + h: heap.* + v: true + + - match: + $body: | + /^ heap\.current \s+ heap\.percent \s+ heap\.max \n + (\s+ \d+(\.\d+)?[ptgmk]?b \s+ \d+ \s+ \d+(\.\d+)?[ptgmk]?b \n)+ $/ + + - do: + cat.nodes: + h: file_desc.current,file_desc.percent,file_desc.max + v: true + + - match: + # Windows reports -1 for the file descriptor counts. + $body: | + /^ file_desc\.current \s+ file_desc\.percent \s+ file_desc\.max \n + (\s+ (-1|\d+) \s+ \d+ \s+ (-1|\d+) \n)+ $/ + + - do: + cat.nodes: + h: http + v: true + + - match: + $body: | + /^ http \n ((\d{1,3}\.){3}\d{1,3}:\d{1,5}\n)+ $/ + +--- +"Additional disk information": + - do: + cat.nodes: + h: diskAvail,diskTotal,diskUsed,diskUsedPercent + v: true + + - match: + # leading whitespace on columns and optional whitespace on values is necessary + # because `diskAvail` is right aligned and text representation of disk size might be + # longer so it's padded with leading whitespace + $body: | + /^ \s* diskAvail \s+ diskTotal \s+ diskUsed \s+ diskUsedPercent \n + (\s* \d+(\.\d+)?[ptgmk]?b \s+ \d+(\.\d+)?[ptgmk]?b \s+ \d+(\.\d+)?[ptgmk]?b\s+ (100\.00 | \d{1,2}\.\d{2}) \n)+ $/ + + - do: + cat.nodes: + h: disk,dt,du,dup + v: true + + - match: + # leading whitespace on columns and optional whitespace on values is necessary + # because `disk` is right aligned and text representation of disk size might be + # longer so it's padded with leading whitespace + $body: | + /^ \s* disk \s+ dt \s+ du \s+ dup \n + (\s* \d+(\.\d+)?[ptgmk]?b \s+ \d+(\.\d+)?[ptgmk]?b \s+ \d+(\.\d+)?[ptgmk]?b\s+ (100\.00 | \d{1,2}\.\d{2}) \n)+ $/ + +--- +"Test cat nodes output with full_id set": + + - do: + cat.nodes: + h: id + # check for a 4 char non-whitespace character string + - match: + $body: | + /^(\S{4}\n)+$/ + + - do: + cat.nodes: + h: id + full_id: true + # check for a 5+ char non-whitespace character string + - match: + $body: | + /^(\S{5,}\n)+$/ + From d86c25d81940c9e875732c60ac47ef8d2ff34469 Mon Sep 17 00:00:00 2001 From: Alpar Torok Date: Fri, 29 Mar 2019 13:34:13 +0200 Subject: [PATCH 11/12] PR review --- .../elasticsearch/docker/test/DockerYmlTestSuiteIT.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/distribution/docker/src/test/java/org/elasticsearch/docker/test/DockerYmlTestSuiteIT.java b/distribution/docker/src/test/java/org/elasticsearch/docker/test/DockerYmlTestSuiteIT.java index 53301c72eb6ae..3a88301828096 100644 --- a/distribution/docker/src/test/java/org/elasticsearch/docker/test/DockerYmlTestSuiteIT.java +++ b/distribution/docker/src/test/java/org/elasticsearch/docker/test/DockerYmlTestSuiteIT.java @@ -86,12 +86,12 @@ private boolean isOss() { } private String getProperty(String key) { - String port = System.getProperty(key); - if (port == null) { + String value = System.getProperty(key); + if (value == null) { throw new IllegalStateException("Could not find system properties from test.fixtures. " + "This test expects to run with the elasticsearch.test.fixtures Gradle plugin"); } - return port; + return value; } @Before @@ -112,7 +112,7 @@ public static void getKeyStore() { } catch (URISyntaxException e) { throw new ElasticsearchException("exception while reading the store", e); } - if (!Files.exists(keyStore)) { + if (Files.exists(keyStore) == false) { throw new IllegalStateException("Keystore file [" + keyStore + "] does not exist."); } } From 4b785b888350c3ede52080ac82892c226690c8dc Mon Sep 17 00:00:00 2001 From: Alpar Torok Date: Fri, 12 Apr 2019 17:47:49 +0300 Subject: [PATCH 12/12] Migrate to Gradle Test task --- distribution/docker/build.gradle | 5 ++--- distribution/docker/docker-compose.yml | 1 + 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/distribution/docker/build.gradle b/distribution/docker/build.gradle index e11111e4bab78..61c9be37bd9be 100644 --- a/distribution/docker/build.gradle +++ b/distribution/docker/build.gradle @@ -2,7 +2,6 @@ import org.elasticsearch.gradle.BuildPlugin import org.elasticsearch.gradle.LoggedExec import org.elasticsearch.gradle.MavenFilteringHack import org.elasticsearch.gradle.VersionProperties -import com.carrotsearch.gradle.junit4.RandomizedTestingTask apply plugin: 'elasticsearch.standalone-rest-test' apply plugin: 'elasticsearch.test.fixtures' @@ -139,8 +138,8 @@ processTestResources { dependsOn configurations.restSpec } -task integTest(type: RandomizedTestingTask) { - parallelism = '1' +task integTest(type: Test) { + maxParallelForks = '1' include '**/*IT.class' } diff --git a/distribution/docker/docker-compose.yml b/distribution/docker/docker-compose.yml index 4eb799e08c31a..ec6730f6dd558 100644 --- a/distribution/docker/docker-compose.yml +++ b/distribution/docker/docker-compose.yml @@ -130,3 +130,4 @@ services: ulimits: memlock: soft: -1 + hard: -1