This is an automated email from the ASF dual-hosted git repository. sk0x50 pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/ignite-3.git
The following commit(s) were added to refs/heads/main by this push: new 6bc603deb6 IGNITE-20355 Fix failing RO tests in TxLocalTest (#2582) 6bc603deb6 is described below commit 6bc603deb67a1b5fcb02c0954c55859b17d53244 Author: Cyrill <cyrill.si...@gmail.com> AuthorDate: Wed Sep 13 17:09:01 2023 +0300 IGNITE-20355 Fix failing RO tests in TxLocalTest (#2582) --- .../apache/ignite/internal/table/TxLocalTest.java | 49 ++++------------------ .../table/impl/DummyInternalTableImpl.java | 13 +++--- 2 files changed, 13 insertions(+), 49 deletions(-) diff --git a/modules/table/src/test/java/org/apache/ignite/internal/table/TxLocalTest.java b/modules/table/src/test/java/org/apache/ignite/internal/table/TxLocalTest.java index dc67894f76..b5cf8349d8 100644 --- a/modules/table/src/test/java/org/apache/ignite/internal/table/TxLocalTest.java +++ b/modules/table/src/test/java/org/apache/ignite/internal/table/TxLocalTest.java @@ -28,7 +28,6 @@ import static org.mockito.Mockito.when; import java.util.HashMap; import java.util.Map; import java.util.concurrent.CompletableFuture; -import org.apache.ignite.internal.hlc.HybridClockImpl; import org.apache.ignite.internal.hlc.HybridTimestamp; import org.apache.ignite.internal.replicator.ReplicaService; import org.apache.ignite.internal.replicator.ReplicationGroupId; @@ -72,9 +71,10 @@ public class TxLocalTest extends TxAbstractTest { ReplicaMessagesFactory replicaMessagesFactory = new ReplicaMessagesFactory(); - HybridClockImpl localClock = new HybridClockImpl(); MessagingService msgSvc = mock(MessagingService.class, RETURNS_DEEP_STUBS); - ReplicaService replicaSvc = new ReplicaService(msgSvc, localClock); + ReplicaService replicaSvc = new ReplicaService(msgSvc, DummyInternalTableImpl.CLOCK); + + String localNodeName = DummyInternalTableImpl.LOCAL_NODE.name(); Map<ReplicationGroupId, DummyInternalTableImpl> tables = new HashMap<>(); doAnswer(invocationOnMock -> { @@ -85,7 +85,7 @@ public class TxLocalTest extends TxAbstractTest { TimestampAware aware = (TimestampAware) request; HybridTimestamp updated = DummyInternalTableImpl.CLOCK.update(aware.timestamp()); - return replicaListener.invoke(request, "local").handle((res, err) -> err == null ? replicaMessagesFactory + return replicaListener.invoke(request, localNodeName).handle((res, err) -> err == null ? replicaMessagesFactory .timestampAwareReplicaResponse() .result(res) .timestampLong(updated.longValue()) @@ -96,7 +96,7 @@ public class TxLocalTest extends TxAbstractTest { .timestampLong(updated.longValue()) .build()); } else { - return replicaListener.invoke(request, "local").handle((res, err) -> err == null ? replicaMessagesFactory + return replicaListener.invoke(request, localNodeName).handle((res, err) -> err == null ? replicaMessagesFactory .replicaResponse() .result(res) .build() : replicaMessagesFactory @@ -116,7 +116,8 @@ public class TxLocalTest extends TxAbstractTest { tables.get(request.groupId()).txStateStorage().getTxStateStorage(0).get(request.txId())); }).when(transactionStateResolver).sendMetaRequest(any(), any()); - txManager = new TxManagerImpl(replicaSvc, lockManager, localClock, new TransactionIdGenerator(0xdeadbeef), () -> "local"); + txManager = new TxManagerImpl(replicaSvc, lockManager, DummyInternalTableImpl.CLOCK, + new TransactionIdGenerator(0xdeadbeef), () -> localNodeName); igniteTransactions = new IgniteTransactionsImpl(txManager, timestampTracker); @@ -171,40 +172,4 @@ public class TxLocalTest extends TxAbstractTest { protected boolean assertPartitionsSame(TableImpl table, int partId) { return true; } - - // TODO: https://issues.apache.org/jira/browse/IGNITE-20355 - @Override - public void testReadOnlyGet() { - // No-op - } - - // TODO: https://issues.apache.org/jira/browse/IGNITE-20355 - @Override - public void testReadOnlyScan() throws Exception { - // No-op - } - - // TODO: https://issues.apache.org/jira/browse/IGNITE-20355 - @Override - public void testReadOnlyGetWriteIntentResolutionUpdate() { - // No-op - } - - // TODO: https://issues.apache.org/jira/browse/IGNITE-20355 - @Override - public void testReadOnlyGetWriteIntentResolutionRemove() { - // No-op - } - - // TODO: https://issues.apache.org/jira/browse/IGNITE-20355 - @Override - public void testReadOnlyGetAll() { - // No-op - } - - // TODO: https://issues.apache.org/jira/browse/IGNITE-20355 - @Override - public void testReadOnlyPendingWriteIntentSkippedCombined() { - super.testReadOnlyPendingWriteIntentSkippedCombined(); - } } diff --git a/modules/table/src/testFixtures/java/org/apache/ignite/internal/table/impl/DummyInternalTableImpl.java b/modules/table/src/testFixtures/java/org/apache/ignite/internal/table/impl/DummyInternalTableImpl.java index bb49f42910..69476824e4 100644 --- a/modules/table/src/testFixtures/java/org/apache/ignite/internal/table/impl/DummyInternalTableImpl.java +++ b/modules/table/src/testFixtures/java/org/apache/ignite/internal/table/impl/DummyInternalTableImpl.java @@ -34,7 +34,6 @@ import java.util.UUID; import java.util.concurrent.CompletableFuture; import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicLong; -import java.util.function.LongSupplier; import javax.naming.OperationNotSupportedException; import org.apache.ignite.configuration.ConfigurationValue; import org.apache.ignite.distributed.TestPartitionDataStorage; @@ -114,12 +113,12 @@ public class DummyInternalTableImpl extends InternalTableImpl { public static final ClusterNode LOCAL_NODE = new ClusterNodeImpl("id", "node", ADDR); - public static final HybridClock CLOCK = new TestHybridClock(new LongSupplier() { - @Override - public long getAsLong() { - return 0; - } - }); + // 2000 was picked to avoid negative time that we get when building read timestamp + // in TxManagerImpl.currentReadTimestamp. + // We subtract (ReplicaManager.IDLE_SAFE_TIME_PROPAGATION_PERIOD_MILLISECONDS + HybridTimestamp.CLOCK_SKEW) = (1000 + 7) = 1007 + // from the current time. + // Any value greater than that will work, hence 2000. + public static final HybridClock CLOCK = new TestHybridClock(() -> 2000); private static final int PART_ID = 0;