From 66e0f026dab494359737b8a0254e0b212f725d4d Mon Sep 17 00:00:00 2001 From: Craig Perkins Date: Thu, 2 Nov 2023 23:04:03 -0400 Subject: [PATCH] Revert change to SlowIntegrationTests Signed-off-by: Craig Perkins --- .../security/SlowIntegrationTests.java | 38 ++++++++++--------- 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/src/test/java/org/opensearch/security/SlowIntegrationTests.java b/src/test/java/org/opensearch/security/SlowIntegrationTests.java index a66e519fad..28ec9f8d88 100644 --- a/src/test/java/org/opensearch/security/SlowIntegrationTests.java +++ b/src/test/java/org/opensearch/security/SlowIntegrationTests.java @@ -26,6 +26,8 @@ package org.opensearch.security; +import java.io.IOException; + import com.google.common.collect.Lists; import org.apache.hc.core5.http.HttpStatus; import org.junit.Assert; @@ -221,24 +223,24 @@ public void testDelayInSecurityIndexInitialization() throws Exception { .put(ConfigConstants.SECURITY_ALLOW_DEFAULT_INIT_SECURITYINDEX, true) .put("cluster.routing.allocation.exclude._ip", "127.0.0.1") .build(); - setup(Settings.EMPTY, null, settings, false); - Thread.sleep(1000 * 30); - Assert.assertEquals( - ClusterHealthStatus.RED, - clusterHelper.nodeClient().admin().cluster().health(new ClusterHealthRequest()).actionGet().getStatus() - ); - Thread.sleep(1000 * 30); - // Ideally, we would want to remove this cluster setting, but default settings cannot be removed. So overriding with a reserved - // IP address - clusterHelper.nodeClient() - .admin() - .cluster() - .updateSettings( - new ClusterUpdateSettingsRequest().transientSettings( - Settings.builder().put("cluster.routing.allocation.exclude._ip", "192.0.2.0").build() - ) - ); - this.clusterInfo = clusterHelper.waitForCluster(ClusterHealthStatus.GREEN, TimeValue.timeValueSeconds(10), 3); + try { + setup(Settings.EMPTY, null, settings, false); + Assert.fail("Expected IOException here due to red cluster state"); + } catch (IOException e) { + // Index request has a default timeout of 1 minute, adding buffer between nodes initialization and cluster health check + Thread.sleep(1000 * 80); + // Ideally, we would want to remove this cluster setting, but default settings cannot be removed. So overriding with a reserved + // IP address + clusterHelper.nodeClient() + .admin() + .cluster() + .updateSettings( + new ClusterUpdateSettingsRequest().transientSettings( + Settings.builder().put("cluster.routing.allocation.exclude._ip", "192.0.2.0").build() + ) + ); + this.clusterInfo = clusterHelper.waitForCluster(ClusterHealthStatus.GREEN, TimeValue.timeValueSeconds(10), 3); + } RestHelper rh = nonSslRestHelper(); Thread.sleep(10000); Assert.assertEquals(HttpStatus.SC_OK, rh.executeGetRequest("", encodeBasicHeader("admin", "admin")).getStatusCode());