This is an automated email from the ASF dual-hosted git repository.
tkalkirill 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 6f479853fc IGNITE-19432 Tests in PartitionReplicaListenerTest are not
independent (#2034)
6f479853fc is described below
commit 6f479853fcead0127a443afbbeb82c5524708737
Author: Roman Puchkovskiy <[email protected]>
AuthorDate: Mon May 8 11:04:55 2023 +0400
IGNITE-19432 Tests in PartitionReplicaListenerTest are not independent
(#2034)
---
gradle/libs.versions.toml | 4 +
modules/table/build.gradle | 1 +
.../replication/PartitionReplicaListenerTest.java | 207 +++++++++++----------
3 files changed, 109 insertions(+), 103 deletions(-)
diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml
index aab1b13919..4a32e394d5 100644
--- a/gradle/libs.versions.toml
+++ b/gradle/libs.versions.toml
@@ -30,6 +30,7 @@ jetbrainsAnnotations = "20.1.0"
jline = "3.21.0"
jmh = "1.35"
junit5 = "5.9.1"
+junitPioneer = "2.0.1"
jsr305 = "3.0.2"
okhttp = "4.9.1"
gson = "2.8.9"
@@ -122,6 +123,9 @@ junit5-impl = { module =
"org.junit.jupiter:junit-jupiter-engine", version.ref =
junit5-params = { module = "org.junit.jupiter:junit-jupiter-params",
version.ref = "junit5" }
junit-testkit = { module = "org.junit.platform:junit-platform-testkit",
version.ref = "testkit" }
+#junit-pioneer
+junit-pioneer = { module = "org.junit-pioneer:junit-pioneer", version.ref =
"junitPioneer" }
+
#Micronaut
micronaut-inject = { module = "io.micronaut:micronaut-inject", version.ref =
"micronaut" }
micronaut-runtime = { module = "io.micronaut:micronaut-runtime", version.ref =
"micronaut" }
diff --git a/modules/table/build.gradle b/modules/table/build.gradle
index f070155e81..70611297f3 100644
--- a/modules/table/build.gradle
+++ b/modules/table/build.gradle
@@ -67,6 +67,7 @@ dependencies {
testImplementation libs.mockito.junit
testImplementation libs.hamcrest.core
testImplementation libs.hamcrest.optional
+ testImplementation libs.junit.pioneer
testImplementation libs.slf4j.jdk14
testImplementation libs.jmh.core
testImplementation libs.javax.annotations
diff --git
a/modules/table/src/test/java/org/apache/ignite/internal/table/distributed/replication/PartitionReplicaListenerTest.java
b/modules/table/src/test/java/org/apache/ignite/internal/table/distributed/replication/PartitionReplicaListenerTest.java
index ffb75897bb..2e1b27e5c6 100644
---
a/modules/table/src/test/java/org/apache/ignite/internal/table/distributed/replication/PartitionReplicaListenerTest.java
+++
b/modules/table/src/test/java/org/apache/ignite/internal/table/distributed/replication/PartitionReplicaListenerTest.java
@@ -29,8 +29,8 @@ import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.lenient;
import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
import java.nio.ByteBuffer;
import java.util.ArrayList;
@@ -125,39 +125,46 @@ import org.apache.ignite.network.ClusterNode;
import org.apache.ignite.network.NetworkAddress;
import org.apache.ignite.network.TopologyService;
import org.apache.ignite.tx.TransactionException;
-import org.junit.jupiter.api.BeforeAll;
+import org.jetbrains.annotations.Nullable;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
+import org.junitpioneer.jupiter.cartesian.CartesianTest;
+import org.junitpioneer.jupiter.cartesian.CartesianTest.Values;
import org.mockito.Mock;
+import org.mockito.junit.jupiter.MockitoExtension;
-/** There are tests for partition replica listener. */
+/** Tests for partition replica listener. */
@ExtendWith(ConfigurationExtension.class)
+@ExtendWith(MockitoExtension.class)
public class PartitionReplicaListenerTest extends IgniteAbstractTest {
/** Partition id. */
private static final int partId = 0;
/** Table id. */
- private static final UUID tblId = UUID.randomUUID();
+ private final UUID tblId = UUID.randomUUID();
- private static final Map<UUID, Set<RowId>> pendingRows = new
ConcurrentHashMap<>();
+ private final Map<UUID, Set<RowId>> pendingRows = new
ConcurrentHashMap<>();
/** The storage stores partition data. */
- private static final TestMvPartitionStorage testMvPartitionStorage = new
TestMvPartitionStorage(partId);
+ private final TestMvPartitionStorage testMvPartitionStorage = new
TestMvPartitionStorage(partId);
- private static final LockManager lockManager = new HeapLockManager();
+ private final LockManager lockManager = new HeapLockManager();
- private static final Function<PartitionCommand, CompletableFuture<?>>
DEFAULT_MOCK_RAFT_FUTURE_CLOSURE = cmd -> {
+ private final Function<PartitionCommand, CompletableFuture<?>>
defaultMockRaftFutureClosure = cmd -> {
if (cmd instanceof TxCleanupCommand) {
Set<RowId> rows = pendingRows.remove(cmd.txId());
+ HybridTimestamp commitTimestamp = ((TxCleanupCommand)
cmd).commitTimestamp();
+ assertNotNull(commitTimestamp);
+
if (rows != null) {
for (RowId row : rows) {
- testMvPartitionStorage.commitWrite(row,
((TxCleanupCommand) cmd).commitTimestamp());
+ testMvPartitionStorage.commitWrite(row, commitTimestamp);
}
}
- lockManager.locks(cmd.txId()).forEachRemaining(lock ->
lockManager.release(lock));
+
lockManager.locks(cmd.txId()).forEachRemaining(lockManager::release);
} else if (cmd instanceof UpdateCommand) {
pendingRows.compute(cmd.txId(), (txId, v) -> {
if (v == null) {
@@ -181,64 +188,67 @@ public class PartitionReplicaListenerTest extends
IgniteAbstractTest {
private static final TableMessagesFactory TABLE_MESSAGES_FACTORY = new
TableMessagesFactory();
/** Replication group id. */
- private static final ReplicationGroupId grpId = new
TablePartitionId(tblId, partId);
+ private final ReplicationGroupId grpId = new TablePartitionId(tblId,
partId);
/** Hybrid clock. */
- private static final HybridClock clock = new HybridClockImpl();
+ private final HybridClock clock = new HybridClockImpl();
/** The storage stores transaction states. */
- private static final TestTxStateStorage txStateStorage = new
TestTxStateStorage();
+ private final TestTxStateStorage txStateStorage = new TestTxStateStorage();
/** Local cluster node. */
- private static final ClusterNode localNode = new ClusterNode("node1",
"node1", NetworkAddress.from("127.0.0.1:127"));
+ private final ClusterNode localNode = new ClusterNode("node1", "node1",
NetworkAddress.from("127.0.0.1:127"));
/** Another (not local) cluster node. */
- private static final ClusterNode anotherNode = new ClusterNode("node2",
"node2", NetworkAddress.from("127.0.0.2:127"));
+ private final ClusterNode anotherNode = new ClusterNode("node2", "node2",
NetworkAddress.from("127.0.0.2:127"));
- private static final PlacementDriver placementDriver =
mock(PlacementDriver.class);
+ private final PlacementDriver placementDriver =
mock(PlacementDriver.class);
- private static final PartitionDataStorage partitionDataStorage = new
TestPartitionDataStorage(testMvPartitionStorage);
+ private final PartitionDataStorage partitionDataStorage = new
TestPartitionDataStorage(testMvPartitionStorage);
@Mock
- private static RaftGroupService mockRaftClient =
mock(RaftGroupService.class);
+ private RaftGroupService mockRaftClient;
@Mock
- private static TopologyService topologySrv = mock(TopologyService.class);
+ private TopologyService topologySrv;
- /** Default reflection marshaller factory. */
- private static MarshallerFactory marshallerFactory;
+ @Mock
+ private PendingComparableValuesTracker<HybridTimestamp> safeTimeClock;
/** Schema descriptor for tests. */
- private static SchemaDescriptor schemaDescriptor;
+ private SchemaDescriptor schemaDescriptor;
/** Key-value marshaller for tests. */
- private static KvMarshaller<TestKey, TestValue> kvMarshaller;
+ private KvMarshaller<TestKey, TestValue> kvMarshaller;
/** Partition replication listener to test. */
- private static PartitionReplicaListener partitionReplicaListener;
+ private PartitionReplicaListener partitionReplicaListener;
/** Primary index. */
- private static Lazy<TableSchemaAwareIndexStorage> pkStorage;
+ private Lazy<TableSchemaAwareIndexStorage> pkStorageSupplier;
/** If true the local replica is considered leader, false otherwise. */
- private static boolean localLeader;
+ private boolean localLeader;
/** The state is used to resolve write intent. */
- private static TxState txState;
+ @Nullable
+ private TxState txState;
- private static BinaryTupleSchema sortedIndexBinarySchema;
+ private BinaryTupleSchema sortedIndexBinarySchema;
/** Secondary sorted index. */
- private static TableSchemaAwareIndexStorage sortedIndexStorage;
+ private TableSchemaAwareIndexStorage sortedIndexStorage;
/** Secondary hash index. */
- private static TableSchemaAwareIndexStorage hashIndexStorage;
+ private TableSchemaAwareIndexStorage hashIndexStorage;
+
+ private Function<PartitionCommand, CompletableFuture<?>>
raftClientFutureClosure = defaultMockRaftFutureClosure;
- private static Function<PartitionCommand, CompletableFuture<?>>
raftClientFutureClosure = DEFAULT_MOCK_RAFT_FUTURE_CLOSURE;
+ private static final AtomicInteger nextMonotonicInt = new AtomicInteger(1);
- @BeforeAll
- public static void beforeAll(@InjectConfiguration DataStorageConfiguration
dsCfg) {
-
when(mockRaftClient.refreshAndGetLeaderWithTerm()).thenAnswer(invocationOnMock
-> {
+ @BeforeEach
+ public void beforeTest(@InjectConfiguration DataStorageConfiguration
dsCfg) {
+
lenient().when(mockRaftClient.refreshAndGetLeaderWithTerm()).thenAnswer(invocationOnMock
-> {
if (!localLeader) {
return completedFuture(new LeaderWithTerm(new
Peer(anotherNode.name()), 1L));
}
@@ -246,9 +256,10 @@ public class PartitionReplicaListenerTest extends
IgniteAbstractTest {
return completedFuture(new LeaderWithTerm(new
Peer(localNode.name()), 1L));
});
- when(mockRaftClient.run(any())).thenAnswer(invocationOnMock ->
raftClientFutureClosure.apply(invocationOnMock.getArgument(0)));
+ lenient().when(mockRaftClient.run(any()))
+ .thenAnswer(invocationOnMock ->
raftClientFutureClosure.apply(invocationOnMock.getArgument(0)));
- when(topologySrv.getByConsistentId(any())).thenAnswer(invocationOnMock
-> {
+
lenient().when(topologySrv.getByConsistentId(any())).thenAnswer(invocationOnMock
-> {
String consistentId = invocationOnMock.getArgument(0);
if (consistentId.equals(anotherNode.name())) {
return anotherNode;
@@ -259,11 +270,11 @@ public class PartitionReplicaListenerTest extends
IgniteAbstractTest {
}
});
- when(topologySrv.localMember()).thenReturn(localNode);
+ lenient().when(topologySrv.localMember()).thenReturn(localNode);
HybridTimestamp txFixedTimestamp = clock.now();
- when(placementDriver.sendMetaRequest(any(),
any())).thenAnswer(invocationOnMock -> {
+ lenient().when(placementDriver.sendMetaRequest(any(),
any())).thenAnswer(invocationOnMock -> {
TxMeta txMeta;
if (txState == null) {
@@ -278,8 +289,7 @@ public class PartitionReplicaListenerTest extends
IgniteAbstractTest {
return completedFuture(txMeta);
});
- PendingComparableValuesTracker safeTimeClock =
mock(PendingComparableValuesTracker.class);
- when(safeTimeClock.waitFor(any())).thenReturn(completedFuture(null));
+
lenient().when(safeTimeClock.waitFor(any())).thenReturn(completedFuture(null));
UUID pkIndexId = UUID.randomUUID();
UUID sortedIndexId = UUID.randomUUID();
@@ -295,9 +305,9 @@ public class PartitionReplicaListenerTest extends
IgniteAbstractTest {
Function<BinaryRow, BinaryTuple> row2Tuple =
BinaryRowConverter.keyExtractor(schemaDescriptor);
- pkStorage = new Lazy<>(() -> new TableSchemaAwareIndexStorage(
+ pkStorageSupplier = new Lazy<>(() -> new TableSchemaAwareIndexStorage(
pkIndexId,
- new TestHashIndexStorage(partId, null),
+ new TestHashIndexStorage(partId,
mock(HashIndexDescriptor.class)),
row2Tuple
));
@@ -329,7 +339,7 @@ public class PartitionReplicaListenerTest extends
IgniteAbstractTest {
partId,
tblId,
() -> Map.of(pkLocker.id(), pkLocker, sortedIndexId,
sortedIndexLocker, hashIndexId, hashIndexLocker),
- pkStorage,
+ pkStorageSupplier,
() -> Map.of(sortedIndexId, sortedIndexStorage, hashIndexId,
hashIndexStorage),
clock,
safeTimeClock,
@@ -338,7 +348,7 @@ public class PartitionReplicaListenerTest extends
IgniteAbstractTest {
new StorageUpdateHandler(
partId,
partitionDataStorage,
-
DummyInternalTableImpl.createTableIndexStoragesSupplier(Map.of(pkStorage.get().id(),
pkStorage.get())),
+
DummyInternalTableImpl.createTableIndexStoragesSupplier(Map.of(pkStorage().id(),
pkStorage())),
dsCfg,
safeTimeClock,
mock(LowWatermark.class)
@@ -347,18 +357,23 @@ public class PartitionReplicaListenerTest extends
IgniteAbstractTest {
completedFuture(schemaManager)
);
- marshallerFactory = new ReflectionMarshallerFactory();
+ MarshallerFactory marshallerFactory = new
ReflectionMarshallerFactory();
sortedIndexBinarySchema =
BinaryTupleSchema.createSchema(schemaDescriptor, new int[]{2 /* intVal column
*/});
kvMarshaller = marshallerFactory.create(schemaDescriptor,
TestKey.class, TestValue.class);
+
+ reset();
}
- @BeforeEach
- public void beforeTest() {
+ private TableSchemaAwareIndexStorage pkStorage() {
+ return Objects.requireNonNull(pkStorageSupplier.get());
+ }
+
+ private void reset() {
localLeader = true;
txState = null;
- ((TestHashIndexStorage) pkStorage.get().storage()).clear();
+ ((TestHashIndexStorage) pkStorage().storage()).clear();
((TestHashIndexStorage) hashIndexStorage.storage()).clear();
((TestSortedIndexStorage) sortedIndexStorage.storage()).clear();
testMvPartitionStorage.clear();
@@ -396,8 +411,11 @@ public class PartitionReplicaListenerTest extends
IgniteAbstractTest {
LeaderOrTxState tuple = (LeaderOrTxState) fut.get(1, TimeUnit.SECONDS);
- assertEquals(TxState.COMMITED, tuple.txMeta().txState());
- assertTrue(readTimestamp.compareTo(tuple.txMeta().commitTimestamp()) >
0);
+ TxMeta txMeta = tuple.txMeta();
+ assertNotNull(txMeta);
+ assertEquals(TxState.COMMITED, txMeta.txState());
+ assertNotNull(txMeta.commitTimestamp());
+ assertTrue(readTimestamp.compareTo(txMeta.commitTimestamp()) > 0);
assertNull(tuple.leaderName());
}
@@ -440,7 +458,7 @@ public class PartitionReplicaListenerTest extends
IgniteAbstractTest {
BinaryRow testBinaryRow = binaryRow(key(testBinaryKey), new
TestValue(1, "v1"));
var rowId = new RowId(partId);
- pkStorage.get().put(testBinaryRow, rowId);
+ pkStorage().put(testBinaryRow, rowId);
testMvPartitionStorage.addWrite(rowId, testBinaryRow, txId, tblId,
partId);
testMvPartitionStorage.commitWrite(rowId, clock.now());
@@ -464,7 +482,7 @@ public class PartitionReplicaListenerTest extends
IgniteAbstractTest {
var rowId = new RowId(partId);
txState = TxState.COMMITED;
- pkStorage.get().put(testBinaryRow, rowId);
+ pkStorage().put(testBinaryRow, rowId);
testMvPartitionStorage.addWrite(rowId, testBinaryRow, txId, tblId,
partId);
CompletableFuture<?> fut =
partitionReplicaListener.invoke(TABLE_MESSAGES_FACTORY.readOnlySingleRowReplicaRequest()
@@ -486,7 +504,7 @@ public class PartitionReplicaListenerTest extends
IgniteAbstractTest {
BinaryRow testBinaryRow = binaryRow(key(testBinaryKey), new
TestValue(1, "v1"));
var rowId = new RowId(partId);
- pkStorage.get().put(testBinaryRow, rowId);
+ pkStorage().put(testBinaryRow, rowId);
testMvPartitionStorage.addWrite(rowId, testBinaryRow, txId, tblId,
partId);
CompletableFuture<?> fut =
partitionReplicaListener.invoke(TABLE_MESSAGES_FACTORY.readOnlySingleRowReplicaRequest()
@@ -509,7 +527,7 @@ public class PartitionReplicaListenerTest extends
IgniteAbstractTest {
var rowId = new RowId(partId);
txState = TxState.ABORTED;
- pkStorage.get().put(testBinaryRow, rowId);
+ pkStorage().put(testBinaryRow, rowId);
testMvPartitionStorage.addWrite(rowId, testBinaryRow, txId, tblId,
partId);
CompletableFuture<?> fut =
partitionReplicaListener.invoke(TABLE_MESSAGES_FACTORY.readOnlySingleRowReplicaRequest()
@@ -525,7 +543,7 @@ public class PartitionReplicaListenerTest extends
IgniteAbstractTest {
}
@Test
- public void testWriteScanRetriveBatchReplicaRequestWithSortedIndex()
throws Exception {
+ public void testWriteScanRetrieveBatchReplicaRequestWithSortedIndex()
throws Exception {
UUID txId = TestTransactionIds.newTransactionId();
UUID sortedIndexId = sortedIndexStorage.id();
@@ -632,7 +650,7 @@ public class PartitionReplicaListenerTest extends
IgniteAbstractTest {
}
@Test
- public void testReadOnlyScanRetriveBatchReplicaRequestSortedIndex() throws
Exception {
+ public void testReadOnlyScanRetrieveBatchReplicaRequestSortedIndex()
throws Exception {
UUID txId = TestTransactionIds.newTransactionId();
UUID sortedIndexId = sortedIndexStorage.id();
@@ -734,7 +752,7 @@ public class PartitionReplicaListenerTest extends
IgniteAbstractTest {
}
@Test
- public void testReadOnlyScanRetriveBatchReplicaRequstHashIndex() throws
Exception {
+ public void testReadOnlyScanRetrieveBatchReplicaRequstHashIndex() throws
Exception {
UUID txId = TestTransactionIds.newTransactionId();
UUID hashIndexId = hashIndexStorage.id();
@@ -964,7 +982,7 @@ public class PartitionReplicaListenerTest extends
IgniteAbstractTest {
}
private void checkRowInMvStorage(BinaryRow binaryRow, boolean
shouldBePresent) {
- Cursor<RowId> cursor = pkStorage.get().get(binaryRow);
+ Cursor<RowId> cursor = pkStorage().get(binaryRow);
if (shouldBePresent) {
boolean found = false;
@@ -991,7 +1009,7 @@ public class PartitionReplicaListenerTest extends
IgniteAbstractTest {
}
private void checkNoRowInIndex(BinaryRow binaryRow) {
- try (Cursor<RowId> cursor = pkStorage.get().get(binaryRow)) {
+ try (Cursor<RowId> cursor = pkStorage().get(binaryRow)) {
assertFalse(cursor.hasNext());
}
}
@@ -1014,7 +1032,7 @@ public class PartitionReplicaListenerTest extends
IgniteAbstractTest {
assertFalse(replicaWriteFut.isDone());
- raftClientFutureClosure = DEFAULT_MOCK_RAFT_FUTURE_CLOSURE;
+ raftClientFutureClosure = defaultMockRaftFutureClosure;
HybridTimestamp now = clock.now();
@@ -1035,7 +1053,7 @@ public class PartitionReplicaListenerTest extends
IgniteAbstractTest {
assertThat(replicaCleanupFut, willSucceedFast());
} finally {
- raftClientFutureClosure = DEFAULT_MOCK_RAFT_FUTURE_CLOSURE;
+ raftClientFutureClosure = defaultMockRaftFutureClosure;
}
// Check that one more write after cleanup is discarded.
@@ -1043,30 +1061,6 @@ public class PartitionReplicaListenerTest extends
IgniteAbstractTest {
assertThat(writeAfterCleanupFuture,
willThrowFast(TransactionException.class));
}
- @Test
- public void testReadOnlyGetAfterRowRewrite() {
- testReadOnlyGetAfterRowRewrite0(true, true, true, false);
- testReadOnlyGetAfterRowRewrite0(true, true, false, false);
- testReadOnlyGetAfterRowRewrite0(true, false, true, false);
- testReadOnlyGetAfterRowRewrite0(true, false, false, false);
- testReadOnlyGetAfterRowRewrite0(false, true, true, false);
- testReadOnlyGetAfterRowRewrite0(false, true, false, false);
- testReadOnlyGetAfterRowRewrite0(false, false, true, false);
- testReadOnlyGetAfterRowRewrite0(false, false, false, false);
- }
-
- @Test
- public void testReadOnlyGetAllAfterRowRewrite() {
- testReadOnlyGetAfterRowRewrite0(true, true, true, true);
- testReadOnlyGetAfterRowRewrite0(true, true, false, true);
- testReadOnlyGetAfterRowRewrite0(true, false, true, true);
- testReadOnlyGetAfterRowRewrite0(true, false, false, true);
- testReadOnlyGetAfterRowRewrite0(false, true, true, true);
- testReadOnlyGetAfterRowRewrite0(false, true, false, true);
- testReadOnlyGetAfterRowRewrite0(false, false, true, true);
- testReadOnlyGetAfterRowRewrite0(false, false, false, true);
- }
-
/**
* Puts several records into the storage, optionally leaving them as write
intents, alternately deleting and upserting the same row
* within the same RW transaction, then checking read correctness via read
only request.
@@ -1076,9 +1070,13 @@ public class PartitionReplicaListenerTest extends
IgniteAbstractTest {
* @param committed Whether to commit RW transaction before doing RO
request.
* @param multiple Whether to check multiple rows via getAll request.
*/
- public void testReadOnlyGetAfterRowRewrite0(boolean insertFirst, boolean
upsertAfterDelete, boolean committed, boolean multiple) {
- beforeTest();
-
+ @CartesianTest
+ void testReadOnlyGetAfterRowRewrite(
+ @Values(booleans = {false, true}) boolean insertFirst,
+ @Values(booleans = {false, true}) boolean upsertAfterDelete,
+ @Values(booleans = {false, true}) boolean committed,
+ @Values(booleans = {false, true}) boolean multiple
+ ) {
BinaryRow br1 = binaryRow(1);
BinaryRow br2 = binaryRow(2);
@@ -1102,7 +1100,7 @@ public class PartitionReplicaListenerTest extends
IgniteAbstractTest {
upsert(tx1, br1);
}
- Cursor<RowId> cursor = pkStorage.get().get(br1);
+ Cursor<RowId> cursor = pkStorage().get(br1);
if (!insertFirst) {
if (!upsertAfterDelete) {
@@ -1139,6 +1137,7 @@ public class PartitionReplicaListenerTest extends
IgniteAbstractTest {
assertEquals(expected.size(), res.size());
for (BinaryRow e : expected) {
+ // TODO: IGNITE-19430 - should there be an assertion in the
next line?
res.contains(e);
}
} else {
@@ -1157,7 +1156,7 @@ public class PartitionReplicaListenerTest extends
IgniteAbstractTest {
cleanup(tx1);
}
- private UUID beginTx() {
+ private static UUID beginTx() {
return TestTransactionIds.newTransactionId();
}
@@ -1217,53 +1216,55 @@ public class PartitionReplicaListenerTest extends
IgniteAbstractTest {
txState = TxState.COMMITED;
}
- private static BinaryTuplePrefix toIndexBound(int val) {
+ private BinaryTuplePrefix toIndexBound(int val) {
ByteBuffer tuple = new BinaryTuplePrefixBuilder(1,
1).appendInt(val).build();
return new BinaryTuplePrefix(sortedIndexBinarySchema, tuple);
}
- private static BinaryTuple toIndexKey(int val) {
+ private BinaryTuple toIndexKey(int val) {
ByteBuffer tuple = new BinaryTupleBuilder(1,
true).appendInt(val).build();
return new BinaryTuple(sortedIndexBinarySchema, tuple);
}
- private static BinaryRow nextBinaryKey() {
+ private BinaryRow nextBinaryKey() {
try {
- int nextInt = (int) System.nanoTime();
-
- return kvMarshaller.marshal(new TestKey(nextInt, "key " +
nextInt));
+ return kvMarshaller.marshal(new TestKey(monotonicInt(), "key " +
monotonicInt()));
} catch (MarshallerException e) {
throw new IgniteException(e);
}
}
- protected static BinaryRow binaryRow(int i) {
+ private static int monotonicInt() {
+ return nextMonotonicInt.getAndIncrement();
+ }
+
+ protected BinaryRow binaryRow(int i) {
try {
return kvMarshaller.marshal(new TestKey(i, "k" + i), new
TestValue(i, "v" + i));
} catch (MarshallerException e) {
- throw new IgniteException(e);
+ throw new AssertionError(e);
}
}
- private static BinaryRow binaryRow(TestKey key, TestValue value) {
+ private BinaryRow binaryRow(TestKey key, TestValue value) {
try {
return kvMarshaller.marshal(key, value);
} catch (MarshallerException e) {
- throw new IgniteException(e);
+ throw new AssertionError(e);
}
}
- private static TestKey key(BinaryRow binaryRow) {
+ private TestKey key(BinaryRow binaryRow) {
try {
return kvMarshaller.unmarshalKey(new Row(schemaDescriptor,
binaryRow));
} catch (MarshallerException e) {
- throw new IgniteException(e);
+ throw new AssertionError(e);
}
}
- private static TestValue value(BinaryRow binaryRow) {
+ private TestValue value(BinaryRow binaryRow) {
try {
return kvMarshaller.unmarshalValue(new Row(schemaDescriptor,
binaryRow));
} catch (MarshallerException e) {