SecurityTribeIT - only wait for number nodes if they are not already there.
Original commit: elastic/x-pack-elasticsearch@3fa5da519a
This commit is contained in:
parent
baf1596418
commit
29e35267c3
|
@ -43,6 +43,7 @@ import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.concurrent.CountDownLatch;
|
import java.util.concurrent.CountDownLatch;
|
||||||
|
import java.util.function.Predicate;
|
||||||
|
|
||||||
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
|
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
|
||||||
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertNoTimeout;
|
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertNoTimeout;
|
||||||
|
@ -167,10 +168,12 @@ public class SecurityTribeIT extends NativeRealmIntegTestCase {
|
||||||
tribeClient = getClientWrapper().apply(tribeNode.client());
|
tribeClient = getClientWrapper().apply(tribeNode.client());
|
||||||
ClusterStateObserver observer = new ClusterStateObserver(tribeNode.injector().getInstance(ClusterService.class),
|
ClusterStateObserver observer = new ClusterStateObserver(tribeNode.injector().getInstance(ClusterService.class),
|
||||||
logger, new ThreadContext(settings));
|
logger, new ThreadContext(settings));
|
||||||
CountDownLatch latch = new CountDownLatch(1);
|
|
||||||
final int cluster1Nodes = internalCluster().size();
|
final int cluster1Nodes = internalCluster().size();
|
||||||
final int cluster2Nodes = cluster2.size();
|
final int cluster2Nodes = cluster2.size();
|
||||||
logger.info("waiting for [{}] nodes to be added to the tribe cluster state", cluster1Nodes + cluster2Nodes + 2);
|
logger.info("waiting for [{}] nodes to be added to the tribe cluster state", cluster1Nodes + cluster2Nodes + 2);
|
||||||
|
final Predicate<ClusterState> nodeCountPredicate = state -> state.nodes().getSize() == cluster1Nodes + cluster2Nodes + 3;
|
||||||
|
if (nodeCountPredicate.test(observer.observedState()) == false) {
|
||||||
|
CountDownLatch latch = new CountDownLatch(1);
|
||||||
observer.waitForNextChange(new ClusterStateObserver.Listener() {
|
observer.waitForNextChange(new ClusterStateObserver.Listener() {
|
||||||
@Override
|
@Override
|
||||||
public void onNewClusterState(ClusterState state) {
|
public void onNewClusterState(ClusterState state) {
|
||||||
|
@ -191,11 +194,12 @@ public class SecurityTribeIT extends NativeRealmIntegTestCase {
|
||||||
}, new ClusterStateObserver.ValidationPredicate() {
|
}, new ClusterStateObserver.ValidationPredicate() {
|
||||||
@Override
|
@Override
|
||||||
protected boolean validate(ClusterState newState) {
|
protected boolean validate(ClusterState newState) {
|
||||||
return newState.nodes().getSize() == cluster1Nodes + cluster2Nodes + 3;
|
return nodeCountPredicate.test(newState);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
latch.await();
|
latch.await();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void testThatTribeCanAuthenticateElasticUser() throws Exception {
|
public void testThatTribeCanAuthenticateElasticUser() throws Exception {
|
||||||
setupTribeNode(Settings.EMPTY);
|
setupTribeNode(Settings.EMPTY);
|
||||||
|
|
Loading…
Reference in New Issue