X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-distributed-datastore%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fcluster%2Fdatastore%2FShardTest.java;h=2ac7c6ea5981d7a75d30e9423213778850609857;hp=d2a08495cdf1eda71f4319560bf09cc36fe9ba2a;hb=HEAD;hpb=8e1d3c4f9001fbc8a5d3d3bea57916c5099078b2 diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/ShardTest.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/ShardTest.java index d2a08495cd..e0db8543f6 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/ShardTest.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/ShardTest.java @@ -13,6 +13,7 @@ import static org.hamcrest.MatcherAssert.assertThat; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; import static org.junit.Assert.assertSame; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; @@ -303,7 +304,7 @@ public class ShardTest extends AbstractShardTest { writeToStore(store, TestModel.TEST_PATH, container); - final YangInstanceIdentifier root = YangInstanceIdentifier.empty(); + final YangInstanceIdentifier root = YangInstanceIdentifier.of(); final NormalizedNode expected = readStore(store, root); final Snapshot snapshot = Snapshot.create(new ShardSnapshotState(new MetadataShardDataTreeSnapshot(expected)), @@ -646,6 +647,7 @@ public class ShardTest extends AbstractShardTest { verifyOuterListEntry(shard, 1); } + @Deprecated(since = "9.0.0", forRemoval = true) @Test(expected = IllegalStateException.class) public void testBatchedModificationsReadyWithIncorrectTotalMessageCount() throws Exception { final ShardTestKit testKit = new ShardTestKit(getSystem()); @@ -672,6 +674,7 @@ public class ShardTest extends AbstractShardTest { } @Test + @Deprecated(since = "9.0.0", forRemoval = true) public void testBatchedModificationsWithOperationFailure() { final ShardTestKit testKit = new ShardTestKit(getSystem()); final TestActorRef shard = actorFactory.createTestActor( @@ -761,6 +764,7 @@ public class ShardTest extends AbstractShardTest { } @Test + @Deprecated(since = "9.0.0", forRemoval = true) public void testOnBatchedModificationsWhenNotLeader() { final AtomicBoolean overrideLeaderCalls = new AtomicBoolean(); final ShardTestKit testKit = new ShardTestKit(getSystem()); @@ -801,6 +805,7 @@ public class ShardTest extends AbstractShardTest { } @Test + @Deprecated(since = "9.0.0", forRemoval = true) public void testTransactionMessagesWithNoLeader() { final ShardTestKit testKit = new ShardTestKit(getSystem()); dataStoreContextBuilder.customRaftPolicyImplementation(DisableElectionsRaftPolicy.class.getName()) @@ -1189,7 +1194,7 @@ public class ShardTest extends AbstractShardTest { final Duration duration = Duration.ofSeconds(5); final TransactionIdentifier transactionID1 = nextTransactionId(); - doThrow(new DataValidationFailedException(YangInstanceIdentifier.empty(), "mock canCommit failure")) + doThrow(new DataValidationFailedException(YangInstanceIdentifier.of(), "mock canCommit failure")) .doNothing().when(dataTree).validate(any(DataTreeModification.class)); shard.tell(newBatchedModifications(transactionID1, TestModel.TEST_PATH, @@ -1230,7 +1235,7 @@ public class ShardTest extends AbstractShardTest { ShardTestKit.waitUntilLeader(shard); - doThrow(new DataValidationFailedException(YangInstanceIdentifier.empty(), "mock canCommit failure")) + doThrow(new DataValidationFailedException(YangInstanceIdentifier.of(), "mock canCommit failure")) .doNothing().when(dataTree).validate(any(DataTreeModification.class)); final Duration duration = Duration.ofSeconds(5); @@ -1742,7 +1747,7 @@ public class ShardTest extends AbstractShardTest { ShardTestKit.waitUntilLeader(shard); writeToStore(shard, TestModel.TEST_PATH, ImmutableNodes.containerNode(TestModel.TEST_QNAME)); - final NormalizedNode expectedRoot = readStore(shard, YangInstanceIdentifier.empty()); + final NormalizedNode expectedRoot = readStore(shard, YangInstanceIdentifier.of()); // Trigger creation of a snapshot by ensuring final RaftActorContext raftActorContext = ((TestShard) shard.underlyingActor()).getRaftActorContext(); @@ -1785,16 +1790,16 @@ public class ShardTest extends AbstractShardTest { commitTransaction(store, putTransaction); - final NormalizedNode expected = readStore(store, YangInstanceIdentifier.empty()); + final NormalizedNode expected = readStore(store, YangInstanceIdentifier.of()); final DataTreeModification writeTransaction = store.takeSnapshot().newModification(); - writeTransaction.delete(YangInstanceIdentifier.empty()); - writeTransaction.write(YangInstanceIdentifier.empty(), expected); + writeTransaction.delete(YangInstanceIdentifier.of()); + writeTransaction.write(YangInstanceIdentifier.of(), expected); commitTransaction(store, writeTransaction); - final NormalizedNode actual = readStore(store, YangInstanceIdentifier.empty()); + final NormalizedNode actual = readStore(store, YangInstanceIdentifier.of()); assertEquals(expected, actual); } @@ -1859,9 +1864,9 @@ public class ShardTest extends AbstractShardTest { ShardLeaderStateChanged leaderStateChanged = MessageCollectorActor.expectFirstMatching(listener, ShardLeaderStateChanged.class); - assertTrue("getLocalShardDataTree present", leaderStateChanged.getLocalShardDataTree().isPresent()); - assertSame("getLocalShardDataTree", shard.underlyingActor().getDataStore().getDataTree(), - leaderStateChanged.getLocalShardDataTree().orElseThrow()); + final var dataTree = leaderStateChanged.localShardDataTree(); + assertNotNull("getLocalShardDataTree present", dataTree); + assertSame("getLocalShardDataTree", shard.underlyingActor().getDataStore().getDataTree(), dataTree); MessageCollectorActor.clearMessages(listener); @@ -1870,7 +1875,7 @@ public class ShardTest extends AbstractShardTest { shard.tell(new RequestVote(10000, "member2", 50, 50), testKit.getRef()); leaderStateChanged = MessageCollectorActor.expectFirstMatching(listener, ShardLeaderStateChanged.class); - assertFalse("getLocalShardDataTree present", leaderStateChanged.getLocalShardDataTree().isPresent()); + assertNull("getLocalShardDataTree present", leaderStateChanged.localShardDataTree()); } @Test