Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
And refactor integration tests Closes #17. (cherry picked from commit f5b444e) (cherry picked from commit 1e63f86)
- Loading branch information
Showing
11 changed files
with
175 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
83 changes: 83 additions & 0 deletions
83
src/test/java/org/elasticsearch/discovery/azure/AzureMinimumMasterNodesTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.