use of com.hazelcast.test.AssertTask in project hazelcast by hazelcast.
the class ShutdownClusterRequestTest method testShutdownCluster.
@Test
public void testShutdownCluster() throws Exception {
ShutdownClusterRequest request = new ShutdownClusterRequest();
cluster.getClusterState();
JsonObject jsonObject = new JsonObject();
request.writeResponse(managementCenterService, jsonObject);
JsonObject result = (JsonObject) jsonObject.get("result");
assertEquals("SUCCESS", request.readResponse(result));
assertTrueEventually(new AssertTask() {
@Override
public void run() throws Exception {
assertFalse(lifecycleService.isRunning());
}
});
}
use of com.hazelcast.test.AssertTask in project hazelcast by hazelcast.
the class RestClusterTest method testClusterShutdown.
@Test
public void testClusterShutdown() throws Exception {
final HazelcastInstance instance1 = Hazelcast.newHazelcastInstance(config);
final HazelcastInstance instance2 = Hazelcast.newHazelcastInstance(config);
HTTPCommunicator communicator = new HTTPCommunicator(instance2);
assertEquals(HttpURLConnection.HTTP_OK, communicator.shutdownCluster("dev", "dev-pass"));
assertTrueEventually(new AssertTask() {
@Override
public void run() throws Exception {
assertFalse(instance1.getLifecycleService().isRunning());
assertFalse(instance2.getLifecycleService().isRunning());
}
});
}
use of com.hazelcast.test.AssertTask in project hazelcast by hazelcast.
the class AdvancedClusterStateTest method changeClusterState_shouldNotFail_whenNonInitiatorMemberDies_duringCommit.
@Test
public void changeClusterState_shouldNotFail_whenNonInitiatorMemberDies_duringCommit() throws Exception {
final TestHazelcastInstanceFactory factory = createHazelcastInstanceFactory(3);
final HazelcastInstance[] instances = factory.newInstances();
final HazelcastInstance hz = instances[2];
TransactionManagerServiceImpl transactionManagerService = spyTransactionManagerService(hz);
final Address address = getAddress(instances[0]);
TransactionOptions options = TransactionOptions.getDefault().setDurability(0);
when(transactionManagerService.newAllowedDuringPassiveStateTransaction(options)).thenAnswer(new TransactionAnswer() {
@Override
protected void afterPrepare() {
terminateInstance(instances[0]);
}
});
hz.getCluster().changeClusterState(ClusterState.FROZEN, options);
assertTrueEventually(new AssertTask() {
@Override
public void run() throws Exception {
assertClusterState(ClusterState.FROZEN, instances[2], instances[1]);
}
});
instances[0] = factory.newHazelcastInstance(address);
assertClusterSizeEventually(3, instances[0]);
assertClusterSizeEventually(3, instances[1]);
assertClusterSizeEventually(3, instances[2]);
assertClusterState(ClusterState.FROZEN, instances);
}
use of com.hazelcast.test.AssertTask in project hazelcast by hazelcast.
the class BasicClusterStateTest method test_eventsDispatched_whenClusterState_PASSIVE.
@Test
public void test_eventsDispatched_whenClusterState_PASSIVE() {
System.setProperty(EventServiceImpl.EVENT_SYNC_FREQUENCY_PROP, "1");
final TestHazelcastInstanceFactory factory = createHazelcastInstanceFactory(2);
final HazelcastInstance master = factory.newHazelcastInstance();
final HazelcastInstance other = factory.newHazelcastInstance();
changeClusterStateEventually(master, ClusterState.PASSIVE);
master.getMap(randomMapName());
assertTrueEventually(new AssertTask() {
@Override
public void run() throws Exception {
assertEquals(1, getNodeEngineImpl(other).getProxyService().getProxyCount());
}
});
}
use of com.hazelcast.test.AssertTask in project hazelcast by hazelcast.
the class LockGuardTest method testIsLeaseExpired.
@Test
public void testIsLeaseExpired() throws Exception {
LockGuard stateLock = LockGuard.NOT_LOCKED;
assertFalse(stateLock.isLeaseExpired());
Address endpoint = newAddress();
stateLock = new LockGuard(endpoint, "txn", TimeUnit.HOURS.toMillis(1));
assertFalse(stateLock.isLeaseExpired());
stateLock = new LockGuard(endpoint, "txn", 1);
final LockGuard finalStateLock = stateLock;
HazelcastTestSupport.assertTrueEventually(new AssertTask() {
@Override
public void run() throws Exception {
assertTrue(finalStateLock.isLeaseExpired());
}
});
}
Aggregations