[TEST] : take into account inclusive range in Pre/Post ExpirationCallbacks

Original commit: elastic/x-pack-elasticsearch@346b9f3b4c
This commit is contained in:
Areek Zillur 2015-01-23 00:01:03 -05:00
parent 91881f8c04
commit 57ec891db0
1 changed files with 6 additions and 23 deletions

View File

@ -144,7 +144,8 @@ public class LicensesClientServiceTests extends AbstractLicensesServiceTests {
actions.add(registerWithEventNotification(clientService, clientListener, feature, TimeValue.timeValueSeconds(3), callbacks));
actions.add(assertExpiryAction(feature, "trial", TimeValue.timeValueMinutes(1)));
assertClientListenerNotificationCount(clientListener, actions);
assertThat(triggerCount3.get(), equalTo(2));
assertThat(triggerCount3.get(), greaterThanOrEqualTo(2));
assertThat(triggerCount3.get(), lessThan(4));
assertThat(triggerCount1.get(), greaterThan(4));
Thread.sleep(2000);
assertThat(triggerCount2.get(), greaterThan(8));
@ -156,26 +157,6 @@ public class LicensesClientServiceTests extends AbstractLicensesServiceTests {
assertThat(previousTriggerCount, lessThanOrEqualTo(triggerCount2.get() + 1));
}
@Test
public void testPostEventNotification2() throws Exception {
final LicensesClientService clientService = licensesClientService();
final String feature = "feature";
TestTrackingClientListener clientListener = new TestTrackingClientListener(feature, true);
AtomicInteger counter = new AtomicInteger(0);
List<Action> actions = new ArrayList<>();
actions.add(
registerWithEventNotification(clientService, clientListener, feature, TimeValue.timeValueSeconds(3),
Arrays.asList(
postCallbackLatch(TimeValue.timeValueMillis(0), TimeValue.timeValueSeconds(2), TimeValue.timeValueMillis(500), counter)
))
);
actions.add(assertExpiryAction(feature, "trial", TimeValue.timeValueSeconds(3)));
assertClientListenerNotificationCount(clientListener, actions);
Thread.sleep(50 + 2000);
assertThat(counter.get(), equalTo(4));
}
@Test
public void testPreEventNotification() throws Exception {
final LicensesClientService clientService = licensesClientService();
@ -191,7 +172,8 @@ public class LicensesClientServiceTests extends AbstractLicensesServiceTests {
);
actions.add(assertExpiryAction(feature, "trial", TimeValue.timeValueSeconds(3)));
assertClientListenerNotificationCount(clientListener, actions);
assertThat(counter.get(), equalTo(3));
assertThat(counter.get(), greaterThanOrEqualTo(3));
assertThat(counter.get(), lessThan(5));
}
@Test
@ -210,7 +192,8 @@ public class LicensesClientServiceTests extends AbstractLicensesServiceTests {
actions.add(assertExpiryAction(feature, "trial", TimeValue.timeValueSeconds(1)));
assertClientListenerNotificationCount(clientListener, actions);
Thread.sleep(50 + 2000);
assertThat(counter.get(), equalTo(3));
assertThat(counter.get(), greaterThanOrEqualTo(3));
assertThat(counter.get(), lessThan(5));
}
private LicensesService.ExpirationCallback preCallbackLatch(TimeValue min, TimeValue max, TimeValue frequency, final AtomicInteger triggerCount) {