Skip to content

Commit

Permalink
Re-throw ResponseException as AssertionError in BasicLicenseUpgradeIT (
Browse files Browse the repository at this point in the history
…#68046)

It's possible that in a slow machine the cluster state updates
take a while to be applied, the license information is published
with NORMAL priority, meaning that it can take a while for the
License information to become available. This can lead to race
conditions. In order to wait until the license information is
available, the tests use assertBusy, but assertBusy only retries
if an AssertionException is raised, for that reason we use the
ignore parameter in the http client and later check that the
response was correct, meaning that the check can be retried
if the license information is not ready yet.

Closes #64578
Backport of #67182
  • Loading branch information
fcofdez authored Jan 27, 2021
1 parent 11ce2f4 commit b0e1d9d
Showing 1 changed file with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,12 @@ public void testNewClusterHasActiveNonExpiringBasic() throws Exception {

@SuppressWarnings("unchecked")
private void checkBasicLicense() throws Exception {
Response licenseResponse = client().performRequest(new Request("GET", "/_license"));
final Request request = new Request("GET", "/_license");
// This avoids throwing a ResponseException when the license is not ready yet
// allowing to retry the check using assertBusy
request.addParameter("ignore", "404");
Response licenseResponse = client().performRequest(request);
assertOK(licenseResponse);
Map<String, Object> licenseResponseMap = entityAsMap(licenseResponse);
Map<String, Object> licenseMap = (Map<String, Object>) licenseResponseMap.get("license");
assertEquals("basic", licenseMap.get("type"));
Expand All @@ -33,7 +38,12 @@ private void checkBasicLicense() throws Exception {

@SuppressWarnings("unchecked")
private void checkNonExpiringBasicLicense() throws Exception {
Response licenseResponse = client().performRequest(new Request("GET", "/_license"));
final Request request = new Request("GET", "/_license");
// This avoids throwing a ResponseException when the license is not ready yet
// allowing to retry the check using assertBusy
request.addParameter("ignore", "404");
Response licenseResponse = client().performRequest(request);
assertOK(licenseResponse);
Map<String, Object> licenseResponseMap = entityAsMap(licenseResponse);
Map<String, Object> licenseMap = (Map<String, Object>) licenseResponseMap.get("license");
assertEquals("basic", licenseMap.get("type"));
Expand Down

0 comments on commit b0e1d9d

Please sign in to comment.