Skip to content

Commit

Permalink
IGNITE-22928 Fix testZoneReplicaListener (#4284)
Browse files Browse the repository at this point in the history
  • Loading branch information
JAkutenshi authored Aug 27, 2024
1 parent ecbe35e commit 8b705e0
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -360,7 +361,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);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,16 @@
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;

/**
* Trivial placement driver for tests.
*/
// TODO: https://issues.apache.org/jira/browse/IGNITE-22522 remove this code
public class TestPlacementDriver extends AbstractEventProducer<PrimaryReplicaEvent, PrimaryReplicaEventParameters> implements
PlacementDriver {
public class TestPlacementDriver extends AbstractEventProducer<PrimaryReplicaEvent, PrimaryReplicaEventParameters>
implements PlacementDriver {
private static final int DEFAULT_ZONE_ID = 0;

private volatile ClusterNode primary;

Expand All @@ -54,18 +56,17 @@ public void setPrimary(ClusterNode node) {
@Override
public CompletableFuture<ReplicaMeta> awaitPrimaryReplica(ReplicationGroupId groupId, HybridTimestamp timestamp, long timeout,
TimeUnit unit) {
return getPrimaryReplicaMeta();
return getPrimaryReplicaMeta(groupId);
}

@Override
public CompletableFuture<ReplicaMeta> 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
Expand All @@ -81,7 +82,11 @@ public CompletableFuture<List<TokenizedAssignments>> getAssignments(
return failedFuture(new UnsupportedOperationException("getAssignments() is not supported in FakePlacementDriver yet."));
}

private CompletableFuture<ReplicaMeta> getPrimaryReplicaMeta() {
private CompletableFuture<ReplicaMeta> getPrimaryReplicaMeta(ReplicationGroupId replicationGroupId) {
if (replicationGroupId instanceof ZonePartitionId && ((ZonePartitionId) replicationGroupId).zoneId() == DEFAULT_ZONE_ID) {
return nullCompletedFuture();
}

if (primary == null) {
throw new IllegalStateException("Primary replica is not defined in test PlacementDriver");
}
Expand Down

0 comments on commit 8b705e0

Please sign in to comment.