From bdb36263b3368b994c8c921b5dcd7ab42b0a27e3 Mon Sep 17 00:00:00 2001 From: Robert Muir Date: Thu, 9 Jul 2015 02:48:45 -0400 Subject: [PATCH 1/6] get ES server started and stopped with shield... but many problems Original commit: elastic/x-pack-elasticsearch@c6b6bc4c103681946a423625b574b640b664f1c8 --- dev-tools/integration-tests.xml | 66 +++++++++++++++++++ pom.xml | 10 ++- .../elasticsearch/shield/ShieldPlugin.java | 2 +- .../shield/test/ShieldAssertions.java | 2 +- .../org/elasticsearch/test/ShieldRestIT.java | 29 ++++++++ 5 files changed, 105 insertions(+), 4 deletions(-) create mode 100644 dev-tools/integration-tests.xml create mode 100644 src/test/java/org/elasticsearch/test/ShieldRestIT.java diff --git a/dev-tools/integration-tests.xml b/dev-tools/integration-tests.xml new file mode 100644 index 00000000000..a2ffe2b2640 --- /dev/null +++ b/dev-tools/integration-tests.xml @@ -0,0 +1,66 @@ + + + + + + + + + + + + + + + + + + + + + + Installing license plugin... + + + + + + Installing plugin ${project.artifactId}... + + + + Starting up external cluster... + + + + + + + + + + + + + + + + + + + + + + External cluster started PID ${integ.pid} + + diff --git a/pom.xml b/pom.xml index 6ecb2e13347..1b2e5c2e1ef 100644 --- a/pom.xml +++ b/pom.xml @@ -47,10 +47,9 @@ - - true dev-tools/elasticsearch_license_header.txt dev-tools/license_header_definition.xml + dev-tools/integration-tests.xml 2.0.0-SNAPSHOT indices.get/10_basic/*allow_no_indices*,cat.count/10_basic/Test cat count output,cat.aliases/10_basic/Empty cluster,indices.segments/10_basic/no segments test,indices.clear_cache/10_basic/clear_cache test,indices.status/10_basic/Indices status test,cat.indices/10_basic/Test cat indices output,cat.recovery/10_basic/Test cat recovery output,cat.shards/10_basic/Test cat shards output,termvector/20_issue7121/*,index/10_with_id/Index with ID,indices.get_alias/20_emtpy/*,cat.segments/10_basic/Test cat segments output,indices.put_settings/10_basic/Test indices settings allow_no_indices,indices.put_settings/10_basic/Test indices settings ignore_unavailable,indices.refresh/10_basic/Indices refresh test no-match wildcard,indices.stats/10_index/Index - star*,indices.recovery/10_basic/Indices recovery test*,template/30_render_search_template/* @@ -96,6 +95,13 @@ 1.0 test + + org.elasticsearch + elasticsearch-license-plugin + ${license.plugin.version} + zip + test + com.github.spullara.mustache.java diff --git a/src/main/java/org/elasticsearch/shield/ShieldPlugin.java b/src/main/java/org/elasticsearch/shield/ShieldPlugin.java index 9c26ab09419..a7e449d1c95 100644 --- a/src/main/java/org/elasticsearch/shield/ShieldPlugin.java +++ b/src/main/java/org/elasticsearch/shield/ShieldPlugin.java @@ -31,7 +31,7 @@ import java.util.Map; */ public class ShieldPlugin extends AbstractPlugin { - public static final String NAME = "shield"; + public static final String NAME = "elasticsearch-shield"; public static final String ENABLED_SETTING_NAME = NAME + ".enabled"; diff --git a/src/test/java/org/elasticsearch/shield/test/ShieldAssertions.java b/src/test/java/org/elasticsearch/shield/test/ShieldAssertions.java index 8c3ef8a747a..28ad43b41e5 100644 --- a/src/test/java/org/elasticsearch/shield/test/ShieldAssertions.java +++ b/src/test/java/org/elasticsearch/shield/test/ShieldAssertions.java @@ -17,6 +17,6 @@ public class ShieldAssertions { assertThat(e.status(), is(RestStatus.UNAUTHORIZED)); assertThat(e.getHeaderKeys(), hasSize(1)); assertThat(e.getHeader("WWW-Authenticate"), notNullValue()); - assertThat(e.getHeader("WWW-Authenticate"), contains("Basic realm=\"shield\"")); + assertThat(e.getHeader("WWW-Authenticate"), contains("Basic realm=\"elasticsearch-shield\"")); } } diff --git a/src/test/java/org/elasticsearch/test/ShieldRestIT.java b/src/test/java/org/elasticsearch/test/ShieldRestIT.java new file mode 100644 index 00000000000..63f55ba28c3 --- /dev/null +++ b/src/test/java/org/elasticsearch/test/ShieldRestIT.java @@ -0,0 +1,29 @@ +/* + * 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.test; + +import com.carrotsearch.randomizedtesting.annotations.Name; +import com.carrotsearch.randomizedtesting.annotations.ParametersFactory; + +import org.elasticsearch.test.rest.ElasticsearchRestTestCase; +import org.elasticsearch.test.rest.RestTestCandidate; +import org.elasticsearch.test.rest.parser.RestTestParseException; +import org.junit.Ignore; + +import java.io.IOException; + +/** Runs rest tests against external cluster */ +@Ignore("not yet functional") +public class ShieldRestIT extends ShieldRestTestCase { + public ShieldRestIT(@Name("yaml") RestTestCandidate testCandidate) { + super(testCandidate); + } + + @ParametersFactory + public static Iterable parameters() throws IOException, RestTestParseException { + return ElasticsearchRestTestCase.createParameters(0, 1); + } +} From f7046efd482292a1680f392eb70d59bae2570dbc Mon Sep 17 00:00:00 2001 From: Robert Muir Date: Thu, 9 Jul 2015 02:56:41 -0400 Subject: [PATCH 2/6] use java.io.tmpdir for the GET hack Original commit: elastic/x-pack-elasticsearch@ed63b5add833aca32caf51331e41865b8560918d --- dev-tools/integration-tests.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dev-tools/integration-tests.xml b/dev-tools/integration-tests.xml index a2ffe2b2640..7a239261020 100644 --- a/dev-tools/integration-tests.xml +++ b/dev-tools/integration-tests.xml @@ -56,7 +56,7 @@ - + From b1147e3cb34fe640ae6bf2e90e4552c77c363a61 Mon Sep 17 00:00:00 2001 From: jaymode Date: Thu, 9 Jul 2015 07:21:45 -0400 Subject: [PATCH 3/6] fix IndexAuditTrailTests Original commit: elastic/x-pack-elasticsearch@d94ecf98e1f606cc0a5da96820fe72d1369cec73 --- src/main/java/org/elasticsearch/shield/ShieldPlugin.java | 1 + .../elasticsearch/shield/audit/index/IndexAuditTrail.java | 8 ++++++-- .../shield/audit/index/IndexAuditTrailTests.java | 3 ++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/elasticsearch/shield/ShieldPlugin.java b/src/main/java/org/elasticsearch/shield/ShieldPlugin.java index a7e449d1c95..48d6bf6e5b2 100644 --- a/src/main/java/org/elasticsearch/shield/ShieldPlugin.java +++ b/src/main/java/org/elasticsearch/shield/ShieldPlugin.java @@ -31,6 +31,7 @@ import java.util.Map; */ public class ShieldPlugin extends AbstractPlugin { + // FIXME need to get this back to Shield once bugs fixed in core... https://github.com/elastic/elasticsearch/issues/12143 public static final String NAME = "elasticsearch-shield"; public static final String ENABLED_SETTING_NAME = NAME + ".enabled"; diff --git a/src/main/java/org/elasticsearch/shield/audit/index/IndexAuditTrail.java b/src/main/java/org/elasticsearch/shield/audit/index/IndexAuditTrail.java index ac5ba082515..d19ccc26d8a 100644 --- a/src/main/java/org/elasticsearch/shield/audit/index/IndexAuditTrail.java +++ b/src/main/java/org/elasticsearch/shield/audit/index/IndexAuditTrail.java @@ -241,7 +241,9 @@ public class IndexAuditTrail extends AbstractComponent implements AuditTrail { if (state.compareAndSet(State.STARTED, State.STOPPING)) { try { queueConsumer.interrupt(); - bulkProcessor.flush(); + if (bulkProcessor != null) { + bulkProcessor.flush(); + } } finally { state.set(State.STOPPED); } @@ -254,7 +256,9 @@ public class IndexAuditTrail extends AbstractComponent implements AuditTrail { } try { - bulkProcessor.close(); + if (bulkProcessor != null) { + bulkProcessor.close(); + } } finally { if (indexToRemoteCluster) { if (client != null) { diff --git a/src/test/java/org/elasticsearch/shield/audit/index/IndexAuditTrailTests.java b/src/test/java/org/elasticsearch/shield/audit/index/IndexAuditTrailTests.java index 9f5cd4b9268..810cd6972a2 100644 --- a/src/test/java/org/elasticsearch/shield/audit/index/IndexAuditTrailTests.java +++ b/src/test/java/org/elasticsearch/shield/audit/index/IndexAuditTrailTests.java @@ -23,6 +23,7 @@ import org.elasticsearch.indices.IndexMissingException; import org.elasticsearch.node.Node; import org.elasticsearch.rest.RestRequest; import org.elasticsearch.search.SearchHit; +import org.elasticsearch.shield.ShieldPlugin; import org.elasticsearch.shield.User; import org.elasticsearch.shield.authc.AuthenticationService; import org.elasticsearch.shield.authc.AuthenticationToken; @@ -124,7 +125,7 @@ public class IndexAuditTrailTests extends ShieldIntegrationTest { if (remoteIndexing) { // start a small single-node cluster to test remote indexing against logger.info("--> remote indexing enabled"); - Settings s = Settings.builder().put("shield.enabled", "false").put("path.home", createTempDir()).build(); + Settings s = Settings.builder().put(ShieldPlugin.ENABLED_SETTING_NAME, false).put("path.home", createTempDir()).build(); remoteNode = nodeBuilder().clusterName(REMOTE_TEST_CLUSTER).data(true).settings(s).node(); remoteClient = remoteNode.client(); From d2d5e62230477ab041f92117df4c11b318b2f60b Mon Sep 17 00:00:00 2001 From: jaymode Date: Thu, 9 Jul 2015 09:41:23 -0400 Subject: [PATCH 4/6] make integration tests work Original commit: elastic/x-pack-elasticsearch@379e705138ce4bdb6434ef78536aed03e0c41a0d --- .../java/org/elasticsearch/test/ShieldIntegrationTest.java | 7 +++++++ src/test/java/org/elasticsearch/test/ShieldRestIT.java | 2 -- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/test/java/org/elasticsearch/test/ShieldIntegrationTest.java b/src/test/java/org/elasticsearch/test/ShieldIntegrationTest.java index e67f786eae2..f70340d056c 100644 --- a/src/test/java/org/elasticsearch/test/ShieldIntegrationTest.java +++ b/src/test/java/org/elasticsearch/test/ShieldIntegrationTest.java @@ -167,6 +167,13 @@ public abstract class ShieldIntegrationTest extends ElasticsearchIntegrationTest .build(); } + @Override + protected Settings externalClusterClientSettings() { + return Settings.builder() + .put("shield.user", ShieldSettingsSource.DEFAULT_USER_NAME + ":" + ShieldSettingsSource.DEFAULT_PASSWORD) + .build(); + } + /** * Allows for us to get the system key that is being used for the cluster * @return the system key bytes diff --git a/src/test/java/org/elasticsearch/test/ShieldRestIT.java b/src/test/java/org/elasticsearch/test/ShieldRestIT.java index 63f55ba28c3..c0d7a58ac1e 100644 --- a/src/test/java/org/elasticsearch/test/ShieldRestIT.java +++ b/src/test/java/org/elasticsearch/test/ShieldRestIT.java @@ -11,12 +11,10 @@ import com.carrotsearch.randomizedtesting.annotations.ParametersFactory; import org.elasticsearch.test.rest.ElasticsearchRestTestCase; import org.elasticsearch.test.rest.RestTestCandidate; import org.elasticsearch.test.rest.parser.RestTestParseException; -import org.junit.Ignore; import java.io.IOException; /** Runs rest tests against external cluster */ -@Ignore("not yet functional") public class ShieldRestIT extends ShieldRestTestCase { public ShieldRestIT(@Name("yaml") RestTestCandidate testCandidate) { super(testCandidate); From aac2fb5b75704662250b651ccf08cc011573f6be Mon Sep 17 00:00:00 2001 From: jaymode Date: Thu, 9 Jul 2015 11:35:30 -0400 Subject: [PATCH 5/6] elasticsearch-shield back to shield Original commit: elastic/x-pack-elasticsearch@128fda2cd3cb7ca984badeb4f75c9b2e78c97376 --- dev-tools/integration-tests.xml | 4 ++-- src/main/java/org/elasticsearch/shield/ShieldPlugin.java | 3 +-- .../java/org/elasticsearch/shield/test/ShieldAssertions.java | 3 ++- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/dev-tools/integration-tests.xml b/dev-tools/integration-tests.xml index 7a239261020..1084222f5ce 100644 --- a/dev-tools/integration-tests.xml +++ b/dev-tools/integration-tests.xml @@ -39,10 +39,10 @@ - + - - - - - -