Skip to content

Commit

Permalink
Update to elasticsearch 1.3.0
Browse files Browse the repository at this point in the history
And refactor integration tests

Closes #17.

(cherry picked from commit f5b444e)
(cherry picked from commit 1e63f86)
  • Loading branch information
dadoonet committed Jun 19, 2014
1 parent d020012 commit 943f255
Show file tree
Hide file tree
Showing 11 changed files with 175 additions and 69 deletions.
59 changes: 30 additions & 29 deletions README.md
Expand Up @@ -3,9 +3,10 @@ Azure Cloud Plugin for Elasticsearch

The Azure Cloud plugin allows to use Azure API for the unicast discovery mechanism.

In order to install the plugin, simply run: `bin/plugin -install elasticsearch/elasticsearch-cloud-azure/2.1.0`.
In order to install the plugin, simply run: `bin/plugin -install elasticsearch/elasticsearch-cloud-azure/2.3.0`.

* For master elasticsearch versions, look at [master branch](https://github.com/elasticsearch/elasticsearch-cloud-azure/tree/master).
* For 1.3.x elasticsearch versions, look at [es-1.3 branch](https://github.com/elasticsearch/elasticsearch-cloud-azure/tree/es-1.3).
* For 1.2.x elasticsearch versions, look at [es-1.2 branch](https://github.com/elasticsearch/elasticsearch-cloud-azure/tree/es-1.2).
* For 1.1.x elasticsearch versions, look at [es-1.1 branch](https://github.com/elasticsearch/elasticsearch-cloud-azure/tree/es-1.1).
* For 1.0.x elasticsearch versions, look at [es-1.0 branch](https://github.com/elasticsearch/elasticsearch-cloud-azure/tree/es-1.0).
Expand All @@ -27,17 +28,17 @@ Azure VM discovery allows to use the azure APIs to perform automatic discovery (
multicast environments). Here is a simple sample configuration:

```
cloud:
azure:
keystore: /path/to/keystore
password: your_password_for_keystore
subscription_id: your_azure_subscription_id
service_name: your_azure_cloud_service_name
discovery:
type: azure
# recommended
# path.data: /mnt/resource/elasticsearch/data
cloud:
azure:
keystore: /path/to/keystore
password: your_password_for_keystore
subscription_id: your_azure_subscription_id
service_name: your_azure_cloud_service_name
discovery:
type: azure
# recommended
# path.data: /mnt/resource/elasticsearch/data
```

How to start (short story)
Expand Down Expand Up @@ -261,17 +262,17 @@ And add the following lines:

```yaml
# If you don't remember your account id, you may get it with `azure account list`
cloud:
azure:
keystore: /home/elasticsearch/azurekeystore.pkcs12
password: your_password_for_keystore
subscription_id: your_azure_subscription_id
service_name: your_azure_cloud_service_name
discovery:
type: azure
cloud:
azure:
keystore: /home/elasticsearch/azurekeystore.pkcs12
password: your_password_for_keystore
subscription_id: your_azure_subscription_id
service_name: your_azure_cloud_service_name
discovery:
type: azure

# Recommended
path.data: /mnt/resource/elasticsearch/data
path.data: /mnt/resource/elasticsearch/data
```

Restart elasticsearch:
Expand Down Expand Up @@ -347,10 +348,10 @@ Azure Repository
To enable Azure repositories, you have first to set your azure storage settings:

```
cloud:
azure:
storage_account: your_azure_storage_account
storage_key: your_azure_storage_key
cloud:
azure:
storage_account: your_azure_storage_account
storage_key: your_azure_storage_key
```

The Azure repository supports following settings:
Expand Down Expand Up @@ -402,10 +403,10 @@ Integrations tests in this plugin require working Azure configuration and theref
To enable tests prepare a config file elasticsearch.yml with the following content:

```
cloud:
azure:
account: "YOUR-AZURE-STORAGE-NAME"
key: "YOUR-AZURE-STORAGE-KEY"
cloud:
azure:
account: "YOUR-AZURE-STORAGE-NAME"
key: "YOUR-AZURE-STORAGE-KEY"
```

Replaces `account`, `key` with your settings. Please, note that the test will delete all snapshot/restore related files in the specified bucket.
Expand Down
31 changes: 14 additions & 17 deletions pom.xml
Expand Up @@ -44,9 +44,8 @@ governing permissions and limitations under the License. -->

<properties>
<elasticsearch.version>2.0.0-SNAPSHOT</elasticsearch.version>
<lucene.version>4.8.0</lucene.version>
<lucene.version>4.8.1</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>
Expand All @@ -56,6 +55,18 @@ governing permissions and limitations under the License. -->
</properties>

<dependencies>
<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>
<dependency>
<groupId>org.apache.lucene</groupId>
<artifactId>lucene-test-framework</artifactId>
Expand Down Expand Up @@ -86,18 +97,6 @@ governing permissions and limitations under the License. -->
<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>
Expand Down Expand Up @@ -157,7 +156,7 @@ governing permissions and limitations under the License. -->
<assertions>
<enable/>
</assertions>
<parallelism>${tests.jvms}</parallelism>
<parallelism>1</parallelism>
<balancers>
<execution-times>
<fileset dir="${basedir}" includes=".local-execution-hints.log"/>
Expand Down Expand Up @@ -204,8 +203,6 @@ governing permissions and limitations under the License. -->
<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>
Expand Down
Expand Up @@ -32,7 +32,6 @@
import org.elasticsearch.common.transport.TransportAddress;
import org.elasticsearch.common.unit.TimeValue;
import org.elasticsearch.discovery.zen.ping.unicast.UnicastHostsProvider;
import org.elasticsearch.discovery.zen.ping.unicast.UnicastZenPing;
import org.elasticsearch.transport.TransportService;

import java.io.IOException;
Expand Down Expand Up @@ -139,10 +138,8 @@ public List<DiscoveryNode> buildDynamicNodes() {
} else {
TransportAddress[] addresses = transportService.addressesFromString(networkAddress);
// we only limit to 1 addresses, makes no sense to ping 100 ports
for (int i = 0; (i < addresses.length && i < UnicastZenPing.LIMIT_PORTS_COUNT); i++) {
logger.trace("adding {}, transport_address {}", networkAddress, addresses[i]);
cachedDiscoNodes.add(new DiscoveryNode("#cloud-" + instance.getName() + "-" + i, addresses[i], Version.CURRENT));
}
logger.trace("adding {}, transport_address {}", networkAddress, addresses[0]);
cachedDiscoNodes.add(new DiscoveryNode("#cloud-" + instance.getName(), addresses[0], Version.CURRENT));
}

}
Expand Down
Expand Up @@ -36,6 +36,7 @@
@ElasticsearchIntegrationTest.ClusterScope(
scope = ElasticsearchIntegrationTest.Scope.TEST,
numDataNodes = 1,
numClientNodes = 0,
transportClientRatio = 0.0)
public class AzureSimpleITest extends AbstractAzureTest {

Expand Down
Expand Up @@ -24,6 +24,7 @@
import org.elasticsearch.cloud.azure.AzureComputeService;
import org.elasticsearch.common.settings.ImmutableSettings;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.plugins.PluginsService;

public abstract class AbstractAzureComputeServiceTest extends AbstractAzureTest {

Expand All @@ -41,13 +42,22 @@ protected void checkNumberOfNodes(int expected) {
assertEquals(expected, nodeInfos.getNodes().length);
}

@Override
protected Settings nodeSettings(int nodeOrdinal) {
protected Settings settingsBuilder() {
ImmutableSettings.Builder builder = ImmutableSettings.settingsBuilder()
.put("plugins." + PluginsService.LOAD_PLUGIN_FROM_CLASSPATH, true)
.put("discovery.type", "azure")
.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");
.put("cloud.azure.refresh_interval", "5s")
.put("cloud.azure.keystore", "dummy")
.put("cloud.azure.password", "dummy")
.put("cloud.azure.service_name", "dummy")
.put("cloud.azure.refresh_interval", "5s")
// Make the tests run faster
.put("discovery.zen.join.timeout", "100ms")
.put("discovery.zen.ping.timeout", "10ms")
.put("discovery.initial_state_timeout", "300ms");

return builder.build();
}
Expand Down
@@ -0,0 +1,83 @@
/*
* 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.common.settings.ImmutableSettings;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.discovery.MasterNotDiscoveredException;
import org.elasticsearch.test.ElasticsearchIntegrationTest;
import org.junit.Test;

import java.io.IOException;

import static org.hamcrest.Matchers.notNullValue;
import static org.hamcrest.Matchers.nullValue;

/**
* Reported issue in #15
* (https://github.com/elasticsearch/elasticsearch-cloud-azure/issues/15)
*/
@ElasticsearchIntegrationTest.ClusterScope(scope = ElasticsearchIntegrationTest.Scope.TEST,
numDataNodes = 0,
transportClientRatio = 0.0,
numClientNodes = 0)
public class AzureMinimumMasterNodesTest extends AbstractAzureComputeServiceTest {

public AzureMinimumMasterNodesTest() {
super(AzureComputeServiceTwoNodesMock.class);
}

@Override
protected final Settings settingsBuilder() {
ImmutableSettings.Builder builder = ImmutableSettings.settingsBuilder()
.put("discovery.zen.minimum_master_nodes", 2)
.put(super.settingsBuilder());
return builder.build();
}

@Test
public void simpleOnlyMasterNodeElection() throws IOException {
logger.info("--> start data node / non master node");
internalCluster().startNode(settingsBuilder());
try {
assertThat(client().admin().cluster().prepareState().setMasterNodeTimeout("100ms").execute().actionGet().getState().nodes().masterNodeId(), nullValue());
fail("should not be able to find master");
} catch (MasterNotDiscoveredException e) {
// all is well, no master elected
}
logger.info("--> start another node");
internalCluster().startNode(settingsBuilder());
assertThat(client().admin().cluster().prepareState().setMasterNodeTimeout("1s").execute().actionGet().getState().nodes().masterNodeId(), notNullValue());

logger.info("--> stop master node");
internalCluster().stopCurrentMasterNode();

try {
assertThat(client().admin().cluster().prepareState().setMasterNodeTimeout("1s").execute().actionGet().getState().nodes().masterNodeId(), nullValue());
fail("should not be able to find master");
} catch (MasterNotDiscoveredException e) {
// all is well, no master elected
}

logger.info("--> start another node");
internalCluster().startNode(settingsBuilder());
assertThat(client().admin().cluster().prepareState().setMasterNodeTimeout("1s").execute().actionGet().getState().nodes().masterNodeId(), notNullValue());
}
}
Expand Up @@ -22,10 +22,12 @@
import org.elasticsearch.test.ElasticsearchIntegrationTest;
import org.junit.Test;

@ElasticsearchIntegrationTest.ClusterScope(
scope = ElasticsearchIntegrationTest.Scope.TEST,
numDataNodes = 1,
transportClientRatio = 0.0)
import static org.hamcrest.Matchers.notNullValue;

@ElasticsearchIntegrationTest.ClusterScope(scope = ElasticsearchIntegrationTest.Scope.TEST,
numDataNodes = 0,
transportClientRatio = 0.0,
numClientNodes = 0)
public class AzureSimpleTest extends AbstractAzureComputeServiceTest {

public AzureSimpleTest() {
Expand All @@ -34,9 +36,11 @@ public AzureSimpleTest() {

@Test
public void one_node_should_run() {
// We expect having 2 nodes as part of the cluster, let's test that
checkNumberOfNodes(1);

logger.info("--> start one node");
internalCluster().startNode(settingsBuilder());
assertThat(client().admin().cluster().prepareState().setMasterNodeTimeout("1s").execute().actionGet().getState().nodes().masterNodeId(), notNullValue());

// We expect having 1 node as part of the cluster, let's test that
checkNumberOfNodes(1);
}
}
Expand Up @@ -22,10 +22,12 @@
import org.elasticsearch.test.ElasticsearchIntegrationTest;
import org.junit.Test;

@ElasticsearchIntegrationTest.ClusterScope(
scope = ElasticsearchIntegrationTest.Scope.TEST,
numDataNodes = 2,
transportClientRatio = 0.0)
import static org.hamcrest.Matchers.notNullValue;

@ElasticsearchIntegrationTest.ClusterScope(scope = ElasticsearchIntegrationTest.Scope.TEST,
numDataNodes = 0,
transportClientRatio = 0.0,
numClientNodes = 0)
public class AzureTwoStartedNodesTest extends AbstractAzureComputeServiceTest {

public AzureTwoStartedNodesTest() {
Expand All @@ -34,6 +36,14 @@ public AzureTwoStartedNodesTest() {

@Test
public void two_nodes_should_run() {
logger.info("--> start first node");
internalCluster().startNode(settingsBuilder());
assertThat(client().admin().cluster().prepareState().setMasterNodeTimeout("1s").execute().actionGet().getState().nodes().masterNodeId(), notNullValue());

logger.info("--> start another node");
internalCluster().startNode(settingsBuilder());
assertThat(client().admin().cluster().prepareState().setMasterNodeTimeout("1s").execute().actionGet().getState().nodes().masterNodeId(), notNullValue());

// We expect having 2 nodes as part of the cluster, let's test that
checkNumberOfNodes(2);
}
Expand Down

0 comments on commit 943f255

Please sign in to comment.