Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix LifecycleLicenseIT failures #66039

Merged
merged 2 commits into from
Dec 8, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

import org.apache.http.util.EntityUtils;
import org.elasticsearch.client.Request;
import org.elasticsearch.client.Response;
import org.elasticsearch.client.ResponseException;
import org.elasticsearch.cluster.metadata.DataStream;
import org.elasticsearch.cluster.metadata.Template;
Expand Down Expand Up @@ -48,9 +49,10 @@ public class LifecycleLicenseIT extends ESRestTestCase {
private String dataStream;

@Before
public void refreshDatastream() {
public void refreshDatastream() throws Exception {
dataStream = "logs-" + randomAlphaOfLength(10).toLowerCase(Locale.ROOT);
policy = "policy-" + randomAlphaOfLength(5);
waitForActiveLicense(adminClient());
}

@After
Expand Down Expand Up @@ -130,11 +132,20 @@ private void putTrialLicense() throws Exception {
XContentBuilder builder = JsonXContent.contentBuilder();
builder = signedLicense.toXContent(builder, ToXContent.EMPTY_PARAMS);
putTrialRequest.setJsonEntity("{\"licenses\":[\n " + Strings.toString(builder) + "\n]}");
client().performRequest(putTrialRequest);
assertBusy(() -> {
Response putLicenseResponse = client().performRequest(putTrialRequest);
logger.info("put trial license response body is [{}]", EntityUtils.toString(putLicenseResponse.getEntity()));
assertOK(putLicenseResponse);
});
}

private void checkCurrentLicenseIs(String type) throws Exception {
assertBusy(() -> assertThat(EntityUtils.toString(client().performRequest(new Request("GET", "/_license")).getEntity()),
containsStringIgnoringCase("\"type\" : \"" + type + "\"")));
assertBusy(() -> {
Response getLicense = client().performRequest(new Request("GET", "/_license"));
String responseBody = EntityUtils.toString(getLicense.getEntity());
logger.info("get license response body is [{}]", responseBody);
assertThat(responseBody,
containsStringIgnoringCase("\"type\" : \"" + type + "\""));
});
}
}