Do not set up NodeAndClusterIdStateListener in test (#38110)
When extending ESIntegTestCase are run on the same jvm, the static field in NodeAndClusterIdConverter will throw an AlreadySet exceptions. overriding the configuration method from Node.configureNodeAndClusterIdStateListener in the MockNode will prevent the listener registration from happening relates #32850
This commit is contained in:
parent
be381b4525
commit
28b5c7ce78
|
@ -684,8 +684,7 @@ public class Node implements Closeable {
|
||||||
transportService.acceptIncomingRequests();
|
transportService.acceptIncomingRequests();
|
||||||
discovery.startInitialJoin();
|
discovery.startInitialJoin();
|
||||||
final TimeValue initialStateTimeout = DiscoverySettings.INITIAL_STATE_TIMEOUT_SETTING.get(settings);
|
final TimeValue initialStateTimeout = DiscoverySettings.INITIAL_STATE_TIMEOUT_SETTING.get(settings);
|
||||||
NodeAndClusterIdStateListener.getAndSetNodeIdAndClusterId(clusterService,
|
configureNodeAndClusterIdStateListener(clusterService);
|
||||||
injector.getInstance(ThreadPool.class).getThreadContext());
|
|
||||||
|
|
||||||
if (initialStateTimeout.millis() > 0) {
|
if (initialStateTimeout.millis() > 0) {
|
||||||
final ThreadPool thread = injector.getInstance(ThreadPool.class);
|
final ThreadPool thread = injector.getInstance(ThreadPool.class);
|
||||||
|
@ -737,6 +736,11 @@ public class Node implements Closeable {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void configureNodeAndClusterIdStateListener(ClusterService clusterService) {
|
||||||
|
NodeAndClusterIdStateListener.getAndSetNodeIdAndClusterId(clusterService,
|
||||||
|
injector.getInstance(ThreadPool.class).getThreadContext());
|
||||||
|
}
|
||||||
|
|
||||||
private Node stop() {
|
private Node stop() {
|
||||||
if (!lifecycle.moveToStopped()) {
|
if (!lifecycle.moveToStopped()) {
|
||||||
return this;
|
return this;
|
||||||
|
|
|
@ -174,4 +174,9 @@ public class MockNode extends Node {
|
||||||
return new MockHttpTransport();
|
return new MockHttpTransport();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void configureNodeAndClusterIdStateListener(ClusterService clusterService) {
|
||||||
|
//do not configure this in tests as this is causing SetOnce to throw exceptions when jvm is used for multiple tests
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue