From fc5edc242dd35d97e2f475ca29aaa57abb1f2aaa Mon Sep 17 00:00:00 2001 From: Boaz Leskes Date: Tue, 31 May 2016 09:48:53 +0200 Subject: [PATCH] add assertBusy to testEmptyGetLicense as trial license is added async Original commit: elastic/x-pack-elasticsearch@8dea3c54f9a89b8d0b74b89edf1e0a351660f4d7 --- .../license/plugin/LicensesTransportTests.java | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/elasticsearch/x-pack/license-plugin/src/test/java/org/elasticsearch/license/plugin/LicensesTransportTests.java b/elasticsearch/x-pack/license-plugin/src/test/java/org/elasticsearch/license/plugin/LicensesTransportTests.java index 1e3db66f25e..d1ef05defbc 100644 --- a/elasticsearch/x-pack/license-plugin/src/test/java/org/elasticsearch/license/plugin/LicensesTransportTests.java +++ b/elasticsearch/x-pack/license-plugin/src/test/java/org/elasticsearch/license/plugin/LicensesTransportTests.java @@ -58,11 +58,19 @@ public class LicensesTransportTests extends ESSingleNodeTestCase { } public void testEmptyGetLicense() throws Exception { - final ActionFuture getLicenseFuture = - new GetLicenseRequestBuilder(client().admin().cluster(), GetLicenseAction.INSTANCE).execute(); - final GetLicenseResponse getLicenseResponse = getLicenseFuture.get(); - assertNotNull(getLicenseResponse.license()); - assertThat(getLicenseResponse.license().operationMode(), equalTo(License.OperationMode.TRIAL)); + // trail license is added async, we should wait for it + assertBusy(() -> { + try { + final ActionFuture getLicenseFuture = + new GetLicenseRequestBuilder(client().admin().cluster(), GetLicenseAction.INSTANCE).execute(); + final GetLicenseResponse getLicenseResponse; + getLicenseResponse = getLicenseFuture.get(); + assertNotNull(getLicenseResponse.license()); + assertThat(getLicenseResponse.license().operationMode(), equalTo(License.OperationMode.TRIAL)); + } catch (Exception e) { + throw new RuntimeException("unexpected exception", e); + } + }); } public void testPutLicense() throws Exception {