Extend tribe integ test infra to test on master and client nodes
Original commit: elastic/x-pack-elasticsearch@5826fb4161
This commit is contained in:
parent
3f0acdd70e
commit
bd04cc9d1f
|
@ -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
|
||||
|
|
|
@ -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<String> 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.<String>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
|
||||
*/
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue