Skip to content

Commit

Permalink
BUG 35575304 - Build: intermittent failures in cache.EvictionTests.te…
Browse files Browse the repository at this point in the history
…stExpirySliding and testQueryExpirySliding()

RQ: job.9.20230710174328.19407
(auto-submit integ 101638 main -> coherence-ce/main after successfully running remote remote.full)
Job ID: job.9.20230711155335.9899

[git-p4: depot-paths = "//dev/coherence-ce/main/": change = 101654]
  • Loading branch information
fryp committed Jul 11, 2023
1 parent 97e9f49 commit 4bbbeea
Showing 1 changed file with 35 additions and 28 deletions.
63 changes: 35 additions & 28 deletions prj/test/functional/cache/src/main/java/cache/EvictionTests.java
Original file line number Diff line number Diff line change
@@ -1,53 +1,58 @@
/*
* Copyright (c) 2000, 2022, Oracle and/or its affiliates.
* Copyright (c) 2000, 2023, Oracle and/or its affiliates.
*
* Licensed under the Universal Permissive License v 1.0 as shown at
* https://oss.oracle.com/licenses/upl.
*/
package cache;

import com.oracle.coherence.common.base.Converter;
import com.oracle.bedrock.runtime.coherence.CoherenceClusterMember;
import com.oracle.bedrock.runtime.coherence.ServiceStatus;
import com.oracle.bedrock.testsupport.deferred.Eventually;

import com.oracle.coherence.common.base.Converter;

import com.oracle.coherence.testing.AbstractFunctionalTest;

import com.tangosol.net.BackingMapManagerContext;
import com.tangosol.net.CacheFactory;
import com.tangosol.net.NamedCache;
import com.tangosol.net.PartitionedService;

import com.tangosol.net.partition.KeyAssociator;

import com.tangosol.util.Base;
import com.tangosol.util.BinaryEntry;
import com.tangosol.util.InvocableMap;
import com.tangosol.util.MapEvent;
import com.tangosol.util.MultiplexingMapListener;
import com.tangosol.util.ValueExtractor;

import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.TimeUnit;
import org.hamcrest.CoreMatchers;
import org.junit.After;
import org.junit.BeforeClass;
import org.junit.Test;

import com.tangosol.net.partition.KeyAssociator;

import com.tangosol.util.aggregator.DistinctValues;

import com.tangosol.util.extractor.ReflectionExtractor;

import com.tangosol.util.filter.AlwaysFilter;

import com.tangosol.util.processor.AbstractProcessor;
import data.Person;

import com.tangosol.util.extractor.ReflectionExtractor;
import data.Person;

import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;

import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.TimeUnit;

import org.hamcrest.CoreMatchers;

import org.junit.After;
import org.junit.BeforeClass;
import org.junit.Test;

import static com.oracle.bedrock.deferred.DeferredHelper.within;
import static com.oracle.bedrock.deferred.DeferredHelper.invoking;
import static org.hamcrest.Matchers.lessThanOrEqualTo;
Expand Down Expand Up @@ -172,8 +177,7 @@ public void COH16231RegressionTest()
*/
public void doActiveEvictionTest(NamedCache cache)
{
long cExpiry = 3000L;
long cSleep = 1000L;
long cSleep = 1000L;

// EvictionTask should be scheduled for cache with expiry configured.
ClientListener listener = new ClientListener();
Expand All @@ -192,7 +196,7 @@ public void doActiveEvictionTest(NamedCache cache)
cache.put(2, EvictionTests.VALUE, 1000L);
listener.assertDeleteEvent(2, true);

Base.sleep(cExpiry - cSleep + 250L);
Base.sleep(EXPIRY - cSleep + 250L);
listener.assertDeleteEvent(1, true);
assertNull(cache.get(1));
assertNull(cache.get(2));
Expand All @@ -203,12 +207,11 @@ public void doActiveEvictionTest(NamedCache cache)
*/
public void doExpirySlidingTest(NamedCache cache)
{
long cExpiry = 3000L;
long cSleep = 2000L;
long cSleep = EXPIRY/2;
int cSize = 10;
Map map = new HashMap();
Set setKeys = new HashSet();
Integer IPart = 100;

for (int i = 0; i < cSize; i++)
{
map.put(i, i);
Expand All @@ -219,15 +222,15 @@ public void doExpirySlidingTest(NamedCache cache)
cache.putAll(map);
Base.sleep(cSleep);
cache.get(1);
Base.sleep(cExpiry - cSleep + 250L);
Base.sleep(cSleep + (cSleep / 2));
assertEquals(1, cache.size());
cache.clear();

// all keys's expiry should be extended after the getAll call
// all keys' expiry should be extended after the getAll call
cache.putAll(map);
Base.sleep(cSleep);
cache.getAll(setKeys);
Base.sleep(cExpiry - cSleep + 250);
Base.sleep(cSleep + (cSleep / 2));
assertEquals(cSize, cache.size());
cache.clear();

Expand All @@ -238,7 +241,7 @@ public void doExpirySlidingTest(NamedCache cache)
Base.sleep(cSleep);
TestProcessor processor = new TestProcessor();
cache.invoke(1, processor);
Base.sleep(cExpiry - cSleep + 250L);
Base.sleep(cSleep + (cSleep / 2));
assertEquals(2, cache.size());
cache.clear();
cleanup();
Expand All @@ -249,8 +252,7 @@ public void doExpirySlidingTest(NamedCache cache)
*/
public void doQueryExpirySlidingTest(NamedCache cache)
{
long cExpiry = 3000L;
long cSleep = 1000L;
long cSleep = EXPIRY/2;
int cSize = 10;

ValueExtractor extractor = new ReflectionExtractor("getLastName");
Expand All @@ -262,12 +264,12 @@ public void doQueryExpirySlidingTest(NamedCache cache)
assertEquals(cSize, cache.size());
Base.sleep(cSleep);

// aggregate DOES NOT extend expiry
cache.aggregate(AlwaysFilter.INSTANCE, agent);

Base.sleep(cExpiry - cSleep + 250);
Base.sleep(cSleep + (cSleep / 2));
assertEquals(0, cache.size());
cache.clear();

cache.clear();
cleanup();
}

Expand Down Expand Up @@ -387,4 +389,9 @@ protected void onMapEvent(MapEvent evt)
* The value put into the cache.
*/
private final static String VALUE = "foo";

/**
* The expiry specified in the cache configuration.
*/
private final static long EXPIRY = 3_000L;
}

0 comments on commit 4bbbeea

Please sign in to comment.