Fix license ack tests to ensure license change always results in ack

messages

Original commit: elastic/x-pack-elasticsearch@25029eb83e
This commit is contained in:
Ryan Ernst 2016-07-25 20:12:42 -07:00
parent 3e8bc2879f
commit 8e0da2602d
1 changed files with 4 additions and 2 deletions

View File

@ -27,17 +27,18 @@ public class LicensesAcknowledgementTests extends AbstractLicenseServiceTestCase
setInitialState(TestUtils.generateSignedLicense("trial", TimeValue.timeValueHours(2)), licenseState);
licenseService.start();
// try installing a signed license
License signedLicense = generateSignedLicense(TimeValue.timeValueHours(10));
License signedLicense = generateSignedLicense("basic", TimeValue.timeValueHours(10));
PutLicenseRequest putLicenseRequest = new PutLicenseRequest().license(signedLicense);
// ensure acknowledgement message was part of the response
licenseService.registerLicense(putLicenseRequest, new AssertingLicensesUpdateResponse(false, LicensesStatus.VALID, true));
assertThat(licenseService.getLicense(), not(signedLicense));
verify(clusterService, times(0)).submitStateUpdateTask(any(String.class), any(ClusterStateUpdateTask.class));
// try installing a signed license with acknowledgement
putLicenseRequest = new PutLicenseRequest().license(signedLicense).acknowledge(true);
// ensure license was installed and no acknowledgment message was returned
licenseService.registerLicense(putLicenseRequest, new AssertingLicensesUpdateResponse(true, LicensesStatus.VALID, false));
verify(clusterService, times(2)).submitStateUpdateTask(any(String.class), any(ClusterStateUpdateTask.class));
verify(clusterService, times(1)).submitStateUpdateTask(any(String.class), any(ClusterStateUpdateTask.class));
}
private static class AssertingLicensesUpdateResponse implements ActionListener<PutLicenseResponse> {
@ -61,6 +62,7 @@ public class LicensesAcknowledgementTests extends AbstractLicenseServiceTestCase
@Override
public void onFailure(Exception throwable) {
throw new RuntimeException(throwable);
}
}
}