Skip to content

Commit 35f9bbd

Browse files
authored
IGNITE-27179 Fixed flaky the CommunicationConnectionPoolMetricsTest#testMetricsBasics test (#12538)
Thank you for submitting the pull request to the Apache Ignite. In order to streamline the review of the contribution we ask you to ensure the following steps have been taken: ### The Contribution Checklist - [ ] There is a single JIRA ticket related to the pull request. - [ ] The web-link to the pull request is attached to the JIRA ticket. - [ ] The JIRA ticket has the _Patch Available_ state. - [ ] The pull request body describes changes that have been made. The description explains _WHAT_ and _WHY_ was made instead of _HOW_. - [ ] The pull request title is treated as the final commit message. The following pattern must be used: `IGNITE-XXXX Change summary` where `XXXX` - number of JIRA issue. - [ ] A reviewer has been mentioned through the JIRA comments (see [the Maintainers list](https://cwiki.apache.org/confluence/display/IGNITE/How+to+Contribute#HowtoContribute-ReviewProcessandMaintainers)) - [ ] The pull request has been checked by the Teamcity Bot and the `green visa` attached to the JIRA ticket (see [TC.Bot: Check PR](https://mtcga.gridgain.com/prs.html)) ### Notes - [How to Contribute](https://cwiki.apache.org/confluence/display/IGNITE/How+to+Contribute) - [Coding abbreviation rules](https://cwiki.apache.org/confluence/display/IGNITE/Abbreviation+Rules) - [Coding Guidelines](https://cwiki.apache.org/confluence/display/IGNITE/Coding+Guidelines) - [Apache Ignite Teamcity Bot](https://cwiki.apache.org/confluence/display/IGNITE/Apache+Ignite+Teamcity+Bot) If you need any help, please email [email protected] or ask anу advice on http://asf.slack.com _#ignite_ channel.
1 parent 110886e commit 35f9bbd

File tree

3 files changed

+22
-13
lines changed

3 files changed

+22
-13
lines changed

docs/_docs/monitoring-metrics/custom-metrics.adoc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@
1616

1717
WARNING: This feature is experimental and may change in future releases.
1818

19-
Ignite provides various internal link:monitoring-metrics/new-metrics.adoc[metrics]. However, these metrics might
19+
Ignite provides various internal link:monitoring-metrics/new-metrics[metrics]. However, these metrics might
2020
not be enough. Users can design and publish their own custom metrics. Custom Metrics are based on
21-
link:monitoring-metrics/new-metrics-system.adoc[Metric System].
21+
link:monitoring-metrics/new-metrics-system[Metric System].
2222

2323
[NOTE]
2424
====

modules/core/src/main/java/org/apache/ignite/spi/communication/tcp/internal/ConnectionClientPool.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -631,8 +631,7 @@ public void addNodeClient(ClusterNode node, int connIdx, GridCommunicationClient
631631
curClients = clients.compute(node.id(), (nodeId0, clients0) -> {
632632
if (clients0 == null) {
633633
// Syncs metrics creation on this map.
634-
if (metricsMgr != null)
635-
createNodeMetrics(node);
634+
createNodeMetrics(node);
636635

637636
return newClients;
638637
}
@@ -737,7 +736,7 @@ private NodeMetrics updatedNodeMetrics(UUID nodeId) {
737736
return clients;
738737
});
739738
}
740-
else {
739+
else if (res != null) {
741740
removeNodeMetrics(nodeId);
742741

743742
res = null;

modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/CommunicationConnectionPoolMetricsTest.java

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -241,8 +241,8 @@ public void testMetricsBasics() throws Exception {
241241

242242
Ignite ldr = clientLdr ? cli : srvr;
243243

244-
GridMetricManager metricsMgr = ((IgniteEx)ldr).context().metric();
245-
MetricRegistryImpl mreg0 = metricsMgr.registry(ConnectionClientPool.SHARED_METRICS_REGISTRY_NAME);
244+
GridMetricManager ldrMetricsMgr = ((IgniteEx)ldr).context().metric();
245+
MetricRegistryImpl mreg0 = ldrMetricsMgr.registry(ConnectionClientPool.SHARED_METRICS_REGISTRY_NAME);
246246

247247
assertEquals(connsPerNode, mreg0.<IntMetric>findMetric(ConnectionClientPool.METRIC_NAME_POOL_SIZE).value());
248248
assertEquals(pairedConns, mreg0.<BooleanGauge>findMetric(ConnectionClientPool.METRIC_NAME_PAIRED_CONNS).value());
@@ -271,7 +271,7 @@ public void testMetricsBasics() throws Exception {
271271

272272
UUID nodeId = node.cluster().localNode().id();
273273

274-
MetricRegistryImpl mreg = metricsMgr.registry(nodeMetricsRegName(nodeId));
274+
MetricRegistryImpl mreg = ldrMetricsMgr.registry(nodeMetricsRegName(nodeId));
275275

276276
// We assume that entire pool was used at least once.
277277
assertTrue(waitForCondition(() -> connsPerNode == mreg.<IntMetric>findMetric(METRIC_NAME_CUR_CNT).value(),
@@ -295,6 +295,10 @@ public void testMetricsBasics() throws Exception {
295295

296296
dumpMetrics(ldr);
297297

298+
// Stop the loading, free the messages queue to prevent the connection recreation attempts.
299+
runFlag.set(false);
300+
loadFut.get(getTestTimeout());
301+
298302
// Check node metrics are cleared if a node stops.
299303
for (Ignite node : G.allGrids()) {
300304
if (node == ldr)
@@ -306,18 +310,24 @@ public void testMetricsBasics() throws Exception {
306310

307311
UUID nodeId = node.cluster().localNode().id();
308312

309-
assertTrue(G.stop(node.name(), true));
313+
// Wait until there is no messages to this node.
314+
assertTrue(waitForCondition(() -> {
315+
MetricRegistryImpl mreg = ldrMetricsMgr.registry(nodeMetricsRegName(nodeId));
316+
317+
assert mreg != null;
318+
319+
return mreg.<IntMetric>findMetric(METRIC_NAME_MSG_QUEUE_SIZE).value() == 0;
320+
}, getTestTimeout(), 100));
321+
322+
assertTrue(G.stop(node.name(), false));
310323

311324
assertTrue(waitForCondition(() -> {
312-
MetricRegistryImpl mreg = metricsMgr.registry(nodeMetricsRegName(nodeId));
325+
MetricRegistryImpl mreg = ldrMetricsMgr.registry(nodeMetricsRegName(nodeId));
313326

314327
return mreg == null || !mreg.iterator().hasNext();
315328
}, getTestTimeout()));
316329
}
317330

318-
runFlag.set(false);
319-
loadFut.get(getTestTimeout());
320-
321331
// Ensure that all the possible nodes are stopped.
322332
assertTrue(waitForCondition(() -> ldr.cluster().nodes().size() == (clientLdr ? 2 : 1), getTestTimeout()));
323333
}

0 commit comments

Comments
 (0)