com.hazelcast.simulator.tests.icache.EvictionICacheTest Maven / Gradle / Ivy
The newest version!
/*
* Copyright (c) 2008-2016, Hazelcast, Inc. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.hazelcast.simulator.tests.icache;
import com.hazelcast.cache.ICache;
import com.hazelcast.collection.IList;
import com.hazelcast.config.CacheConfig;
import com.hazelcast.simulator.hz.HazelcastTest;
import com.hazelcast.simulator.test.BaseThreadState;
import com.hazelcast.simulator.test.annotations.AfterRun;
import com.hazelcast.simulator.test.annotations.Setup;
import com.hazelcast.simulator.test.annotations.TimeStep;
import com.hazelcast.simulator.test.annotations.Verify;
import javax.cache.CacheManager;
import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;
import java.util.Random;
import static com.hazelcast.simulator.tests.icache.helpers.CacheUtils.createCacheManager;
import static org.junit.Assert.fail;
/**
* This test is expecting to work with an ICache which has a max-size policy and an eviction-policy
* defined. The run body of the test simply puts random key value pairs to the ICache, and checks
* the size of the ICache has not grown above the defined max size + a configurable size margin.
* As the max-size policy is not a hard limit we use a configurable size margin in the verification
* of the cache size. The test also logs the global max size of the ICache observed from all test
* participants, providing no assertion errors were throw.
*/
public class EvictionICacheTest extends HazelcastTest {
private static final double TOLERANCE_FACTOR_SMALL = 6.5;
private static final double TOLERANCE_FACTOR_MEDIUM = 4.0;
private static final double TOLERANCE_FACTOR_LARGE = 1.5;
// number of bytes for the value/payload of a key
public int valueSize = 2;
private Map putAllMap = new HashMap<>();
private byte[] value;
private ICache © 2015 - 2025 Weber Informatics LLC | Privacy Policy