use of org.junit.experimental.categories.Category in project hazelcast by hazelcast.
the class EvictionTest method testExpiration_onBackupPartitions_whenPuttingWithTTL.
@Test
@Category(NightlyTest.class)
public void testExpiration_onBackupPartitions_whenPuttingWithTTL() throws Exception {
String mapName = randomMapName();
TestHazelcastInstanceFactory factory = createHazelcastInstanceFactory(2);
HazelcastInstance[] nodes = factory.newInstances(getConfig());
IMap<Integer, Integer> map = nodes[0].getMap(mapName);
// 1. put keys with TTL.
for (int i = 0; i < 60; i++) {
map.put(i, i, 5, TimeUnit.SECONDS);
}
// 2. Shutdown one node.
// Since we want to see previous backup partitions as owners.
nodes[1].shutdown();
// 3. Background task should sweep all keys.
assertSizeEventually(0, map, 240);
}
use of org.junit.experimental.categories.Category in project hazelcast by hazelcast.
the class WriteBehindOnBackupsTest method testPutTransientDoesNotStoreEntry_onPromotedReplica.
@Test
@Category(SlowTest.class)
public void testPutTransientDoesNotStoreEntry_onPromotedReplica() {
String mapName = randomMapName();
final MapStoreWithCounter<String, Object> mapStore = new MapStoreWithCounter<String, Object>();
TestMapUsingMapStoreBuilder<String, Object> storeBuilder = TestMapUsingMapStoreBuilder.create();
TestHazelcastInstanceFactory factory = createHazelcastInstanceFactory(2);
final IMap<String, Object> map = storeBuilder.mapName(mapName).withMapStore(mapStore).withNodeCount(2).withNodeFactory(factory).withWriteDelaySeconds(5).withBackupCount(1).withPartitionCount(1).withBackupProcessingDelay(1).build();
String key = UUID.randomUUID().toString();
map.putTransient(key, 1, 1, TimeUnit.DAYS);
killKeyOwner(key, storeBuilder);
sleepSeconds(10);
assertEquals("There should not be any store operation on promoted replica", 0, mapStore.countStore.get());
}
use of org.junit.experimental.categories.Category in project hazelcast by hazelcast.
the class MapStoreWriteBehindTest method testWriteBehindDestroy.
@Test(timeout = 120000)
@Category(NightlyTest.class)
public // issue #2747: when MapStore configured with write behind, distributed objects' destroy method does not work
void testWriteBehindDestroy() throws InterruptedException {
final int writeDelaySeconds = 5;
String mapName = randomMapName();
final MapStore<String, String> store = new SimpleMapStore<String, String>();
Config config = newConfig(mapName, store, writeDelaySeconds);
HazelcastInstance hzInstance = createHazelcastInstance(config);
IMap<String, String> map = hzInstance.getMap(mapName);
map.put("key", "value");
map.destroy();
sleepSeconds(2 * writeDelaySeconds);
assertNotEquals("value", store.load("key"));
}
use of org.junit.experimental.categories.Category in project hazelcast by hazelcast.
the class TopicTest method testTopicMultiThreading.
@Test
@Category(NightlyTest.class)
@SuppressWarnings("unchecked")
public void testTopicMultiThreading() throws Exception {
final int nodeCount = 5;
final int count = 1000;
final String randomTopicName = randomString();
Config config = new Config();
config.getTopicConfig(randomTopicName).setGlobalOrderingEnabled(false);
config.getTopicConfig(randomTopicName).setMultiThreadingEnabled(true);
TestHazelcastInstanceFactory factory = createHazelcastInstanceFactory(nodeCount);
final HazelcastInstance[] instances = factory.newInstances(config);
final Set<String>[] threads = new Set[nodeCount];
for (int i = 0; i < nodeCount; i++) {
threads[i] = new HashSet<String>();
}
final CountDownLatch startLatch = new CountDownLatch(nodeCount);
final CountDownLatch messageLatch = new CountDownLatch(nodeCount * nodeCount * count);
final CountDownLatch publishLatch = new CountDownLatch(nodeCount * count);
ExecutorService ex = Executors.newFixedThreadPool(nodeCount);
for (int i = 0; i < nodeCount; i++) {
final int finalI = i;
ex.execute(new Runnable() {
public void run() {
final Set<String> thNames = threads[finalI];
HazelcastInstance hz = instances[finalI];
ITopic<TestMessage> topic = hz.getTopic(randomTopicName);
topic.addMessageListener(new MessageListener<TestMessage>() {
public void onMessage(Message<TestMessage> message) {
thNames.add(Thread.currentThread().getName());
messageLatch.countDown();
}
});
startLatch.countDown();
try {
startLatch.await(1, TimeUnit.MINUTES);
} catch (InterruptedException e) {
e.printStackTrace();
return;
}
Member localMember = hz.getCluster().getLocalMember();
for (int j = 0; j < count; j++) {
topic.publish(new TestMessage(localMember, UuidUtil.newUnsecureUuidString()));
publishLatch.countDown();
}
}
});
}
try {
assertTrue(publishLatch.await(2, TimeUnit.MINUTES));
assertTrue(messageLatch.await(5, TimeUnit.MINUTES));
boolean passed = false;
for (int i = 0; i < nodeCount; i++) {
if (threads[i].size() > 1) {
passed = true;
}
}
assertTrue("All listeners received messages in single thread. Expecting more threads involved", passed);
} finally {
ex.shutdownNow();
}
}
use of org.junit.experimental.categories.Category in project beam by apache.
the class GroupByKeyTest method testTimestampCombinerLatest.
/**
* Tests that when two elements are combined via a GroupByKey their output timestamp agrees
* with the windowing function customized to use the latest value.
*/
@Test
@Category(ValidatesRunner.class)
public void testTimestampCombinerLatest() {
p.apply(Create.timestamped(TimestampedValue.of(KV.of(0, "hello"), new Instant(0)), TimestampedValue.of(KV.of(0, "goodbye"), new Instant(10)))).apply(Window.<KV<Integer, String>>into(FixedWindows.of(Duration.standardMinutes(10))).withTimestampCombiner(TimestampCombiner.LATEST)).apply(GroupByKey.<Integer, String>create()).apply(ParDo.of(new AssertTimestamp(new Instant(10))));
p.run();
}
Aggregations