Move tests to elasticsearch test framework
Move tests to elasticsearch test framework. In addition to this, we want to refactor some package names to prepare next snapshot/restore feature (see #2). Closes #3.
This commit is contained in:
parent
41de615eb2
commit
316a1411d0
131
pom.xml
131
pom.xml
|
@ -42,16 +42,30 @@ governing permissions and limitations under the License. -->
|
|||
</parent>
|
||||
|
||||
<properties>
|
||||
<elasticsearch.version>0.90.6</elasticsearch.version>
|
||||
<elasticsearch.version>1.0.0.RC1-SNAPSHOT</elasticsearch.version>
|
||||
<lucene.version>4.6.0</lucene.version>
|
||||
<tests.output>onerror</tests.output>
|
||||
<tests.jvms>1</tests.jvms>
|
||||
<tests.shuffle>true</tests.shuffle>
|
||||
<tests.output>onerror</tests.output>
|
||||
<tests.client.ratio></tests.client.ratio>
|
||||
<tests.jvm.argline></tests.jvm.argline>
|
||||
<es.logger.level>INFO</es.logger.level>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.apache.lucene</groupId>
|
||||
<artifactId>lucene-test-framework</artifactId>
|
||||
<version>${lucene.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.elasticsearch</groupId>
|
||||
<artifactId>elasticsearch</artifactId>
|
||||
<version>${elasticsearch.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>log4j</groupId>
|
||||
<artifactId>log4j</artifactId>
|
||||
|
@ -59,12 +73,24 @@ governing permissions and limitations under the License. -->
|
|||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>4.11</version>
|
||||
<groupId>org.elasticsearch</groupId>
|
||||
<artifactId>elasticsearch</artifactId>
|
||||
<version>${elasticsearch.version}</version>
|
||||
<type>test-jar</type>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.hamcrest</groupId>
|
||||
<artifactId>hamcrest-core</artifactId>
|
||||
<version>1.3.RC2</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.hamcrest</groupId>
|
||||
<artifactId>hamcrest-library</artifactId>
|
||||
<version>1.3.RC2</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
@ -91,10 +117,103 @@ governing permissions and limitations under the License. -->
|
|||
<target>1.6</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>com.carrotsearch.randomizedtesting</groupId>
|
||||
<artifactId>junit4-maven-plugin</artifactId>
|
||||
<version>2.0.14</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>tests</id>
|
||||
<phase>test</phase>
|
||||
<goals>
|
||||
<goal>junit4</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<heartbeat>20</heartbeat>
|
||||
<jvmOutputAction>pipe,warn</jvmOutputAction>
|
||||
<leaveTemporary>true</leaveTemporary>
|
||||
<listeners>
|
||||
<report-ant-xml mavenExtensions="true"
|
||||
dir="${project.build.directory}/surefire-reports"/>
|
||||
<report-text
|
||||
showThrowable="true"
|
||||
showStackTraces="true"
|
||||
showOutput="${tests.output}"
|
||||
showStatusOk="false"
|
||||
showStatusError="true"
|
||||
showStatusFailure="true"
|
||||
showStatusIgnored="true"
|
||||
showSuiteSummary="true"
|
||||
timestamps="false"/>
|
||||
<report-execution-times file="${basedir}/.local-execution-hints.log"/>
|
||||
</listeners>
|
||||
<assertions>
|
||||
<enable/>
|
||||
</assertions>
|
||||
<parallelism>${tests.jvms}</parallelism>
|
||||
<balancers>
|
||||
<execution-times>
|
||||
<fileset dir="${basedir}" includes=".local-execution-hints.log"/>
|
||||
</execution-times>
|
||||
</balancers>
|
||||
<includes>
|
||||
<include>**/*Tests.class</include>
|
||||
<include>**/*Test.class</include>
|
||||
</includes>
|
||||
<excludes>
|
||||
<exclude>**/Abstract*.class</exclude>
|
||||
<exclude>**/*StressTest.class</exclude>
|
||||
</excludes>
|
||||
<argLine>
|
||||
${tests.jvm.argline}
|
||||
</argLine>
|
||||
<jvmArgs>
|
||||
<param>-Xmx512m</param>
|
||||
<param>-Xss256k</param>
|
||||
<param>-XX:MaxDirectMemorySize=512m</param>
|
||||
<param>-Des.logger.prefix=</param>
|
||||
</jvmArgs>
|
||||
<shuffleOnSlave>${tests.shuffle}</shuffleOnSlave>
|
||||
<sysouts>${tests.verbose}</sysouts>
|
||||
<seed>${tests.seed}</seed>
|
||||
<haltOnFailure>${tests.failfast}</haltOnFailure>
|
||||
<systemProperties>
|
||||
<!-- RandomizedTesting library system properties -->
|
||||
<tests.jvm.argline>${tests.jvm.argline}</tests.jvm.argline>
|
||||
<tests.iters>${tests.iters}</tests.iters>
|
||||
<tests.maxfailures>${tests.maxfailures}</tests.maxfailures>
|
||||
<tests.failfast>${tests.failfast}</tests.failfast>
|
||||
<tests.class>${tests.class}</tests.class>
|
||||
<tests.method>${tests.method}</tests.method>
|
||||
<tests.nightly>${tests.nightly}</tests.nightly>
|
||||
<tests.badapples>${tests.badapples}</tests.badapples>
|
||||
<tests.weekly>${tests.weekly}</tests.weekly>
|
||||
<tests.slow>${tests.slow}</tests.slow>
|
||||
<tests.azure>${tests.azure}</tests.azure>
|
||||
<tests.awaitsfix>${tests.awaitsfix}</tests.awaitsfix>
|
||||
<tests.slow>${tests.slow}</tests.slow>
|
||||
<tests.timeoutSuite>${tests.timeoutSuite}</tests.timeoutSuite>
|
||||
<tests.showSuccess>${tests.showSuccess}</tests.showSuccess>
|
||||
<tests.integration>${tests.integration}</tests.integration>
|
||||
<tests.cluster_seed>${tests.cluster_seed}</tests.cluster_seed>
|
||||
<tests.client.ratio>${tests.client.ratio}</tests.client.ratio>
|
||||
<es.node.local>${env.ES_TEST_LOCAL}</es.node.local>
|
||||
<es.node.mode>${es.node.mode}</es.node.mode>
|
||||
<es.config>${es.config}</es.config>
|
||||
<es.logger.level>${es.logger.level}</es.logger.level>
|
||||
<java.awt.headless>true</java.awt.headless>
|
||||
</systemProperties>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<version>2.13</version>
|
||||
<configuration>
|
||||
<skip>true</skip>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
|
|
|
@ -21,23 +21,49 @@ package org.elasticsearch.cloud.azure;
|
|||
|
||||
import org.elasticsearch.common.inject.AbstractModule;
|
||||
import org.elasticsearch.common.inject.Inject;
|
||||
import org.elasticsearch.common.logging.ESLogger;
|
||||
import org.elasticsearch.common.logging.Loggers;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.discovery.azure.AzureDiscovery;
|
||||
|
||||
/**
|
||||
* Azure Module
|
||||
*
|
||||
* <ul>
|
||||
* <li>If needed this module will bind azure discovery service by default
|
||||
* to AzureComputeServiceImpl.</li>
|
||||
* </ul>
|
||||
*
|
||||
* @see org.elasticsearch.cloud.azure.AzureComputeServiceImpl
|
||||
*/
|
||||
public class AzureModule extends AbstractModule {
|
||||
protected final ESLogger logger;
|
||||
private Settings settings;
|
||||
|
||||
@Inject
|
||||
public AzureModule(Settings settings) {
|
||||
this.settings = settings;
|
||||
this.logger = Loggers.getLogger(getClass(), settings);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void configure() {
|
||||
logger.debug("starting azure services");
|
||||
|
||||
// If we have set discovery to azure, let's start the azure compute service
|
||||
if (isDiscoveryReady(settings)) {
|
||||
logger.debug("starting azure discovery service");
|
||||
bind(AzureComputeService.class)
|
||||
.to(settings.getAsClass("cloud.azure.api.impl", AzureComputeServiceImpl.class))
|
||||
.asEagerSingleton();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if discovery is meant to start
|
||||
* @return true if we can start discovery features
|
||||
*/
|
||||
public static boolean isDiscoveryReady(Settings settings) {
|
||||
return (AzureDiscovery.AZURE.equalsIgnoreCase(settings.get("discovery.type")));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,15 +23,16 @@ import org.elasticsearch.common.settings.ImmutableSettings;
|
|||
import org.elasticsearch.common.settings.SettingsFilter;
|
||||
|
||||
/**
|
||||
*
|
||||
* Filtering cloud.azure.* settings
|
||||
*/
|
||||
public class AzureSettingsFilter implements SettingsFilter.Filter {
|
||||
|
||||
@Override
|
||||
public void filter(ImmutableSettings.Builder settings) {
|
||||
settings.remove("cloud.private_key");
|
||||
// Cloud settings
|
||||
settings.remove("cloud.certificate");
|
||||
settings.remove("cloud.azure.password");
|
||||
settings.remove("cloud.azure.subscription_id");
|
||||
settings.remove("cloud.azure.service_name");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -41,6 +41,8 @@ import org.elasticsearch.transport.TransportService;
|
|||
*/
|
||||
public class AzureDiscovery extends ZenDiscovery {
|
||||
|
||||
public static final String AZURE = "azure";
|
||||
|
||||
@Inject
|
||||
public AzureDiscovery(Settings settings, ClusterName clusterName, ThreadPool threadPool, TransportService transportService,
|
||||
ClusterService clusterService, NodeSettingsService nodeSettingsService, ZenPingService pingService,
|
||||
|
|
|
@ -19,6 +19,11 @@
|
|||
|
||||
package org.elasticsearch.discovery.azure;
|
||||
|
||||
import org.elasticsearch.cloud.azure.AzureModule;
|
||||
import org.elasticsearch.common.inject.Inject;
|
||||
import org.elasticsearch.common.logging.ESLogger;
|
||||
import org.elasticsearch.common.logging.Loggers;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.discovery.Discovery;
|
||||
import org.elasticsearch.discovery.zen.ZenDiscoveryModule;
|
||||
|
||||
|
@ -27,8 +32,21 @@ import org.elasticsearch.discovery.zen.ZenDiscoveryModule;
|
|||
*/
|
||||
public class AzureDiscoveryModule extends ZenDiscoveryModule {
|
||||
|
||||
protected final ESLogger logger;
|
||||
private Settings settings;
|
||||
|
||||
@Inject
|
||||
public AzureDiscoveryModule(Settings settings) {
|
||||
super();
|
||||
this.logger = Loggers.getLogger(getClass(), settings);
|
||||
this.settings = settings;
|
||||
}
|
||||
@Override
|
||||
protected void bindDiscovery() {
|
||||
if (AzureModule.isDiscoveryReady(settings)) {
|
||||
bind(Discovery.class).to(AzureDiscovery.class).asEagerSingleton();
|
||||
} else {
|
||||
logger.debug("disabling azure discovery features");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,20 +18,40 @@
|
|||
*/
|
||||
package org.elasticsearch.azure.itest;
|
||||
|
||||
import org.elasticsearch.action.admin.cluster.state.ClusterStateResponse;
|
||||
import org.elasticsearch.cloud.azure.AbstractAzureTest;
|
||||
import org.elasticsearch.common.settings.ImmutableSettings;
|
||||
import org.elasticsearch.node.NodeBuilder;
|
||||
import org.junit.Ignore;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.test.ElasticsearchIntegrationTest;
|
||||
import org.hamcrest.Matchers;
|
||||
import org.junit.Test;
|
||||
|
||||
public class AzureSimpleITest {
|
||||
/**
|
||||
* This test needs Azure to run and -Dtests.azure=true to be set
|
||||
* and -Des.config=/path/to/elasticsearch.yml
|
||||
* @see org.elasticsearch.cloud.azure.AbstractAzureTest
|
||||
*/
|
||||
@AbstractAzureTest.AzureTest
|
||||
@ElasticsearchIntegrationTest.ClusterScope(
|
||||
scope = ElasticsearchIntegrationTest.Scope.TEST,
|
||||
numNodes = 1,
|
||||
transportClientRatio = 0.0)
|
||||
public class AzureSimpleITest extends AbstractAzureTest {
|
||||
|
||||
@Test @Ignore
|
||||
@Test
|
||||
public void one_node_should_run() {
|
||||
ImmutableSettings.Builder builder = ImmutableSettings.settingsBuilder()
|
||||
//.put("gateway.type", "local")
|
||||
.put("path.data", "./target/es/data")
|
||||
.put("path.logs", "./target/es/logs")
|
||||
.put("path.work", "./target/es/work");
|
||||
NodeBuilder.nodeBuilder().settings(builder).node();
|
||||
// Do nothing... Just start :-)
|
||||
// but let's check that we have at least 1 node (local node)
|
||||
ClusterStateResponse clusterState = client().admin().cluster().prepareState().execute().actionGet();
|
||||
|
||||
assertThat(clusterState.getState().getNodes().getSize(), Matchers.greaterThanOrEqualTo(1));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Settings indexSettings() {
|
||||
// During restore we frequently restore index to exactly the same state it was before, that might cause the same
|
||||
// checksum file to be written twice during restore operation
|
||||
return ImmutableSettings.builder().put(super.indexSettings())
|
||||
.build();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,144 +0,0 @@
|
|||
/*
|
||||
* 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.azure.test;
|
||||
|
||||
import org.elasticsearch.action.admin.cluster.node.info.NodesInfoResponse;
|
||||
import org.elasticsearch.client.Client;
|
||||
import org.elasticsearch.client.transport.NoNodeAvailableException;
|
||||
import org.elasticsearch.client.transport.TransportClient;
|
||||
import org.elasticsearch.cloud.azure.AzureComputeService;
|
||||
import org.elasticsearch.common.io.FileSystemUtils;
|
||||
import org.elasticsearch.common.logging.ESLogger;
|
||||
import org.elasticsearch.common.logging.ESLoggerFactory;
|
||||
import org.elasticsearch.common.settings.ImmutableSettings;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.transport.TransportAddress;
|
||||
import org.elasticsearch.node.Node;
|
||||
import org.elasticsearch.node.NodeBuilder;
|
||||
import org.elasticsearch.node.internal.InternalNode;
|
||||
import org.elasticsearch.transport.netty.NettyTransport;
|
||||
import org.junit.After;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public abstract class AzureAbstractTest {
|
||||
|
||||
protected static ESLogger logger = ESLoggerFactory.getLogger(AzureAbstractTest.class.getName());
|
||||
private static List<Node> nodes;
|
||||
private Class<? extends AzureComputeService> mock;
|
||||
|
||||
public AzureAbstractTest(Class<? extends AzureComputeService> mock) {
|
||||
// We want to inject the Azure API Mock
|
||||
this.mock = mock;
|
||||
}
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
nodes = new ArrayList<Node>();
|
||||
|
||||
File dataDir = new File("./target/es/data");
|
||||
if(dataDir.exists()) {
|
||||
FileSystemUtils.deleteRecursively(dataDir, true);
|
||||
}
|
||||
}
|
||||
|
||||
@After
|
||||
public void tearDown() {
|
||||
// Cleaning nodes after test
|
||||
for (Node node : nodes) {
|
||||
node.close();
|
||||
}
|
||||
}
|
||||
|
||||
protected Client getTransportClient() {
|
||||
// Create a TransportClient on node 1 and 2
|
||||
Settings settings = ImmutableSettings.settingsBuilder()
|
||||
.put("cluster.name", "azure")
|
||||
.put("transport.tcp.connect_timeout", "1s")
|
||||
.build();
|
||||
|
||||
TransportClient client = new TransportClient(settings);
|
||||
|
||||
for (Node node : nodes) {
|
||||
NettyTransport nettyTransport = ((InternalNode) node).injector().getInstance(NettyTransport.class);
|
||||
TransportAddress transportAddress = nettyTransport.boundAddress().publishAddress();
|
||||
client.addTransportAddress(transportAddress);
|
||||
}
|
||||
|
||||
return client;
|
||||
}
|
||||
|
||||
protected Client getNodeClient() {
|
||||
for (Node node : nodes) {
|
||||
return node.client();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
protected void checkNumberOfNodes(int expected, boolean fail) {
|
||||
NodesInfoResponse nodeInfos = null;
|
||||
|
||||
try {
|
||||
nodeInfos = getTransportClient().admin().cluster().prepareNodesInfo().execute().actionGet();
|
||||
} catch (NoNodeAvailableException e) {
|
||||
// If we can't build a Transport Client, we are may be not connected to any network
|
||||
// Let's try a Node Client
|
||||
nodeInfos = getNodeClient().admin().cluster().prepareNodesInfo().execute().actionGet();
|
||||
}
|
||||
|
||||
Assert.assertNotNull(nodeInfos);
|
||||
Assert.assertNotNull(nodeInfos.getNodes());
|
||||
|
||||
if (fail) {
|
||||
Assert.assertEquals(expected, nodeInfos.getNodes().length);
|
||||
} else {
|
||||
if (nodeInfos.getNodes().length != expected) {
|
||||
logger.warn("expected {} node(s) but found {}. Could be due to no local IP address available.",
|
||||
expected, nodeInfos.getNodes().length);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void checkNumberOfNodes(int expected) {
|
||||
checkNumberOfNodes(expected, true);
|
||||
}
|
||||
|
||||
protected void nodeBuilder() {
|
||||
ImmutableSettings.Builder builder = ImmutableSettings.settingsBuilder()
|
||||
//.put("gateway.type", "local")
|
||||
.put("path.data", "./target/es/data")
|
||||
.put("path.logs", "./target/es/logs")
|
||||
.put("path.work", "./target/es/work")
|
||||
// .put("discovery.zen.ping.timeout", "500ms")
|
||||
// .put("discovery.zen.fd.ping_retries",1)
|
||||
// .put("discovery.zen.fd.ping_timeout", "500ms")
|
||||
// .put("discovery.initial_state_timeout", "5s")
|
||||
// .put("transport.tcp.connect_timeout", "1s")
|
||||
.put("cloud.azure.api.impl", mock)
|
||||
.put("cloud.azure.refresh_interval", "5s")
|
||||
.put("node.name", (nodes.size()+1) + "#" + mock.getSimpleName());
|
||||
Node node = NodeBuilder.nodeBuilder().settings(builder).node();
|
||||
nodes.add(node);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,64 @@
|
|||
/*
|
||||
* Licensed to Elasticsearch (the "Author") under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. Author 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.cloud.azure;
|
||||
|
||||
import com.carrotsearch.randomizedtesting.annotations.TestGroup;
|
||||
import org.elasticsearch.test.ElasticsearchIntegrationTest;
|
||||
|
||||
import java.lang.annotation.Documented;
|
||||
import java.lang.annotation.Inherited;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public abstract class AbstractAzureTest extends ElasticsearchIntegrationTest {
|
||||
|
||||
/**
|
||||
* Annotation for tests that require Azure to run. Azure tests are disabled by default.
|
||||
* <p/>
|
||||
* To enable test add -Dtests.azure=true -Des.config=/path/to/elasticsearch.yml
|
||||
* <p/>
|
||||
* The elasticsearch.yml file should contain the following keys
|
||||
* <pre>
|
||||
cloud:
|
||||
azure:
|
||||
keystore: FULLPATH-TO-YOUR-KEYSTORE
|
||||
password: YOUR-PASSWORD
|
||||
subscription_id: YOUR-AZURE-SUBSCRIPTION-ID
|
||||
service_name: YOUR-AZURE-SERVICE-NAME
|
||||
|
||||
discovery:
|
||||
type: azure
|
||||
* </pre>
|
||||
*/
|
||||
@Documented
|
||||
@Inherited
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@TestGroup(enabled = false, sysProperty = SYSPROP_AZURE)
|
||||
public @interface AzureTest {
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
public static final String SYSPROP_AZURE = "tests.azure";
|
||||
|
||||
}
|
|
@ -0,0 +1,53 @@
|
|||
/*
|
||||
* 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.discovery.azure;
|
||||
|
||||
import org.elasticsearch.action.admin.cluster.node.info.NodesInfoResponse;
|
||||
import org.elasticsearch.cloud.azure.AbstractAzureTest;
|
||||
import org.elasticsearch.cloud.azure.AzureComputeService;
|
||||
import org.elasticsearch.common.settings.ImmutableSettings;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
|
||||
public abstract class AbstractAzureComputeServiceTest extends AbstractAzureTest {
|
||||
|
||||
private Class<? extends AzureComputeService> mock;
|
||||
|
||||
public AbstractAzureComputeServiceTest(Class<? extends AzureComputeService> mock) {
|
||||
// We want to inject the Azure API Mock
|
||||
this.mock = mock;
|
||||
}
|
||||
|
||||
protected void checkNumberOfNodes(int expected) {
|
||||
NodesInfoResponse nodeInfos = client().admin().cluster().prepareNodesInfo().execute().actionGet();
|
||||
assertNotNull(nodeInfos);
|
||||
assertNotNull(nodeInfos.getNodes());
|
||||
assertEquals(expected, nodeInfos.getNodes().length);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Settings nodeSettings(int nodeOrdinal) {
|
||||
ImmutableSettings.Builder builder = ImmutableSettings.settingsBuilder()
|
||||
.put("cloud.azure.api.impl", mock)
|
||||
// We add a fake subscription_id to start mock compute service
|
||||
.put("cloud.azure.subscription_id", "fake")
|
||||
.put("cloud.azure.refresh_interval", "5s");
|
||||
|
||||
return builder.build();
|
||||
}
|
||||
}
|
|
@ -17,7 +17,7 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
package org.elasticsearch.azure.test;
|
||||
package org.elasticsearch.discovery.azure;
|
||||
|
||||
import org.elasticsearch.ElasticSearchException;
|
||||
import org.elasticsearch.cloud.azure.AzureComputeService;
|
||||
|
@ -32,6 +32,7 @@ public abstract class AzureComputeServiceAbstractMock extends AbstractLifecycleC
|
|||
|
||||
protected AzureComputeServiceAbstractMock(Settings settings) {
|
||||
super(settings);
|
||||
logger.debug("starting Azure Mock [{}]", this.getClass().getSimpleName());
|
||||
}
|
||||
|
||||
@Override
|
|
@ -17,7 +17,7 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
package org.elasticsearch.azure.test;
|
||||
package org.elasticsearch.discovery.azure;
|
||||
|
||||
import org.elasticsearch.cloud.azure.Instance;
|
||||
import org.elasticsearch.common.inject.Inject;
|
||||
|
@ -34,7 +34,6 @@ public class AzureComputeServiceSimpleMock extends AzureComputeServiceAbstractMo
|
|||
@Inject
|
||||
protected AzureComputeServiceSimpleMock(Settings settings) {
|
||||
super(settings);
|
||||
logger.debug("starting Azure Mock");
|
||||
}
|
||||
|
||||
@Override
|
|
@ -17,7 +17,7 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
package org.elasticsearch.azure.test;
|
||||
package org.elasticsearch.discovery.azure;
|
||||
|
||||
import org.elasticsearch.cloud.azure.Instance;
|
||||
import org.elasticsearch.common.inject.Inject;
|
||||
|
@ -34,7 +34,6 @@ public class AzureComputeServiceTwoNodesMock extends AzureComputeServiceAbstract
|
|||
@Inject
|
||||
protected AzureComputeServiceTwoNodesMock(Settings settings) {
|
||||
super(settings);
|
||||
logger.debug("starting Azure Mock");
|
||||
}
|
||||
|
||||
@Override
|
|
@ -17,7 +17,7 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
package org.elasticsearch.azure.test;
|
||||
package org.elasticsearch.discovery.azure;
|
||||
|
||||
import org.elasticsearch.cloud.azure.AzureComputeServiceImpl;
|
||||
import org.elasticsearch.cloud.azure.Instance;
|
|
@ -16,11 +16,16 @@
|
|||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.elasticsearch.azure.test;
|
||||
package org.elasticsearch.discovery.azure;
|
||||
|
||||
import org.elasticsearch.test.ElasticsearchIntegrationTest;
|
||||
import org.junit.Test;
|
||||
|
||||
public class AzureSimpleTest extends AzureAbstractTest {
|
||||
@ElasticsearchIntegrationTest.ClusterScope(
|
||||
scope = ElasticsearchIntegrationTest.Scope.TEST,
|
||||
numNodes = 1,
|
||||
transportClientRatio = 0.0)
|
||||
public class AzureSimpleTest extends AbstractAzureComputeServiceTest {
|
||||
|
||||
public AzureSimpleTest() {
|
||||
super(AzureComputeServiceSimpleMock.class);
|
||||
|
@ -28,10 +33,9 @@ public class AzureSimpleTest extends AzureAbstractTest {
|
|||
|
||||
@Test
|
||||
public void one_node_should_run() {
|
||||
// Then we start our node for tests
|
||||
nodeBuilder();
|
||||
|
||||
// We expect having 2 nodes as part of the cluster, let's test that
|
||||
checkNumberOfNodes(1);
|
||||
|
||||
|
||||
}
|
||||
}
|
|
@ -16,11 +16,16 @@
|
|||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.elasticsearch.azure.test;
|
||||
package org.elasticsearch.discovery.azure;
|
||||
|
||||
import org.elasticsearch.test.ElasticsearchIntegrationTest;
|
||||
import org.junit.Test;
|
||||
|
||||
public class AzureTwoStartedNodesTest extends AzureAbstractTest {
|
||||
@ElasticsearchIntegrationTest.ClusterScope(
|
||||
scope = ElasticsearchIntegrationTest.Scope.TEST,
|
||||
numNodes = 2,
|
||||
transportClientRatio = 0.0)
|
||||
public class AzureTwoStartedNodesTest extends AbstractAzureComputeServiceTest {
|
||||
|
||||
public AzureTwoStartedNodesTest() {
|
||||
super(AzureComputeServiceTwoNodesMock.class);
|
||||
|
@ -28,11 +33,7 @@ public class AzureTwoStartedNodesTest extends AzureAbstractTest {
|
|||
|
||||
@Test
|
||||
public void two_nodes_should_run() {
|
||||
// Then we start our node for tests
|
||||
nodeBuilder();
|
||||
nodeBuilder();
|
||||
|
||||
// We expect having 2 nodes as part of the cluster, let's test that
|
||||
checkNumberOfNodes(2, false);
|
||||
checkNumberOfNodes(2);
|
||||
}
|
||||
}
|
|
@ -8,9 +8,7 @@
|
|||
# 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.
|
||||
|
||||
cluster.name: azure
|
||||
|
||||
#
|
||||
# Azure discovery allows to use Azure API in order to perform discovery.
|
||||
#
|
||||
# You have to install the cloud-azure plugin for enabling the Azure discovery.
|
||||
|
@ -18,13 +16,15 @@
|
|||
# See <http://elasticsearch.org/guide/reference/modules/discovery/azure.html>
|
||||
# for more information.
|
||||
#
|
||||
# See <http://elasticsearch.org/tutorials/2013/04/02/elasticsearch-on-azure.html>
|
||||
# See <https://github.com/elasticsearch/elasticsearch-cloud-azure/>
|
||||
# for a step-by-step tutorial.
|
||||
cloud:
|
||||
azure:
|
||||
keystore: FULLPATH-TO-YOUR-KEYSTORE
|
||||
password: YOUR-PASSWORD
|
||||
subscription_id: YOUR-AZURE-SUBSCRIPTION-ID
|
||||
service_name: YOUR-AZURE-SERVICE-NAME
|
||||
discovery:
|
||||
type: azure
|
||||
#
|
||||
# cloud:
|
||||
# azure:
|
||||
# keystore: FULLPATH-TO-YOUR-KEYSTORE
|
||||
# password: YOUR-PASSWORD
|
||||
# subscription_id: YOUR-AZURE-SUBSCRIPTION-ID
|
||||
# service_name: YOUR-AZURE-SERVICE-NAME
|
||||
#
|
||||
# discovery:
|
||||
# type: azure
|
||||
|
|
Loading…
Reference in New Issue