@Override public String getName() { return cache.getName(); }
void assertSize() { int size = cache.size(); if (size > max) { max = size; } if (size > estimatedMaxSize) { fail(name + ": cache " + cache.getName() + " toleranceFactor=" + toleranceFactor + " configuredMaxSize=" + configuredMaxSize + " estimatedMaxSize=" + estimatedMaxSize + " size=" + cache.size() ); } } }
@Setup public void setup() { value = new byte[valueSize]; Random random = new Random(); random.nextBytes(value); CacheManager cacheManager = createCacheManager(targetInstance); cache = (ICache<Object, Object>) cacheManager.getCache(name); CacheConfig<Object, Object> config = cache.getConfiguration(CacheConfig.class); logger.info(name + ": " + cache.getName() + " config: " + config); configuredMaxSize = config.getEvictionConfig().getSize(); // we are explicitly using a random key so that all participants of the test do not put keys 0...max // the size of putAllMap is not guarantied to be configuredMaxSize / 2 as keys are random for (int i = 0; i < configuredMaxSize / 2; i++) { putAllMap.put(random.nextInt(), value); } if (configuredMaxSize < 1000) { toleranceFactor = TOLERANCE_FACTOR_SMALL; } else if (configuredMaxSize < 10000) { toleranceFactor = TOLERANCE_FACTOR_MEDIUM; } else { toleranceFactor = TOLERANCE_FACTOR_LARGE; } estimatedMaxSize = (int) (configuredMaxSize * toleranceFactor); }
@Verify public void globalVerify() { IList<Integer> results = targetInstance.getList(name + "max"); int observedMaxSize = 0; for (int m : results) { if (observedMaxSize < m) { observedMaxSize = m; } } logger.info(name + ": cache " + cache.getName() + " toleranceFactor=" + toleranceFactor + " configuredMaxSize=" + configuredMaxSize + " estimatedMaxSize=" + estimatedMaxSize + " observedMaxSize=" + observedMaxSize + " size=" + cache.size() ); IList<Counter> counters = targetInstance.getList(name + "counter"); Counter total = new Counter(); for (Counter c : counters) { total.add(c); } logger.info(name + ": " + total); logger.info(name + ": putAllMap size=" + putAllMap.size()); }