mirror of
https://github.com/honeymoose/OpenSearch.git
synced 2025-03-01 16:39:11 +00:00
make sure all integration tests use ElasticsearchIntegrationTest
- move ClusterSettingsTests to ElasticsearchIntegrationTest - remove InternalNodeTests, we already have separate plugin tests that verify it
This commit is contained in:
parent
488451b67c
commit
f47f224d33
@ -20,50 +20,34 @@
|
||||
package org.elasticsearch.cluster.settings;
|
||||
|
||||
import org.elasticsearch.action.admin.cluster.settings.ClusterUpdateSettingsResponse;
|
||||
import org.elasticsearch.client.Client;
|
||||
import org.elasticsearch.cluster.routing.allocation.decider.DisableAllocationDecider;
|
||||
import org.elasticsearch.common.settings.ImmutableSettings;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.node.Node;
|
||||
import org.elasticsearch.node.NodeBuilder;
|
||||
import org.elasticsearch.test.ElasticsearchTestCase;
|
||||
import org.elasticsearch.test.ElasticsearchIntegrationTest;
|
||||
import org.hamcrest.Matchers;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.hamcrest.Matchers.notNullValue;
|
||||
import static org.hamcrest.Matchers.nullValue;
|
||||
|
||||
public class ClusterSettingsTests extends ElasticsearchTestCase {
|
||||
@ElasticsearchIntegrationTest.ClusterScope(scope = ElasticsearchIntegrationTest.Scope.TEST, numNodes = 1)
|
||||
public class ClusterSettingsTests extends ElasticsearchIntegrationTest {
|
||||
|
||||
@Test
|
||||
public void clusterNonExistingSettingsUpdate() {
|
||||
Node node1 = NodeBuilder.nodeBuilder().node();
|
||||
node1.start();
|
||||
Client client = node1.client();
|
||||
|
||||
String key1 = "no_idea_what_you_are_talking_about";
|
||||
int value1 = 10;
|
||||
|
||||
ClusterUpdateSettingsResponse response = client.admin().cluster()
|
||||
ClusterUpdateSettingsResponse response = client().admin().cluster()
|
||||
.prepareUpdateSettings()
|
||||
.setTransientSettings(ImmutableSettings.builder().put(key1, value1).build())
|
||||
.get();
|
||||
|
||||
assertThat(response.getTransientSettings().getAsMap().entrySet(), Matchers.emptyIterable());
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void clusterSettingsUpdateResponse() {
|
||||
Node node1 = NodeBuilder.nodeBuilder().node();
|
||||
Node node2 = NodeBuilder.nodeBuilder().node();
|
||||
|
||||
node1.start();
|
||||
node2.start();
|
||||
|
||||
Client client = node1.client();
|
||||
|
||||
String key1 = "indices.cache.filter.size";
|
||||
int value1 = 10;
|
||||
|
||||
@ -73,7 +57,7 @@ public class ClusterSettingsTests extends ElasticsearchTestCase {
|
||||
Settings transientSettings1 = ImmutableSettings.builder().put(key1, value1).build();
|
||||
Settings persistentSettings1 = ImmutableSettings.builder().put(key2, value2).build();
|
||||
|
||||
ClusterUpdateSettingsResponse response1 = client.admin().cluster()
|
||||
ClusterUpdateSettingsResponse response1 = client().admin().cluster()
|
||||
.prepareUpdateSettings()
|
||||
.setTransientSettings(transientSettings1)
|
||||
.setPersistentSettings(persistentSettings1)
|
||||
@ -88,7 +72,7 @@ public class ClusterSettingsTests extends ElasticsearchTestCase {
|
||||
Settings transientSettings2 = ImmutableSettings.builder().put(key1, value1).put(key2, value2).build();
|
||||
Settings persistentSettings2 = ImmutableSettings.EMPTY;
|
||||
|
||||
ClusterUpdateSettingsResponse response2 = client.admin().cluster()
|
||||
ClusterUpdateSettingsResponse response2 = client().admin().cluster()
|
||||
.prepareUpdateSettings()
|
||||
.setTransientSettings(transientSettings2)
|
||||
.setPersistentSettings(persistentSettings2)
|
||||
@ -103,7 +87,7 @@ public class ClusterSettingsTests extends ElasticsearchTestCase {
|
||||
Settings transientSettings3 = ImmutableSettings.EMPTY;
|
||||
Settings persistentSettings3 = ImmutableSettings.builder().put(key1, value1).put(key2, value2).build();
|
||||
|
||||
ClusterUpdateSettingsResponse response3 = client.admin().cluster()
|
||||
ClusterUpdateSettingsResponse response3 = client().admin().cluster()
|
||||
.prepareUpdateSettings()
|
||||
.setTransientSettings(transientSettings3)
|
||||
.setPersistentSettings(persistentSettings3)
|
||||
@ -114,9 +98,5 @@ public class ClusterSettingsTests extends ElasticsearchTestCase {
|
||||
assertThat(response3.getTransientSettings().get(key2), nullValue());
|
||||
assertThat(response3.getPersistentSettings().get(key1), notNullValue());
|
||||
assertThat(response3.getPersistentSettings().get(key2), notNullValue());
|
||||
|
||||
node1.stop();
|
||||
node2.stop();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,119 +0,0 @@
|
||||
/*
|
||||
* Licensed to Elastic Search and Shay Banon 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.node;
|
||||
|
||||
import org.elasticsearch.ElasticSearchException;
|
||||
import org.elasticsearch.common.component.AbstractLifecycleComponent;
|
||||
import org.elasticsearch.common.component.Lifecycle;
|
||||
import org.elasticsearch.common.component.LifecycleComponent;
|
||||
import org.elasticsearch.common.inject.Inject;
|
||||
import org.elasticsearch.common.inject.Singleton;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.node.internal.InternalNode;
|
||||
import org.elasticsearch.plugins.AbstractPlugin;
|
||||
import org.elasticsearch.test.ElasticsearchTestCase;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
|
||||
import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder;
|
||||
import static org.elasticsearch.node.NodeBuilder.nodeBuilder;
|
||||
import static org.hamcrest.Matchers.is;
|
||||
|
||||
public class InternalNodeTests extends ElasticsearchTestCase {
|
||||
|
||||
@Test
|
||||
public void testDefaultPluginConfiguration() throws Exception {
|
||||
|
||||
Settings settings = settingsBuilder()
|
||||
.put("plugin.types", TestPlugin.class.getName())
|
||||
.put("name", "test")
|
||||
.build();
|
||||
|
||||
InternalNode node = (InternalNode) nodeBuilder()
|
||||
.settings(settings)
|
||||
.build();
|
||||
|
||||
TestService service = node.injector().getInstance(TestService.class);
|
||||
assertThat(service.state.initialized(), is(true));
|
||||
node.start();
|
||||
assertThat(service.state.started(), is(true));
|
||||
node.stop();
|
||||
assertThat(service.state.stopped(), is(true));
|
||||
node.close();
|
||||
assertThat(service.state.closed(), is(true));
|
||||
}
|
||||
|
||||
public static class TestPlugin extends AbstractPlugin {
|
||||
|
||||
public TestPlugin() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String name() {
|
||||
return "test";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String description() {
|
||||
return "test plugin";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<Class<? extends LifecycleComponent>> services() {
|
||||
Collection<Class<? extends LifecycleComponent>> services = new ArrayList<Class<? extends LifecycleComponent>>();
|
||||
services.add(TestService.class);
|
||||
return services;
|
||||
}
|
||||
}
|
||||
|
||||
@Singleton
|
||||
public static class TestService extends AbstractLifecycleComponent<TestService> {
|
||||
|
||||
private Lifecycle state;
|
||||
|
||||
@Inject
|
||||
public TestService(Settings settings) {
|
||||
super(settings);
|
||||
logger.info("initializing");
|
||||
state = new Lifecycle();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doStart() throws ElasticSearchException {
|
||||
logger.info("starting");
|
||||
state.moveToStarted();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doStop() throws ElasticSearchException {
|
||||
logger.info("stopping");
|
||||
state.moveToStopped();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doClose() throws ElasticSearchException {
|
||||
logger.info("closing");
|
||||
state.moveToClosed();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user