Skip to content

Commit c5d7bc4

Browse files
committed
Enh 37136318 - Add a metrics test for Executor (main -> ce-main @112229)
[git-p4: depot-paths = "//dev/coherence-ce/main/": change = 112260]
1 parent a34d2e1 commit c5d7bc4

File tree

3 files changed

+57
-6
lines changed

3 files changed

+57
-6
lines changed

prj/test/functional/executor/pom.xml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<!--
3-
Copyright (c) 2000, 2022, Oracle and/or its affiliates.
3+
Copyright (c) 2000, 2024, Oracle and/or its affiliates.
44
55
Licensed under the Universal Permissive License v 1.0 as shown at
66
https://oss.oracle.com/licenses/upl.
@@ -40,6 +40,12 @@
4040
<artifactId>coherence-testing-support</artifactId>
4141
<version>${project.version}</version>
4242
</dependency>
43+
<dependency>
44+
<groupId>com.oracle.coherence.ce.tests</groupId>
45+
<artifactId>metrics</artifactId>
46+
<version>${project.version}</version>
47+
<scope>compile</scope>
48+
</dependency>
4349

4450
<dependency>
4551
<groupId>org.glassfish.jersey.core</groupId>

prj/test/functional/executor/src/main/java/executor/CESJavaSingleClusterTests.java

Lines changed: 43 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2000, 2023, Oracle and/or its affiliates.
2+
* Copyright (c) 2000, 2024, Oracle and/or its affiliates.
33
*
44
* Licensed under the Universal Permissive License v 1.0 as shown at
55
* https://oss.oracle.com/licenses/upl.
@@ -18,25 +18,38 @@
1818
import com.oracle.bedrock.runtime.coherence.options.RoleName;
1919

2020
import com.oracle.bedrock.runtime.java.features.JmxFeature;
21-
2221
import com.oracle.bedrock.runtime.java.options.ClassName;
2322
import com.oracle.bedrock.runtime.java.options.SystemProperty;
2423

2524
import com.oracle.bedrock.runtime.options.DisplayName;
26-
2725
import com.oracle.bedrock.runtime.options.StabilityPredicate;
26+
import com.oracle.bedrock.testsupport.deferred.Eventually;
27+
28+
import com.tangosol.internal.net.metrics.MetricsHttpHelper;
2829
import com.tangosol.net.Coherence;
2930

3031
import executor.common.CoherenceClusterResource;
3132
import executor.common.LogOutput;
3233
import executor.common.SingleClusterForAllTests;
34+
import executor.common.Utils;
35+
36+
import metrics.AbstractMetricsFunctionalTest;
37+
38+
import java.util.LinkedHashMap;
39+
import java.util.Map;
40+
41+
import org.hamcrest.CoreMatchers;
3342

34-
import org.junit.AfterClass;
3543
import org.junit.BeforeClass;
3644
import org.junit.ClassRule;
37-
45+
import org.junit.Test;
3846
import org.junit.experimental.categories.Category;
3947

48+
import static com.oracle.bedrock.deferred.DeferredHelper.invoking;
49+
import static org.hamcrest.Matchers.greaterThan;
50+
import static org.junit.Assert.fail;
51+
52+
4053
/**
4154
* Tests will spin up a cluster shared by each test using java as the serialization
4255
* format.
@@ -78,10 +91,34 @@ public String getLabel()
7891
return CESJavaSingleClusterTests.class.getSimpleName();
7992
}
8093

94+
// Add Executor metrics verification.
95+
@Override
96+
@Test(timeout = 300000) // timeout after five minutes
97+
public void shouldUseDefaultExecutor()
98+
{
99+
Utils.assertWithFailureAction(super::shouldUseDefaultExecutor, this::dumpExecutorCacheStates);
100+
101+
AbstractMetricsFunctionalTest metricsHelper = new AbstractMetricsFunctionalTest();
102+
Map<String, String> tags = new LinkedHashMap<>();
103+
104+
try
105+
{
106+
Eventually.assertThat(invoking(metricsHelper).getCacheMetric(s_metrics_port, "Coherence.Executor.TasksCompletedCount", tags), CoreMatchers.is(greaterThan(4L)));
107+
}
108+
catch (Exception e)
109+
{
110+
fail("Get Executor metrics failed with exception: " + e);
111+
}
112+
}
113+
81114
// ----- constants ------------------------------------------------------
82115

83116
protected static final String EXTEND_CONFIG = "coherence-concurrent-client-config.xml";
84117

118+
protected static final String METRICS_ENABLED_PROPERTY = "coherence.metrics.http.enabled";
119+
120+
protected static int s_metrics_port = MetricsHttpHelper.DEFAULT_PROMETHEUS_METRICS_PORT;
121+
85122
// ----- data members ---------------------------------------------------
86123

87124
/**
@@ -113,6 +150,7 @@ public String getLabel()
113150
LogOutput.to(CESJavaSingleClusterTests.class.getSimpleName(), "ComputeServer"),
114151
RoleName.of(STORAGE_DISABLED_MEMBER_ROLE),
115152
LocalStorage.disabled(),
153+
SystemProperty.of(METRICS_ENABLED_PROPERTY, true),
116154
SystemProperty.of(EXTEND_ENABLED_PROPERTY, false),
117155
SystemProperty.of(EXECUTOR_LOGGING_PROPERTY, true))
118156
.include(PROXY_MEMBER_COUNT,

prj/test/functional/metrics/src/main/java/metrics/AbstractMetricsFunctionalTest.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,13 @@ public class AbstractMetricsFunctionalTest extends AbstractFunctionalTest
3232
{
3333
// ----- constructors ---------------------------------------------------
3434

35+
/**
36+
* Default constructor
37+
*/
38+
public AbstractMetricsFunctionalTest()
39+
{
40+
}
41+
3542
/**
3643
* Constructor that initializes cluster member configuration file.
3744
*

0 commit comments

Comments
 (0)