Skip to content

Commit 943f255

Browse files
committed
Update to elasticsearch 1.3.0
And refactor integration tests Closes #17. (cherry picked from commit f5b444e) (cherry picked from commit 1e63f86)
1 parent d020012 commit 943f255

11 files changed

+175
-69
lines changed

README.md

+30-29
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@ Azure Cloud Plugin for Elasticsearch
33

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

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

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

2930
```
30-
cloud:
31-
azure:
32-
keystore: /path/to/keystore
33-
password: your_password_for_keystore
34-
subscription_id: your_azure_subscription_id
35-
service_name: your_azure_cloud_service_name
36-
discovery:
37-
type: azure
38-
39-
# recommended
40-
# path.data: /mnt/resource/elasticsearch/data
31+
cloud:
32+
azure:
33+
keystore: /path/to/keystore
34+
password: your_password_for_keystore
35+
subscription_id: your_azure_subscription_id
36+
service_name: your_azure_cloud_service_name
37+
discovery:
38+
type: azure
39+
40+
# recommended
41+
# path.data: /mnt/resource/elasticsearch/data
4142
```
4243

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

262263
```yaml
263264
# If you don't remember your account id, you may get it with `azure account list`
264-
cloud:
265-
azure:
266-
keystore: /home/elasticsearch/azurekeystore.pkcs12
267-
password: your_password_for_keystore
268-
subscription_id: your_azure_subscription_id
269-
service_name: your_azure_cloud_service_name
270-
discovery:
271-
type: azure
265+
cloud:
266+
azure:
267+
keystore: /home/elasticsearch/azurekeystore.pkcs12
268+
password: your_password_for_keystore
269+
subscription_id: your_azure_subscription_id
270+
service_name: your_azure_cloud_service_name
271+
discovery:
272+
type: azure
272273

273274
# Recommended
274-
path.data: /mnt/resource/elasticsearch/data
275+
path.data: /mnt/resource/elasticsearch/data
275276
```
276277
277278
Restart elasticsearch:
@@ -347,10 +348,10 @@ Azure Repository
347348
To enable Azure repositories, you have first to set your azure storage settings:
348349
349350
```
350-
cloud:
351-
azure:
352-
storage_account: your_azure_storage_account
353-
storage_key: your_azure_storage_key
351+
cloud:
352+
azure:
353+
storage_account: your_azure_storage_account
354+
storage_key: your_azure_storage_key
354355
```
355356
356357
The Azure repository supports following settings:
@@ -402,10 +403,10 @@ Integrations tests in this plugin require working Azure configuration and theref
402403
To enable tests prepare a config file elasticsearch.yml with the following content:
403404

404405
```
405-
cloud:
406-
azure:
407-
account: "YOUR-AZURE-STORAGE-NAME"
408-
key: "YOUR-AZURE-STORAGE-KEY"
406+
cloud:
407+
azure:
408+
account: "YOUR-AZURE-STORAGE-NAME"
409+
key: "YOUR-AZURE-STORAGE-KEY"
409410
```
410411

411412
Replaces `account`, `key` with your settings. Please, note that the test will delete all snapshot/restore related files in the specified bucket.

pom.xml

+14-17
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,8 @@ governing permissions and limitations under the License. -->
4444

4545
<properties>
4646
<elasticsearch.version>2.0.0-SNAPSHOT</elasticsearch.version>
47-
<lucene.version>4.8.0</lucene.version>
47+
<lucene.version>4.8.1</lucene.version>
4848
<tests.output>onerror</tests.output>
49-
<tests.jvms>1</tests.jvms>
5049
<tests.shuffle>true</tests.shuffle>
5150
<tests.output>onerror</tests.output>
5251
<tests.client.ratio></tests.client.ratio>
@@ -56,6 +55,18 @@ governing permissions and limitations under the License. -->
5655
</properties>
5756

5857
<dependencies>
58+
<dependency>
59+
<groupId>org.hamcrest</groupId>
60+
<artifactId>hamcrest-core</artifactId>
61+
<version>1.3.RC2</version>
62+
<scope>test</scope>
63+
</dependency>
64+
<dependency>
65+
<groupId>org.hamcrest</groupId>
66+
<artifactId>hamcrest-library</artifactId>
67+
<version>1.3.RC2</version>
68+
<scope>test</scope>
69+
</dependency>
5970
<dependency>
6071
<groupId>org.apache.lucene</groupId>
6172
<artifactId>lucene-test-framework</artifactId>
@@ -86,18 +97,6 @@ governing permissions and limitations under the License. -->
8697
<type>test-jar</type>
8798
<scope>test</scope>
8899
</dependency>
89-
<dependency>
90-
<groupId>org.hamcrest</groupId>
91-
<artifactId>hamcrest-core</artifactId>
92-
<version>1.3.RC2</version>
93-
<scope>test</scope>
94-
</dependency>
95-
<dependency>
96-
<groupId>org.hamcrest</groupId>
97-
<artifactId>hamcrest-library</artifactId>
98-
<version>1.3.RC2</version>
99-
<scope>test</scope>
100-
</dependency>
101100
</dependencies>
102101

103102
<build>
@@ -157,7 +156,7 @@ governing permissions and limitations under the License. -->
157156
<assertions>
158157
<enable/>
159158
</assertions>
160-
<parallelism>${tests.jvms}</parallelism>
159+
<parallelism>1</parallelism>
161160
<balancers>
162161
<execution-times>
163162
<fileset dir="${basedir}" includes=".local-execution-hints.log"/>
@@ -204,8 +203,6 @@ governing permissions and limitations under the License. -->
204203
<tests.integration>${tests.integration}</tests.integration>
205204
<tests.cluster_seed>${tests.cluster_seed}</tests.cluster_seed>
206205
<tests.client.ratio>${tests.client.ratio}</tests.client.ratio>
207-
<es.node.local>${env.ES_TEST_LOCAL}</es.node.local>
208-
<es.node.mode>${es.node.mode}</es.node.mode>
209206
<es.config>${es.config}</es.config>
210207
<es.logger.level>${es.logger.level}</es.logger.level>
211208
<java.awt.headless>true</java.awt.headless>

src/main/java/org/elasticsearch/discovery/azure/AzureUnicastHostsProvider.java

+2-5
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
import org.elasticsearch.common.transport.TransportAddress;
3333
import org.elasticsearch.common.unit.TimeValue;
3434
import org.elasticsearch.discovery.zen.ping.unicast.UnicastHostsProvider;
35-
import org.elasticsearch.discovery.zen.ping.unicast.UnicastZenPing;
3635
import org.elasticsearch.transport.TransportService;
3736

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

148145
}

src/test/java/org/elasticsearch/azure/itest/AzureSimpleITest.java

+1
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
@ElasticsearchIntegrationTest.ClusterScope(
3737
scope = ElasticsearchIntegrationTest.Scope.TEST,
3838
numDataNodes = 1,
39+
numClientNodes = 0,
3940
transportClientRatio = 0.0)
4041
public class AzureSimpleITest extends AbstractAzureTest {
4142

src/test/java/org/elasticsearch/discovery/azure/AbstractAzureComputeServiceTest.java

+13-3
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import org.elasticsearch.cloud.azure.AzureComputeService;
2525
import org.elasticsearch.common.settings.ImmutableSettings;
2626
import org.elasticsearch.common.settings.Settings;
27+
import org.elasticsearch.plugins.PluginsService;
2728

2829
public abstract class AbstractAzureComputeServiceTest extends AbstractAzureTest {
2930

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

44-
@Override
45-
protected Settings nodeSettings(int nodeOrdinal) {
45+
protected Settings settingsBuilder() {
4646
ImmutableSettings.Builder builder = ImmutableSettings.settingsBuilder()
47+
.put("plugins." + PluginsService.LOAD_PLUGIN_FROM_CLASSPATH, true)
48+
.put("discovery.type", "azure")
4749
.put("cloud.azure.api.impl", mock)
4850
// We add a fake subscription_id to start mock compute service
4951
.put("cloud.azure.subscription_id", "fake")
50-
.put("cloud.azure.refresh_interval", "5s");
52+
.put("cloud.azure.refresh_interval", "5s")
53+
.put("cloud.azure.keystore", "dummy")
54+
.put("cloud.azure.password", "dummy")
55+
.put("cloud.azure.service_name", "dummy")
56+
.put("cloud.azure.refresh_interval", "5s")
57+
// Make the tests run faster
58+
.put("discovery.zen.join.timeout", "100ms")
59+
.put("discovery.zen.ping.timeout", "10ms")
60+
.put("discovery.initial_state_timeout", "300ms");
5161

5262
return builder.build();
5363
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
/*
2+
* Licensed to Elasticsearch under one or more contributor
3+
* license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright
5+
* ownership. Elasticsearch licenses this file to you under
6+
* the Apache License, Version 2.0 (the "License"); you may
7+
* not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
20+
package org.elasticsearch.discovery.azure;
21+
22+
import org.elasticsearch.common.settings.ImmutableSettings;
23+
import org.elasticsearch.common.settings.Settings;
24+
import org.elasticsearch.discovery.MasterNotDiscoveredException;
25+
import org.elasticsearch.test.ElasticsearchIntegrationTest;
26+
import org.junit.Test;
27+
28+
import java.io.IOException;
29+
30+
import static org.hamcrest.Matchers.notNullValue;
31+
import static org.hamcrest.Matchers.nullValue;
32+
33+
/**
34+
* Reported issue in #15
35+
* (https://github.com/elasticsearch/elasticsearch-cloud-azure/issues/15)
36+
*/
37+
@ElasticsearchIntegrationTest.ClusterScope(scope = ElasticsearchIntegrationTest.Scope.TEST,
38+
numDataNodes = 0,
39+
transportClientRatio = 0.0,
40+
numClientNodes = 0)
41+
public class AzureMinimumMasterNodesTest extends AbstractAzureComputeServiceTest {
42+
43+
public AzureMinimumMasterNodesTest() {
44+
super(AzureComputeServiceTwoNodesMock.class);
45+
}
46+
47+
@Override
48+
protected final Settings settingsBuilder() {
49+
ImmutableSettings.Builder builder = ImmutableSettings.settingsBuilder()
50+
.put("discovery.zen.minimum_master_nodes", 2)
51+
.put(super.settingsBuilder());
52+
return builder.build();
53+
}
54+
55+
@Test
56+
public void simpleOnlyMasterNodeElection() throws IOException {
57+
logger.info("--> start data node / non master node");
58+
internalCluster().startNode(settingsBuilder());
59+
try {
60+
assertThat(client().admin().cluster().prepareState().setMasterNodeTimeout("100ms").execute().actionGet().getState().nodes().masterNodeId(), nullValue());
61+
fail("should not be able to find master");
62+
} catch (MasterNotDiscoveredException e) {
63+
// all is well, no master elected
64+
}
65+
logger.info("--> start another node");
66+
internalCluster().startNode(settingsBuilder());
67+
assertThat(client().admin().cluster().prepareState().setMasterNodeTimeout("1s").execute().actionGet().getState().nodes().masterNodeId(), notNullValue());
68+
69+
logger.info("--> stop master node");
70+
internalCluster().stopCurrentMasterNode();
71+
72+
try {
73+
assertThat(client().admin().cluster().prepareState().setMasterNodeTimeout("1s").execute().actionGet().getState().nodes().masterNodeId(), nullValue());
74+
fail("should not be able to find master");
75+
} catch (MasterNotDiscoveredException e) {
76+
// all is well, no master elected
77+
}
78+
79+
logger.info("--> start another node");
80+
internalCluster().startNode(settingsBuilder());
81+
assertThat(client().admin().cluster().prepareState().setMasterNodeTimeout("1s").execute().actionGet().getState().nodes().masterNodeId(), notNullValue());
82+
}
83+
}

src/test/java/org/elasticsearch/discovery/azure/AzureSimpleTest.java

+11-7
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,12 @@
2222
import org.elasticsearch.test.ElasticsearchIntegrationTest;
2323
import org.junit.Test;
2424

25-
@ElasticsearchIntegrationTest.ClusterScope(
26-
scope = ElasticsearchIntegrationTest.Scope.TEST,
27-
numDataNodes = 1,
28-
transportClientRatio = 0.0)
25+
import static org.hamcrest.Matchers.notNullValue;
26+
27+
@ElasticsearchIntegrationTest.ClusterScope(scope = ElasticsearchIntegrationTest.Scope.TEST,
28+
numDataNodes = 0,
29+
transportClientRatio = 0.0,
30+
numClientNodes = 0)
2931
public class AzureSimpleTest extends AbstractAzureComputeServiceTest {
3032

3133
public AzureSimpleTest() {
@@ -34,9 +36,11 @@ public AzureSimpleTest() {
3436

3537
@Test
3638
public void one_node_should_run() {
37-
// We expect having 2 nodes as part of the cluster, let's test that
38-
checkNumberOfNodes(1);
39-
39+
logger.info("--> start one node");
40+
internalCluster().startNode(settingsBuilder());
41+
assertThat(client().admin().cluster().prepareState().setMasterNodeTimeout("1s").execute().actionGet().getState().nodes().masterNodeId(), notNullValue());
4042

43+
// We expect having 1 node as part of the cluster, let's test that
44+
checkNumberOfNodes(1);
4145
}
4246
}

src/test/java/org/elasticsearch/discovery/azure/AzureTwoStartedNodesTest.java

+14-4
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,12 @@
2222
import org.elasticsearch.test.ElasticsearchIntegrationTest;
2323
import org.junit.Test;
2424

25-
@ElasticsearchIntegrationTest.ClusterScope(
26-
scope = ElasticsearchIntegrationTest.Scope.TEST,
27-
numDataNodes = 2,
28-
transportClientRatio = 0.0)
25+
import static org.hamcrest.Matchers.notNullValue;
26+
27+
@ElasticsearchIntegrationTest.ClusterScope(scope = ElasticsearchIntegrationTest.Scope.TEST,
28+
numDataNodes = 0,
29+
transportClientRatio = 0.0,
30+
numClientNodes = 0)
2931
public class AzureTwoStartedNodesTest extends AbstractAzureComputeServiceTest {
3032

3133
public AzureTwoStartedNodesTest() {
@@ -34,6 +36,14 @@ public AzureTwoStartedNodesTest() {
3436

3537
@Test
3638
public void two_nodes_should_run() {
39+
logger.info("--> start first node");
40+
internalCluster().startNode(settingsBuilder());
41+
assertThat(client().admin().cluster().prepareState().setMasterNodeTimeout("1s").execute().actionGet().getState().nodes().masterNodeId(), notNullValue());
42+
43+
logger.info("--> start another node");
44+
internalCluster().startNode(settingsBuilder());
45+
assertThat(client().admin().cluster().prepareState().setMasterNodeTimeout("1s").execute().actionGet().getState().nodes().masterNodeId(), notNullValue());
46+
3747
// We expect having 2 nodes as part of the cluster, let's test that
3848
checkNumberOfNodes(2);
3949
}

0 commit comments

Comments
 (0)