From bd04cc9d1feacebd2d497d863522cd054647b341 Mon Sep 17 00:00:00 2001 From: Areek Zillur Date: Tue, 3 May 2016 14:43:43 -0400 Subject: [PATCH] Extend tribe integ test infra to test on master and client nodes Original commit: elastic/x-pack-elasticsearch@5826fb4161082942546141faf86b228053b31a03 --- .../license/plugin/LicenseTribeTests.java | 20 +++++++++++++--- .../xpack/TribeTransportTestCase.java | 23 ++++++++++++++----- .../marvel/MonitoringTribeTests.java | 16 ++++++++++++- 3 files changed, 49 insertions(+), 10 deletions(-) diff --git a/elasticsearch/x-pack/license-plugin/src/test/java/org/elasticsearch/license/plugin/LicenseTribeTests.java b/elasticsearch/x-pack/license-plugin/src/test/java/org/elasticsearch/license/plugin/LicenseTribeTests.java index 51709949de4..29d0f7766b5 100644 --- a/elasticsearch/x-pack/license-plugin/src/test/java/org/elasticsearch/license/plugin/LicenseTribeTests.java +++ b/elasticsearch/x-pack/license-plugin/src/test/java/org/elasticsearch/license/plugin/LicenseTribeTests.java @@ -19,12 +19,26 @@ import static org.elasticsearch.license.plugin.TestUtils.generateSignedLicense; public class LicenseTribeTests extends TribeTransportTestCase { + @Override + protected void verifyActionOnClientNode(Client client) throws Exception { + assertLicenseTransportActionsWorks(client); + } + + @Override + protected void verifyActionOnMasterNode(Client masterClient) throws Exception { + assertLicenseTransportActionsWorks(masterClient); + } + @Override protected void verifyActionOnDataNode(Client dataNodeClient) throws Exception { - dataNodeClient.execute(GetLicenseAction.INSTANCE, new GetLicenseRequest()).get(); - dataNodeClient.execute(PutLicenseAction.INSTANCE, new PutLicenseRequest() + assertLicenseTransportActionsWorks(dataNodeClient); + } + + private static void assertLicenseTransportActionsWorks(Client client) throws Exception { + client.execute(GetLicenseAction.INSTANCE, new GetLicenseRequest()).get(); + client.execute(PutLicenseAction.INSTANCE, new PutLicenseRequest() .license(generateSignedLicense(TimeValue.timeValueHours(1)))); - dataNodeClient.execute(DeleteLicenseAction.INSTANCE, new DeleteLicenseRequest()); + client.execute(DeleteLicenseAction.INSTANCE, new DeleteLicenseRequest()); } @Override diff --git a/elasticsearch/x-pack/license-plugin/src/test/java/org/elasticsearch/xpack/TribeTransportTestCase.java b/elasticsearch/x-pack/license-plugin/src/test/java/org/elasticsearch/xpack/TribeTransportTestCase.java index 8fdb4fae563..deb1c6456e4 100644 --- a/elasticsearch/x-pack/license-plugin/src/test/java/org/elasticsearch/xpack/TribeTransportTestCase.java +++ b/elasticsearch/x-pack/license-plugin/src/test/java/org/elasticsearch/xpack/TribeTransportTestCase.java @@ -11,7 +11,6 @@ import org.elasticsearch.action.admin.cluster.node.info.NodeInfo; import org.elasticsearch.action.admin.cluster.node.info.NodesInfoResponse; import org.elasticsearch.client.Client; import org.elasticsearch.client.Requests; -import org.elasticsearch.client.transport.NoNodeAvailableException; import org.elasticsearch.cluster.health.ClusterHealthStatus; import org.elasticsearch.cluster.node.DiscoveryNode; import org.elasticsearch.cluster.node.DiscoveryNodes; @@ -46,7 +45,7 @@ import static org.hamcrest.Matchers.anyOf; import static org.hamcrest.Matchers.containsString; import static org.hamcrest.Matchers.equalTo; -@ClusterScope(scope = Scope.TEST, transportClientRatio = 0, numClientNodes = 0, numDataNodes = 0) +@ClusterScope(scope = Scope.TEST, transportClientRatio = 0, numClientNodes = 1, numDataNodes = 0) public abstract class TribeTransportTestCase extends ESIntegTestCase { private static final Collection ALL_FEATURES = Arrays.asList(Security.NAME, Monitoring.NAME, @@ -102,7 +101,7 @@ public abstract class TribeTransportTestCase extends ESIntegTestCase { }; final InternalTestCluster cluster2 = new InternalTestCluster(InternalTestCluster.configuredNodeMode(), randomLong(), createTempDir(), 2, 2, - UUIDs.randomBase64UUID(random()), nodeConfigurationSource, 0, false, "tribe_node2", + UUIDs.randomBase64UUID(random()), nodeConfigurationSource, 1, false, "tribe_node2", getMockPlugins(), getClientWrapper()); cluster2.beforeTest(random(), 0.0); @@ -155,12 +154,14 @@ public abstract class TribeTransportTestCase extends ESIntegTestCase { }); logger.info(" --> verify transport actions for tribe node"); verifyActionOnTribeNode(tribeClient); - logger.info(" --> verify transport actions for data and master node"); + logger.info(" --> verify transport actions for data node"); verifyActionOnDataNode((randomBoolean() ? internalCluster() : cluster2).dataNodeClient()); - verifyActionOnDataNode((randomBoolean() ? internalCluster() : cluster2).masterClient()); + logger.info(" --> verify transport actions for master node"); + verifyActionOnMasterNode((randomBoolean() ? internalCluster() : cluster2).masterClient()); + logger.info(" --> verify transport actions for client node"); + verifyActionOnClientNode((randomBoolean() ? internalCluster() : cluster2).coordOnlyNodeClient()); try { cluster2.wipe(Collections.emptySet()); - } catch (NoNodeAvailableException ignored) { } finally { cluster2.afterTest(); } @@ -168,6 +169,16 @@ public abstract class TribeTransportTestCase extends ESIntegTestCase { cluster2.close(); } + /** + * Verify transport action behaviour on client node + */ + protected abstract void verifyActionOnClientNode(Client client) throws Exception; + + /** + * Verify transport action behaviour on master node + */ + protected abstract void verifyActionOnMasterNode(Client masterClient) throws Exception; + /** * Verify transport action behaviour on data node */ diff --git a/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/MonitoringTribeTests.java b/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/MonitoringTribeTests.java index d9b5204a3f9..df11eaae87e 100644 --- a/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/MonitoringTribeTests.java +++ b/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/MonitoringTribeTests.java @@ -22,12 +22,26 @@ public class MonitoringTribeTests extends TribeTransportTestCase { return Collections.singletonList(Monitoring.NAME); } + @Override + protected void verifyActionOnClientNode(Client client) throws Exception { + assertMonitoringTransportActionsWorks(client); + } + + @Override + protected void verifyActionOnMasterNode(Client masterClient) throws Exception { + assertMonitoringTransportActionsWorks(masterClient); + } + @Override protected void verifyActionOnDataNode(Client dataNodeClient) throws Exception { + assertMonitoringTransportActionsWorks(dataNodeClient); + } + + private static void assertMonitoringTransportActionsWorks(Client client) throws Exception { MonitoringBulkDoc doc = new MonitoringBulkDoc(randomAsciiOfLength(2), randomAsciiOfLength(2)); doc.setType(randomAsciiOfLength(5)); doc.setSource(new BytesArray("{\"key\" : \"value\"}")); - dataNodeClient.execute(MonitoringBulkAction.INSTANCE, new MonitoringBulkRequest()); + client.execute(MonitoringBulkAction.INSTANCE, new MonitoringBulkRequest()); } @Override