1
1
/*
2
- * Copyright (c) 2000, 2024 , Oracle and/or its affiliates.
2
+ * Copyright (c) 2000, 2025 , Oracle and/or its affiliates.
3
3
*
4
4
* Licensed under the Universal Permissive License v 1.0 as shown at
5
5
* https://oss.oracle.com/licenses/upl.
25
25
import com .oracle .bedrock .runtime .options .StabilityPredicate ;
26
26
import com .oracle .bedrock .testsupport .deferred .Eventually ;
27
27
28
- import com .tangosol .internal .net .metrics .MetricsHttpHelper ;
28
+ import com .tangosol .discovery .NSLookup ;
29
+
29
30
import com .tangosol .net .Coherence ;
30
31
31
32
import executor .common .CoherenceClusterResource ;
32
33
import executor .common .LogOutput ;
33
34
import executor .common .SingleClusterForAllTests ;
34
35
import executor .common .Utils ;
35
36
37
+ import java .net .InetSocketAddress ;
38
+ import java .net .URL ;
39
+
36
40
import metrics .AbstractMetricsFunctionalTest ;
37
41
38
42
import java .util .LinkedHashMap ;
39
43
import java .util .Map ;
40
44
41
- import org .hamcrest .CoreMatchers ;
42
-
43
45
import org .junit .BeforeClass ;
44
46
import org .junit .ClassRule ;
45
47
import org .junit .Test ;
48
+
46
49
import org .junit .experimental .categories .Category ;
47
50
48
- import static com . oracle . bedrock . deferred . DeferredHelper . invoking ;
49
- import static org . hamcrest . Matchers . greaterThan ;
51
+ import static org . hamcrest . CoreMatchers . is ;
52
+
50
53
import static org .junit .Assert .fail ;
51
54
52
55
@@ -97,18 +100,35 @@ public String getLabel()
97
100
public void shouldUseDefaultExecutor ()
98
101
{
99
102
Utils .assertWithFailureAction (super ::shouldUseDefaultExecutor , this ::dumpExecutorCacheStates );
103
+ Utils .assertWithFailureAction (this ::validateMetrics , this ::dumpExecutorCacheStates );
104
+ }
105
+
106
+ // ----- helper methods -------------------------------------------------
100
107
108
+ protected void validateMetrics ()
109
+ {
110
+ Eventually .assertDeferred (this ::getCompletedMetricsAggregate , is (23L ));
111
+ }
112
+
113
+ protected long getCompletedMetricsAggregate ()
114
+ {
101
115
AbstractMetricsFunctionalTest metricsHelper = new AbstractMetricsFunctionalTest ();
102
116
Map <String , String > tags = new LinkedHashMap <>();
117
+ long clInvoked = 0 ;
103
118
104
119
try
105
120
{
106
- Eventually .assertThat (invoking (metricsHelper ).getCacheMetric (s_metrics_port , "Coherence.Executor.TasksCompletedCount" , tags ), CoreMatchers .is (greaterThan (4L )));
121
+ for (URL url : NSLookup .lookupHTTPMetricsURL (new InetSocketAddress ("127.0.0.1" , 7778 )))
122
+ {
123
+ clInvoked += metricsHelper .getCacheMetric (url .getPort (), TASK_COMP_COUNT_METRIC , tags );
124
+ }
107
125
}
108
126
catch (Exception e )
109
127
{
110
128
fail ("Get Executor metrics failed with exception: " + e );
111
129
}
130
+
131
+ return clInvoked ;
112
132
}
113
133
114
134
// ----- constants ------------------------------------------------------
@@ -117,7 +137,9 @@ public void shouldUseDefaultExecutor()
117
137
118
138
protected static final String METRICS_ENABLED_PROPERTY = "coherence.metrics.http.enabled" ;
119
139
120
- protected static int s_metrics_port = MetricsHttpHelper .DEFAULT_PROMETHEUS_METRICS_PORT ;
140
+ protected static final String METRICS_PORT_PROPERTY = "coherence.metrics.http.port" ;
141
+
142
+ protected static final String TASK_COMP_COUNT_METRIC = "Coherence.Executor.TasksCompletedCount" ;
121
143
122
144
// ----- data members ---------------------------------------------------
123
145
@@ -136,6 +158,7 @@ public void shouldUseDefaultExecutor()
136
158
ClusterName .of (CESJavaSingleClusterTests .class .getSimpleName ()), // default name is too long
137
159
SystemProperty .of (EXTEND_ADDRESS_PROPERTY , EXTEND_HOST ),
138
160
SystemProperty .of (EXTEND_PORT_PROPERTY , EXTEND_PORT ),
161
+ SystemProperty .of (METRICS_PORT_PROPERTY , "0" ),
139
162
JmxFeature .enabled (),
140
163
StabilityPredicate .of (CoherenceCluster .Predicates .isCoherenceRunning ()))
141
164
.include (STORAGE_ENABLED_MEMBER_COUNT ,
@@ -144,21 +167,23 @@ public void shouldUseDefaultExecutor()
144
167
RoleName .of (STORAGE_ENABLED_MEMBER_ROLE ),
145
168
LocalStorage .enabled (),
146
169
SystemProperty .of (EXTEND_ENABLED_PROPERTY , false ),
170
+ SystemProperty .of (METRICS_ENABLED_PROPERTY , true ),
147
171
SystemProperty .of (EXECUTOR_LOGGING_PROPERTY , true ))
148
172
.include (STORAGE_DISABLED_MEMBER_COUNT ,
149
173
DisplayName .of ("ComputeServer" ),
150
174
LogOutput .to (CESJavaSingleClusterTests .class .getSimpleName (), "ComputeServer" ),
151
175
RoleName .of (STORAGE_DISABLED_MEMBER_ROLE ),
152
176
LocalStorage .disabled (),
153
- SystemProperty .of (METRICS_ENABLED_PROPERTY , true ),
154
177
SystemProperty .of (EXTEND_ENABLED_PROPERTY , false ),
178
+ SystemProperty .of (METRICS_ENABLED_PROPERTY , true ),
155
179
SystemProperty .of (EXECUTOR_LOGGING_PROPERTY , true ))
156
180
.include (PROXY_MEMBER_COUNT ,
157
181
DisplayName .of ("ProxyServer" ),
158
182
LogOutput .to (CESJavaSingleClusterTests .class .getSimpleName (), "ProxyServer" ),
159
183
RoleName .of (PROXY_MEMBER_ROLE ),
160
184
LocalStorage .disabled (),
161
185
SystemProperty .of (EXTEND_ENABLED_PROPERTY , true ),
186
+ SystemProperty .of (METRICS_ENABLED_PROPERTY , true ),
162
187
SystemProperty .of (EXECUTOR_LOGGING_PROPERTY , true ));
163
188
}
164
189
0 commit comments