Skip to content

Commit

Permalink
ISPN-8176 RemoteCacheStoreIT.testReadOnly random failures
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanemerson authored and tristantarrant committed Aug 8, 2017
1 parent b0e0862 commit 87844d4
Showing 1 changed file with 21 additions and 7 deletions.
Expand Up @@ -3,6 +3,9 @@
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;

import java.util.HashSet;
import java.util.Set;

import org.infinispan.arquillian.core.InfinispanResource;
import org.infinispan.arquillian.core.RemoteInfinispanServer;
import org.infinispan.arquillian.core.RunningServer;
Expand Down Expand Up @@ -76,15 +79,26 @@ public void testReadOnly() throws Exception {
.getHotrodEndpoint().getPort()).build();
rcm1 = new RemoteCacheManager(conf);
RemoteCache<String, String> rc1 = rcm1.getCache(READONLY_CACHE_NAME);
// put 3 keys, k1 is evicted, but not stored
rc1.put("k1", "v1");
rc1.put("k2", "v2");
rc1.put("k3", "v3");
// put 3 keys, one entry is evicted, but not stored
Set<String> allKeys = new HashSet<>();
for (int i = 1; i < 4; i++) {
String key = "k"+i;
rc1.put(key, "v"+i);
allKeys.add(key);
}
assertEquals(0, server2.getCacheManager(LOCAL_CACHE_MANAGER).getDefaultCache().getNumberOfEntriesInMemory());
assertEquals(2, server1.getCacheManager(LOCAL_CACHE_MANAGER).getCache(READONLY_CACHE_NAME).getNumberOfEntries());
assertEquals(2, server1.getCacheManager(LOCAL_CACHE_MANAGER).getCache(READONLY_CACHE_NAME).getNumberOfEntriesInMemory());
assertNull(rc1.get("k1"));
assertEquals("v2", rc1.get("k2"));
assertEquals("v3", rc1.get("k3"));

Set<String> storedKeys = rc1.keySet();
allKeys.removeAll(storedKeys);
for (String key : allKeys)
assertNull(rc1.get(key));

for (String key : storedKeys) {
int i = Integer.parseInt(key.substring(1));
assertEquals("v"+i, rc1.get(key));
}
}

/*
Expand Down

0 comments on commit 87844d4

Please sign in to comment.