use of com.hazelcast.test.AssertTask in project hazelcast by hazelcast.
the class PartitionListenerTest method test_whenMemberAdded.
@Test
public void test_whenMemberAdded() {
TestHazelcastInstanceFactory factory = createHazelcastInstanceFactory();
HazelcastInstance hz = factory.newHazelcastInstance();
InternalPartitionServiceImpl partitionService = getNode(hz).partitionService;
final int partitionCount = partitionService.getPartitionCount();
warmUpPartitionsAndDrainEvents(hz, partitionCount);
final AtomicInteger count = addEventCountingPartitionListener(partitionService);
factory.newHazelcastInstance();
assertClusterSizeEventually(2, hz);
assertTrueEventually(new AssertTask() {
@Override
public void run() throws Exception {
int currentCount = count.get();
assertTrue("Expecting events equal or greater than partition-count! Count: " + currentCount, currentCount >= partitionCount);
}
});
}
use of com.hazelcast.test.AssertTask in project hazelcast by hazelcast.
the class WriteBehindWithEntryProcessorTest method assertStoreOperationCount.
private void assertStoreOperationCount(MapStore mapStore, final int expectedStoreCallCount) {
final CustomerDataStore store = (CustomerDataStore) mapStore;
assertTrueEventually(new AssertTask() {
@Override
public void run() throws Exception {
final int storeCallCount = store.getStoreCallCount();
assertEquals(expectedStoreCallCount, storeCallCount);
}
});
}
use of com.hazelcast.test.AssertTask in project hazelcast by hazelcast.
the class WriteBehindFailAndRetryTest method testStoreOperationDone_afterTemporaryMapStoreFailure_whenNonWriteCoalescingModeOn.
@Test
public void testStoreOperationDone_afterTemporaryMapStoreFailure_whenNonWriteCoalescingModeOn() throws Exception {
final SelfHealingMapStore<Integer, Integer> mapStore = new SelfHealingMapStore<Integer, Integer>();
final IMap<Integer, Integer> map = TestMapUsingMapStoreBuilder.<Integer, Integer>create().withMapStore(mapStore).withNodeCount(1).withNodeFactory(createHazelcastInstanceFactory(1)).withWriteDelaySeconds(1).withWriteCoalescing(false).withPartitionCount(1).build();
map.put(1, 2);
map.put(1, 3);
map.put(1, 4);
assertTrueEventually(new AssertTask() {
@Override
public void run() throws Exception {
assertEquals(1, mapStore.size());
}
});
}
use of com.hazelcast.test.AssertTask in project hazelcast by hazelcast.
the class WriteBehindFlushTest method testWriteBehindQueues_flushed_onNodeShutdown.
@Test
public void testWriteBehindQueues_flushed_onNodeShutdown() throws Exception {
int nodeCount = 3;
String mapName = randomName();
TestHazelcastInstanceFactory factory = createHazelcastInstanceFactory(nodeCount);
MapStoreConfig mapStoreConfig = new MapStoreConfig();
final MapStoreWithCounter mapStore = new MapStoreWithCounter<Integer, String>();
mapStoreConfig.setImplementation(mapStore).setWriteDelaySeconds(3000);
Config config = getConfig();
config.getMapConfig(mapName).setBackupCount(0).setMapStoreConfig(mapStoreConfig);
HazelcastInstance member = factory.newHazelcastInstance(config);
factory.newHazelcastInstance(config);
factory.newHazelcastInstance(config);
IMap<Integer, Integer> map = member.getMap(mapName);
for (int i = 0; i < 1000; i++) {
map.put(i, i);
}
factory.shutdownAll();
assertTrueEventually(new AssertTask() {
@Override
public void run() throws Exception {
for (int i = 0; i < 1000; i++) {
assertEquals(i, mapStore.store.get(i));
}
}
});
}
use of com.hazelcast.test.AssertTask in project hazelcast by hazelcast.
the class WriteBehindFlushTest method testWriteBehindQueues_flushed_uponEviction.
@Test
public void testWriteBehindQueues_flushed_uponEviction() throws Exception {
int nodeCount = 3;
String mapName = randomName();
TestHazelcastInstanceFactory factory = createHazelcastInstanceFactory(nodeCount);
MapStoreConfig mapStoreConfig = new MapStoreConfig();
final MapStoreWithCounter mapStore = new MapStoreWithCounter<Integer, String>();
mapStoreConfig.setImplementation(mapStore).setWriteDelaySeconds(3000);
Config config = getConfig();
config.getMapConfig(mapName).setMapStoreConfig(mapStoreConfig);
HazelcastInstance node1 = factory.newHazelcastInstance(config);
HazelcastInstance node2 = factory.newHazelcastInstance(config);
HazelcastInstance node3 = factory.newHazelcastInstance(config);
IMap<Integer, Integer> map = node1.getMap(mapName);
for (int i = 0; i < 1000; i++) {
map.put(i, i);
}
for (int i = 0; i < 1000; i++) {
map.evict(i);
}
assertTrueEventually(new AssertTask() {
@Override
public void run() throws Exception {
assertEquals(1000, mapStore.countStore.get());
}
});
assertWriteBehindQueuesEmpty(mapName, asList(node1, node2, node3));
}
Aggregations