Skip to content

Commit

Permalink
Harden Executor tests
Browse files Browse the repository at this point in the history
(merge ce/main -> ce/23.09 105346)

[git-p4: depot-paths = "//dev/coherence-ce/release/coherence-ce-v23.09/": change = 105348]
  • Loading branch information
thegridman committed Dec 12, 2023
1 parent e61297d commit 5cbd1f3
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* 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.
Expand All @@ -8,6 +8,7 @@

import com.oracle.coherence.concurrent.executor.util.Caches;

import com.tangosol.net.CacheService;
import executor.common.SingleClusterForAllTests;
import executor.common.Utils;

Expand All @@ -28,13 +29,17 @@ public abstract class AbstractCESSingleClusterTests
{
// ----- test lifecycle -------------------------------------------------

@SuppressWarnings("resource")
@Override
public void cleanup()
{
CacheService service = getCacheService();
if (service != null)
{
Caches.tasks(service).clear();
Caches.assignments(service).clear();
}
super.cleanup();

Caches.tasks(getCacheService()).clear();
Caches.assignments(getCacheService()).clear();
}

// ----- constructors ---------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@

import com.tangosol.io.Serializer;

import com.tangosol.net.CacheFactory;
import com.tangosol.net.CacheService;
import com.tangosol.net.ConfigurableCacheFactory;
import com.tangosol.net.NamedCache;
Expand Down Expand Up @@ -123,7 +124,7 @@
* @author lh
* @since 21.12
*/
@SuppressWarnings({"rawtypes", "unchecked"})
@SuppressWarnings({"rawtypes", "unchecked", "resource"})
public abstract class AbstractClusteredExecutorServiceTests
extends AbstractTaskExecutorServiceTests
{
Expand Down Expand Up @@ -182,6 +183,11 @@ public void setup()
public void cleanup()
{
String sMsg = ">>>>> Finished test: " + f_watcher.getMethodName();
if (m_cacheFactory != null && m_cacheFactory.isActive())
{
m_cacheFactory.dispose();
m_cacheFactory = null;
}
for (CoherenceClusterMember member : getCoherence().getCluster())
{
if (member != null)
Expand All @@ -201,6 +207,7 @@ public void cleanup()

Eventually.assertDeferred(() -> m_taskExecutorService.isShutdown(), is(true));
}
CacheFactory.shutdown();
}

// ----- contract -------------------------------------------------------
Expand Down Expand Up @@ -238,10 +245,12 @@ protected void initCluster()
clusterResource.getCluster();

// connect as an *Extend client
System.setProperty("coherence.client", "remote-fixed");
m_cacheFactory = clusterResource.createSession((
SessionBuilders.extendClient(m_extendConfig,
SystemProperty.of(EXECUTOR_LOGGING_PROPERTY, "true"),
SystemProperty.of("coherence.client", "remote-fixed"))));
m_cacheFactory.activate();
}

// ----- test methods ---------------------------------------------------
Expand Down Expand Up @@ -1443,7 +1452,8 @@ public static void ensureExecutorProxyAvailable(CoherenceCluster cluster)

public CacheService getCacheService()
{
return m_taskExecutorService.getCacheService();
return m_taskExecutorService == null
? null : m_taskExecutorService.getCacheService();
}

/**
Expand Down

0 comments on commit 5cbd1f3

Please sign in to comment.