Skip to content

Commit

Permalink
Bug 37467966 - [37355933->24.09.1] Build: CESJavaSingleClusterTests.s…
Browse files Browse the repository at this point in the history
…houldUseDefaultExecutor (merge ce/main -> ce/24.09 @ 113363)

[git-p4: depot-paths = "//dev/coherence-ce/release/coherence-ce-v24.09/": change = 113367]
  • Loading branch information
rlubke committed Jan 10, 2025
1 parent 2349e29 commit 899418a
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2000, 2024, Oracle and/or its affiliates.
* Copyright (c) 2000, 2025, Oracle and/or its affiliates.
*
* Licensed under the Universal Permissive License v 1.0 as shown at
* https://oss.oracle.com/licenses/upl.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2000, 2024, Oracle and/or its affiliates.
* Copyright (c) 2000, 2025, 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 @@ -25,28 +25,31 @@
import com.oracle.bedrock.runtime.options.StabilityPredicate;
import com.oracle.bedrock.testsupport.deferred.Eventually;

import com.tangosol.internal.net.metrics.MetricsHttpHelper;
import com.tangosol.discovery.NSLookup;

import com.tangosol.net.Coherence;

import executor.common.CoherenceClusterResource;
import executor.common.LogOutput;
import executor.common.SingleClusterForAllTests;
import executor.common.Utils;

import java.net.InetSocketAddress;
import java.net.URL;

import metrics.AbstractMetricsFunctionalTest;

import java.util.LinkedHashMap;
import java.util.Map;

import org.hamcrest.CoreMatchers;

import org.junit.BeforeClass;
import org.junit.ClassRule;
import org.junit.Test;

import org.junit.experimental.categories.Category;

import static com.oracle.bedrock.deferred.DeferredHelper.invoking;
import static org.hamcrest.Matchers.greaterThan;
import static org.hamcrest.CoreMatchers.is;

import static org.junit.Assert.fail;


Expand Down Expand Up @@ -97,18 +100,35 @@ public String getLabel()
public void shouldUseDefaultExecutor()
{
Utils.assertWithFailureAction(super::shouldUseDefaultExecutor, this::dumpExecutorCacheStates);
Utils.assertWithFailureAction(this::validateMetrics, this::dumpExecutorCacheStates);
}

// ----- helper methods -------------------------------------------------

protected void validateMetrics()
{
Eventually.assertDeferred(this::getCompletedMetricsAggregate, is(23L));
}

protected long getCompletedMetricsAggregate()
{
AbstractMetricsFunctionalTest metricsHelper = new AbstractMetricsFunctionalTest();
Map<String, String> tags = new LinkedHashMap<>();
long clInvoked = 0;

try
{
Eventually.assertThat(invoking(metricsHelper).getCacheMetric(s_metrics_port, "Coherence.Executor.TasksCompletedCount", tags), CoreMatchers.is(greaterThan(4L)));
for (URL url : NSLookup.lookupHTTPMetricsURL(new InetSocketAddress("127.0.0.1", 7778)))
{
clInvoked += metricsHelper.getCacheMetric(url.getPort(), TASK_COMP_COUNT_METRIC, tags);
}
}
catch (Exception e)
{
fail("Get Executor metrics failed with exception: " + e);
}

return clInvoked;
}

// ----- constants ------------------------------------------------------
Expand All @@ -117,7 +137,9 @@ public void shouldUseDefaultExecutor()

protected static final String METRICS_ENABLED_PROPERTY = "coherence.metrics.http.enabled";

protected static int s_metrics_port = MetricsHttpHelper.DEFAULT_PROMETHEUS_METRICS_PORT;
protected static final String METRICS_PORT_PROPERTY = "coherence.metrics.http.port";

protected static final String TASK_COMP_COUNT_METRIC = "Coherence.Executor.TasksCompletedCount";

// ----- data members ---------------------------------------------------

Expand All @@ -136,6 +158,7 @@ public void shouldUseDefaultExecutor()
ClusterName.of(CESJavaSingleClusterTests.class.getSimpleName()), // default name is too long
SystemProperty.of(EXTEND_ADDRESS_PROPERTY, EXTEND_HOST),
SystemProperty.of(EXTEND_PORT_PROPERTY, EXTEND_PORT),
SystemProperty.of(METRICS_PORT_PROPERTY, "0"),
JmxFeature.enabled(),
StabilityPredicate.of(CoherenceCluster.Predicates.isCoherenceRunning()))
.include(STORAGE_ENABLED_MEMBER_COUNT,
Expand All @@ -144,21 +167,23 @@ public void shouldUseDefaultExecutor()
RoleName.of(STORAGE_ENABLED_MEMBER_ROLE),
LocalStorage.enabled(),
SystemProperty.of(EXTEND_ENABLED_PROPERTY, false),
SystemProperty.of(METRICS_ENABLED_PROPERTY, true),
SystemProperty.of(EXECUTOR_LOGGING_PROPERTY, true))
.include(STORAGE_DISABLED_MEMBER_COUNT,
DisplayName.of("ComputeServer"),
LogOutput.to(CESJavaSingleClusterTests.class.getSimpleName(), "ComputeServer"),
RoleName.of(STORAGE_DISABLED_MEMBER_ROLE),
LocalStorage.disabled(),
SystemProperty.of(METRICS_ENABLED_PROPERTY, true),
SystemProperty.of(EXTEND_ENABLED_PROPERTY, false),
SystemProperty.of(METRICS_ENABLED_PROPERTY, true),
SystemProperty.of(EXECUTOR_LOGGING_PROPERTY, true))
.include(PROXY_MEMBER_COUNT,
DisplayName.of("ProxyServer"),
LogOutput.to(CESJavaSingleClusterTests.class.getSimpleName(), "ProxyServer"),
RoleName.of(PROXY_MEMBER_ROLE),
LocalStorage.disabled(),
SystemProperty.of(EXTEND_ENABLED_PROPERTY, true),
SystemProperty.of(METRICS_ENABLED_PROPERTY, true),
SystemProperty.of(EXECUTOR_LOGGING_PROPERTY, true));
}

0 comments on commit 899418a

Please sign in to comment.