ibessonov commented on code in PR #7361:
URL: https://github.com/apache/ignite-3/pull/7361#discussion_r2740614774


##########
modules/raft/src/integrationTest/java/org/apache/ignite/raft/ItRaftMetricTest.java:
##########
@@ -0,0 +1,92 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.raft;
+
+import static java.util.List.of;
+import static 
org.apache.ignite.internal.ClusterPerTestIntegrationTest.aggressiveLowWatermarkIncreaseClusterConfig;
+import static 
org.apache.ignite.internal.TestMetricUtils.testMetricChangeAfterOperation;
+import static org.apache.ignite.internal.TestWrappers.unwrapIgniteImpl;
+import static 
org.apache.ignite.internal.metrics.sources.RaftMetricSource.RAFT_GROUP_LEADERS;
+import static 
org.apache.ignite.internal.metrics.sources.RaftMetricSource.SOURCE_NAME;
+import static org.awaitility.Awaitility.await;
+
+import org.apache.ignite.InitParametersBuilder;
+import org.apache.ignite.internal.ClusterPerClassIntegrationTest;
+import org.apache.ignite.internal.metrics.sources.RaftMetricSource;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+/** Tests for {@link RaftMetricSource}. */
+public class ItRaftMetricTest extends ClusterPerClassIntegrationTest {
+    private static final String ZONE_NAME = "TEST_ZONE";
+
+    @Override
+    protected void configureInitParameters(InitParametersBuilder builder) {
+        // To trigger zone's raft partitions destruction.
+        
builder.clusterConfiguration(aggressiveLowWatermarkIncreaseClusterConfig());
+    }
+
+    @BeforeEach
+    void setUp() {
+        dropTableAndZone();
+    }
+
+    @Test
+    void testLeaderCountIncreases() {
+        testMetricChangeAfterOperation(
+                CLUSTER,
+                SOURCE_NAME,
+                of(RAFT_GROUP_LEADERS),
+                of((long) DEFAULT_PARTITION_COUNT),
+                ItRaftMetricTest::createZoneAndTable
+        );
+    }
+
+    @Test
+    void testLeaderCountDecreases() {
+        createZoneAndTable();
+
+        testMetricChangeAfterOperation(
+                CLUSTER,
+                SOURCE_NAME,
+                of(RAFT_GROUP_LEADERS),
+                of((long) -DEFAULT_PARTITION_COUNT),

Review Comment:
   Please don't use static imports for `List.of`, it looks ugly.



##########
modules/raft/src/integrationTest/java/org/apache/ignite/raft/ItRaftMetricTest.java:
##########
@@ -0,0 +1,92 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.raft;
+
+import static java.util.List.of;
+import static 
org.apache.ignite.internal.ClusterPerTestIntegrationTest.aggressiveLowWatermarkIncreaseClusterConfig;
+import static 
org.apache.ignite.internal.TestMetricUtils.testMetricChangeAfterOperation;
+import static org.apache.ignite.internal.TestWrappers.unwrapIgniteImpl;
+import static 
org.apache.ignite.internal.metrics.sources.RaftMetricSource.RAFT_GROUP_LEADERS;
+import static 
org.apache.ignite.internal.metrics.sources.RaftMetricSource.SOURCE_NAME;
+import static org.awaitility.Awaitility.await;
+
+import org.apache.ignite.InitParametersBuilder;
+import org.apache.ignite.internal.ClusterPerClassIntegrationTest;
+import org.apache.ignite.internal.metrics.sources.RaftMetricSource;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+/** Tests for {@link RaftMetricSource}. */
+public class ItRaftMetricTest extends ClusterPerClassIntegrationTest {
+    private static final String ZONE_NAME = "TEST_ZONE";
+
+    @Override
+    protected void configureInitParameters(InitParametersBuilder builder) {
+        // To trigger zone's raft partitions destruction.
+        
builder.clusterConfiguration(aggressiveLowWatermarkIncreaseClusterConfig());
+    }
+
+    @BeforeEach
+    void setUp() {
+        dropTableAndZone();
+    }
+
+    @Test
+    void testLeaderCountIncreases() {
+        testMetricChangeAfterOperation(
+                CLUSTER,
+                SOURCE_NAME,
+                of(RAFT_GROUP_LEADERS),
+                of((long) DEFAULT_PARTITION_COUNT),
+                ItRaftMetricTest::createZoneAndTable
+        );
+    }
+
+    @Test
+    void testLeaderCountDecreases() {
+        createZoneAndTable();
+
+        testMetricChangeAfterOperation(
+                CLUSTER,
+                SOURCE_NAME,
+                of(RAFT_GROUP_LEADERS),
+                of((long) -DEFAULT_PARTITION_COUNT),
+                () -> {
+                    int initialNodes = getRaftNodesCount();
+
+                    dropTableAndZone();
+
+                    // Waiting for zone partitions to be destroyed.
+                    await().until(() -> initialNodes - getRaftNodesCount() >= 
DEFAULT_PARTITION_COUNT);

Review Comment:
   What's the default timeout here?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to