use of org.opensearch.common.transport.TransportAddress in project OpenSearch by opensearch-project.
the class Ec2DiscoveryTests method testFilterByTags.
public void testFilterByTags() throws InterruptedException {
int nodes = randomIntBetween(5, 10);
Settings nodeSettings = Settings.builder().put(AwsEc2Service.TAG_SETTING.getKey() + "stage", "prod").build();
int prodInstances = 0;
List<List<Tag>> tagsList = new ArrayList<>();
for (int node = 0; node < nodes; node++) {
List<Tag> tags = new ArrayList<>();
if (randomBoolean()) {
tags.add(new Tag("stage", "prod"));
prodInstances++;
} else {
tags.add(new Tag("stage", "dev"));
}
tagsList.add(tags);
}
logger.info("started [{}] instances with [{}] stage=prod tag", nodes, prodInstances);
List<TransportAddress> dynamicHosts = buildDynamicHosts(nodeSettings, nodes, tagsList);
assertThat(dynamicHosts, hasSize(prodInstances));
}
use of org.opensearch.common.transport.TransportAddress in project OpenSearch by opensearch-project.
the class Ec2DiscoveryTests method testPublicIp.
public void testPublicIp() throws InterruptedException {
int nodes = randomInt(10);
for (int i = 0; i < nodes; i++) {
poorMansDNS.put(PREFIX_PUBLIC_IP + (i + 1), buildNewFakeTransportAddress());
}
Settings nodeSettings = Settings.builder().put(AwsEc2Service.HOST_TYPE_SETTING.getKey(), "public_ip").build();
List<TransportAddress> dynamicHosts = buildDynamicHosts(nodeSettings, nodes);
assertThat(dynamicHosts, hasSize(nodes));
// We check that we are using here expected address
int node = 1;
for (TransportAddress address : dynamicHosts) {
TransportAddress expected = poorMansDNS.get(PREFIX_PUBLIC_IP + node++);
assertEquals(address, expected);
}
}
use of org.opensearch.common.transport.TransportAddress in project OpenSearch by opensearch-project.
the class Ec2DiscoveryTests method testFilterByMultipleTags.
public void testFilterByMultipleTags() throws InterruptedException {
int nodes = randomIntBetween(5, 10);
Settings nodeSettings = Settings.builder().putList(AwsEc2Service.TAG_SETTING.getKey() + "stage", "prod", "preprod").build();
int prodInstances = 0;
List<List<Tag>> tagsList = new ArrayList<>();
for (int node = 0; node < nodes; node++) {
List<Tag> tags = new ArrayList<>();
if (randomBoolean()) {
tags.add(new Tag("stage", "prod"));
if (randomBoolean()) {
tags.add(new Tag("stage", "preprod"));
prodInstances++;
}
} else {
tags.add(new Tag("stage", "dev"));
if (randomBoolean()) {
tags.add(new Tag("stage", "preprod"));
}
}
tagsList.add(tags);
}
logger.info("started [{}] instances with [{}] stage=prod tag", nodes, prodInstances);
List<TransportAddress> dynamicHosts = buildDynamicHosts(nodeSettings, nodes, tagsList);
assertThat(dynamicHosts, hasSize(prodInstances));
}
use of org.opensearch.common.transport.TransportAddress in project OpenSearch by opensearch-project.
the class Ec2DiscoveryTests method testPrivateIp.
public void testPrivateIp() throws InterruptedException {
int nodes = randomInt(10);
for (int i = 0; i < nodes; i++) {
poorMansDNS.put(PREFIX_PRIVATE_IP + (i + 1), buildNewFakeTransportAddress());
}
Settings nodeSettings = Settings.builder().put(AwsEc2Service.HOST_TYPE_SETTING.getKey(), "private_ip").build();
List<TransportAddress> transportAddresses = buildDynamicHosts(nodeSettings, nodes);
assertThat(transportAddresses, hasSize(nodes));
// We check that we are using here expected address
int node = 1;
for (TransportAddress address : transportAddresses) {
TransportAddress expected = poorMansDNS.get(PREFIX_PRIVATE_IP + node++);
assertEquals(address, expected);
}
}
use of org.opensearch.common.transport.TransportAddress in project OpenSearch by opensearch-project.
the class Ec2DiscoveryTests method testDefaultSettings.
public void testDefaultSettings() throws InterruptedException {
int nodes = randomInt(10);
Settings nodeSettings = Settings.builder().build();
List<TransportAddress> discoveryNodes = buildDynamicHosts(nodeSettings, nodes);
assertThat(discoveryNodes, hasSize(nodes));
}
Aggregations