com.hazelcast.simulator.tests.icache.EvictionICacheTest Maven / Gradle / Ivy
/*
* 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.config.CacheConfig;
import com.hazelcast.core.IList;
import com.hazelcast.simulator.test.AbstractTest;
import com.hazelcast.simulator.test.annotations.RunWithWorker;
import com.hazelcast.simulator.test.annotations.Setup;
import com.hazelcast.simulator.test.annotations.Verify;
import com.hazelcast.simulator.worker.selector.OperationSelectorBuilder;
import com.hazelcast.simulator.worker.tasks.AbstractWorker;
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.EvictionICacheTest.Operation.PUT;
import static com.hazelcast.simulator.tests.icache.EvictionICacheTest.Operation.PUT_ALL;
import static com.hazelcast.simulator.tests.icache.EvictionICacheTest.Operation.PUT_ASYNC;
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 AbstractTest {
enum Operation {
PUT,
PUT_ASYNC,
PUT_ALL,
}
public int partitionCount;
// number of bytes for the value/payload of a key
public int valueSize = 2;
public double putProb = 0.8;
public double putAsyncProb = 0.1;
public double putAllProb = 0.1;
private byte[] value;
private ICache © 2015 - 2025 Weber Informatics LLC | Privacy Policy