From e0cca08ac01462097e99fa1f87566701c274a73b Mon Sep 17 00:00:00 2001 From: Mikhail Efremov Date: Mon, 26 Aug 2024 18:04:59 +0600 Subject: [PATCH 1/3] IGNITE-22928 `TestPlacementDriver` now returns null primary node on default zone --- .../replicator/ItReplicaLifecycleTest.java | 1 - .../replicator/utils/TestPlacementDriver.java | 16 ++++++++++------ 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/modules/partition-replicator/src/integrationTest/java/org/apache/ignite/internal/partition/replicator/ItReplicaLifecycleTest.java b/modules/partition-replicator/src/integrationTest/java/org/apache/ignite/internal/partition/replicator/ItReplicaLifecycleTest.java index 1dfed729879..67b6dab8291 100644 --- a/modules/partition-replicator/src/integrationTest/java/org/apache/ignite/internal/partition/replicator/ItReplicaLifecycleTest.java +++ b/modules/partition-replicator/src/integrationTest/java/org/apache/ignite/internal/partition/replicator/ItReplicaLifecycleTest.java @@ -360,7 +360,6 @@ private void stopNode(int idx) { } @Test - @Disabled("https://issues.apache.org/jira/browse/IGNITE-22928") public void testZoneReplicaListener(TestInfo testInfo) throws Exception { startNodes(testInfo, 3); diff --git a/modules/partition-replicator/src/integrationTest/java/org/apache/ignite/internal/partition/replicator/utils/TestPlacementDriver.java b/modules/partition-replicator/src/integrationTest/java/org/apache/ignite/internal/partition/replicator/utils/TestPlacementDriver.java index fa70085543e..d135406a9bd 100644 --- a/modules/partition-replicator/src/integrationTest/java/org/apache/ignite/internal/partition/replicator/utils/TestPlacementDriver.java +++ b/modules/partition-replicator/src/integrationTest/java/org/apache/ignite/internal/partition/replicator/utils/TestPlacementDriver.java @@ -31,6 +31,7 @@ import org.apache.ignite.internal.placementdriver.event.PrimaryReplicaEvent; import org.apache.ignite.internal.placementdriver.event.PrimaryReplicaEventParameters; import org.apache.ignite.internal.replicator.ReplicationGroupId; +import org.apache.ignite.internal.replicator.ZonePartitionId; import org.apache.ignite.network.ClusterNode; /** @@ -54,18 +55,17 @@ public void setPrimary(ClusterNode node) { @Override public CompletableFuture awaitPrimaryReplica(ReplicationGroupId groupId, HybridTimestamp timestamp, long timeout, TimeUnit unit) { - return getPrimaryReplicaMeta(); + return getPrimaryReplicaMeta(groupId); } @Override public CompletableFuture getPrimaryReplica(ReplicationGroupId replicationGroupId, HybridTimestamp timestamp) { - return getPrimaryReplicaMeta(); + return getPrimaryReplicaMeta(replicationGroupId); } @Override - public ReplicaMeta getCurrentPrimaryReplica(ReplicationGroupId replicationGroupId, - HybridTimestamp timestamp) { - return getPrimaryReplicaMeta().join(); + public ReplicaMeta getCurrentPrimaryReplica(ReplicationGroupId replicationGroupId, HybridTimestamp timestamp) { + return getPrimaryReplicaMeta(replicationGroupId).join(); } @Override @@ -81,7 +81,11 @@ public CompletableFuture> getAssignments( return failedFuture(new UnsupportedOperationException("getAssignments() is not supported in FakePlacementDriver yet.")); } - private CompletableFuture getPrimaryReplicaMeta() { + private CompletableFuture getPrimaryReplicaMeta(ReplicationGroupId replicationGroupId) { + if (replicationGroupId instanceof ZonePartitionId && ((ZonePartitionId) replicationGroupId).zoneId() == 0) { + return nullCompletedFuture(); + } + if (primary == null) { throw new IllegalStateException("Primary replica is not defined in test PlacementDriver"); } From d478e044558de32fdb50946ad909018c4eb964c8 Mon Sep 17 00:00:00 2001 From: Mikhail Efremov Date: Tue, 27 Aug 2024 16:39:47 +0600 Subject: [PATCH 2/3] IGNITE-22928 review fix --- .../partition/replicator/utils/TestPlacementDriver.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/modules/partition-replicator/src/integrationTest/java/org/apache/ignite/internal/partition/replicator/utils/TestPlacementDriver.java b/modules/partition-replicator/src/integrationTest/java/org/apache/ignite/internal/partition/replicator/utils/TestPlacementDriver.java index d135406a9bd..e7a2cb4fd8f 100644 --- a/modules/partition-replicator/src/integrationTest/java/org/apache/ignite/internal/partition/replicator/utils/TestPlacementDriver.java +++ b/modules/partition-replicator/src/integrationTest/java/org/apache/ignite/internal/partition/replicator/utils/TestPlacementDriver.java @@ -38,8 +38,9 @@ * Trivial placement driver for tests. */ // TODO: https://issues.apache.org/jira/browse/IGNITE-22522 remove this code -public class TestPlacementDriver extends AbstractEventProducer implements - PlacementDriver { +public class TestPlacementDriver extends AbstractEventProducer + implements PlacementDriver { + private static final int DEFAULT_ZONE_ID = 0; private volatile ClusterNode primary; @@ -82,7 +83,7 @@ public CompletableFuture> getAssignments( } private CompletableFuture getPrimaryReplicaMeta(ReplicationGroupId replicationGroupId) { - if (replicationGroupId instanceof ZonePartitionId && ((ZonePartitionId) replicationGroupId).zoneId() == 0) { + if (replicationGroupId instanceof ZonePartitionId && ((ZonePartitionId) replicationGroupId).zoneId() == DEFAULT_ZONE_ID) { return nullCompletedFuture(); } From 2bd5a0d86f62773e633ba8e1996d0ee6cfc516e0 Mon Sep 17 00:00:00 2001 From: Mikhail Efremov Date: Tue, 27 Aug 2024 17:48:13 +0600 Subject: [PATCH 3/3] IGNITE-22928 `ItReplicaLifecycleTest` is disabled until IGNITE-23063 --- .../internal/partition/replicator/ItReplicaLifecycleTest.java | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/partition-replicator/src/integrationTest/java/org/apache/ignite/internal/partition/replicator/ItReplicaLifecycleTest.java b/modules/partition-replicator/src/integrationTest/java/org/apache/ignite/internal/partition/replicator/ItReplicaLifecycleTest.java index 67b6dab8291..f2eadd5afe4 100644 --- a/modules/partition-replicator/src/integrationTest/java/org/apache/ignite/internal/partition/replicator/ItReplicaLifecycleTest.java +++ b/modules/partition-replicator/src/integrationTest/java/org/apache/ignite/internal/partition/replicator/ItReplicaLifecycleTest.java @@ -209,6 +209,7 @@ */ @ExtendWith({WorkDirectoryExtension.class, ConfigurationExtension.class}) @Timeout(60) +@Disabled("https://issues.apache.org/jira/browse/IGNITE-23063") // TODO: https://issues.apache.org/jira/browse/IGNITE-22522 remove this test after the switching to zone-based replication public class ItReplicaLifecycleTest extends BaseIgniteAbstractTest { private static final IgniteLogger LOG = Loggers.forClass(ItReplicaLifecycleTest.class);