mirror of
https://github.com/honeymoose/OpenSearch.git
synced 2025-02-17 02:14:54 +00:00
When a new cluster starts, the HTTP layer becomes ready to accept incoming requests while the basic license is still being populated in the background. When a get license request comes in before the license is ready, it can get 404 error. This PR fixes it by either wrap the license check in assertBusy or ensure the license is ready before perform the check. This is a backport for both #60498 and #60573
This commit is contained in:
parent
3270cb3088
commit
a76fc324d4
@ -104,7 +104,7 @@ public class DocsClientYamlTestSuiteIT extends ESClientYamlSuiteTestCase {
|
||||
|
||||
@Before
|
||||
public void waitForRequirements() throws Exception {
|
||||
if (isCcrTest()) {
|
||||
if (isCcrTest() || isGetLicenseTest()) {
|
||||
ESRestTestCase.waitForActiveLicense(adminClient());
|
||||
}
|
||||
}
|
||||
@ -175,6 +175,11 @@ public class DocsClientYamlTestSuiteIT extends ESClientYamlSuiteTestCase {
|
||||
return testName != null && testName.contains("/ccr/");
|
||||
}
|
||||
|
||||
protected boolean isGetLicenseTest() {
|
||||
String testName = getTestName();
|
||||
return testName != null && (testName.contains("/get-license/") || testName.contains("\\get-license\\"));
|
||||
}
|
||||
|
||||
/**
|
||||
* Compares the results of running two analyzers against many random
|
||||
* strings. The goal is to figure out if two anlayzers are "the same" by
|
||||
|
@ -97,10 +97,16 @@ public class EnableSecurityOnBasicLicenseIT extends ESRestTestCase {
|
||||
return EntityUtils.toString(response.getEntity());
|
||||
}
|
||||
|
||||
private void checkBasicLicenseType() throws IOException {
|
||||
Map<String, Object> license = getAsMap("/_license");
|
||||
assertThat(license, notNullValue());
|
||||
assertThat(ObjectPath.evaluate(license, "license.type"), equalTo("basic"));
|
||||
private void checkBasicLicenseType() throws Exception {
|
||||
assertBusy(() -> {
|
||||
try {
|
||||
Map<String, Object> license = getAsMap("/_license");
|
||||
assertThat(license, notNullValue());
|
||||
assertThat(ObjectPath.evaluate(license, "license.type"), equalTo("basic"));
|
||||
} catch (ResponseException e) {
|
||||
throw new AssertionError(e);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void checkSecurityStatus(boolean expectEnabled) throws IOException {
|
||||
|
@ -77,10 +77,16 @@ public class SecurityWithBasicLicenseIT extends SecurityInBasicRestTestCase {
|
||||
client().performRequest(new Request("POST", "/_license/start_basic?acknowledge=true"));
|
||||
}
|
||||
|
||||
private void checkLicenseType(String type) throws IOException {
|
||||
Map<String, Object> license = getAsMap("/_license");
|
||||
assertThat(license, notNullValue());
|
||||
assertThat(ObjectPath.evaluate(license, "license.type"), equalTo(type));
|
||||
private void checkLicenseType(String type) throws Exception {
|
||||
assertBusy(() -> {
|
||||
try {
|
||||
Map<String, Object> license = getAsMap("/_license");
|
||||
assertThat(license, notNullValue());
|
||||
assertThat(ObjectPath.evaluate(license, "license.type"), equalTo(type));
|
||||
} catch (ResponseException e) {
|
||||
throw new AssertionError(e);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void checkSecurityEnabled(boolean allowAllRealms) throws IOException {
|
||||
|
@ -7,6 +7,7 @@ package org.elasticsearch.xpack.security;
|
||||
|
||||
import org.elasticsearch.client.Request;
|
||||
import org.elasticsearch.client.Response;
|
||||
import org.elasticsearch.client.ResponseException;
|
||||
import org.elasticsearch.common.io.PathUtils;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.test.rest.ESRestTestCase;
|
||||
@ -85,10 +86,17 @@ public class TlsWithBasicLicenseIT extends ESRestTestCase {
|
||||
client().performRequest(new Request("POST", "/_license/start_basic?acknowledge=true"));
|
||||
}
|
||||
|
||||
private void checkLicenseType(String type) throws IOException {
|
||||
Map<String, Object> license = getAsMap("/_license");
|
||||
assertThat(license, notNullValue());
|
||||
assertThat(ObjectPath.evaluate(license, "license.type"), equalTo(type));
|
||||
private void checkLicenseType(String type) throws Exception {
|
||||
assertBusy(() -> {
|
||||
try {
|
||||
Map<String, Object> license = getAsMap("/_license");
|
||||
assertThat(license, notNullValue());
|
||||
assertThat(ObjectPath.evaluate(license, "license.type"), equalTo(type));
|
||||
} catch (ResponseException e) {
|
||||
throw new AssertionError(e);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private void checkSSLEnabled() throws IOException {
|
||||
|
Loading…
x
Reference in New Issue
Block a user