Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IGNITE-22928 Fix testZoneReplicaListener #4284

Merged
merged 5 commits into from
Aug 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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