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=3e2313dc2780eab81c8a6c355751f8def2589905;hp=c5cd4635c320908b0650384b5e91407fc5a73269;hb=f276ae33b951d173b51c467bb7bb1a5f5cf9a1e6;hpb=3d4e718d0fe598b33e50b8d3bbcca3ff3bbb8b3a 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 c5cd4635c3..3e2313dc27 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 @@ -174,7 +174,7 @@ public class ShardTest extends AbstractShardTest { // it does do a persist) return new Shard(newShardBuilder()) { @Override - public void onReceiveCommand(final Object message) throws Exception { + public void handleCommand(final Object message) { if(message instanceof ElectionTimeout && firstElectionTimeout) { // Got the first ElectionTimeout. We don't forward it to the // base Shard yet until we've sent the RegisterChangeListener @@ -197,7 +197,7 @@ public class ShardTest extends AbstractShardTest { onFirstElectionTimeout.countDown(); } else { - super.onReceiveCommand(message); + super.handleCommand(message); } } }; @@ -286,7 +286,7 @@ public class ShardTest extends AbstractShardTest { public Shard create() throws Exception { return new Shard(newShardBuilder()) { @Override - public void onReceiveCommand(final Object message) throws Exception { + public void handleCommand(final Object message) { if(message instanceof ElectionTimeout && firstElectionTimeout) { firstElectionTimeout = false; final ActorRef self = getSelf(); @@ -301,7 +301,7 @@ public class ShardTest extends AbstractShardTest { onFirstElectionTimeout.countDown(); } else { - super.onReceiveCommand(message); + super.handleCommand(message); } } }; @@ -977,8 +977,12 @@ public class ShardTest extends AbstractShardTest { } @Test - public void testReadyWithImmediateCommit() throws Exception{ + public void testReadyWithReadWriteImmediateCommit() throws Exception{ testReadyWithImmediateCommit(true); + } + + @Test + public void testReadyWithWriteOnlyImmediateCommit() throws Exception{ testReadyWithImmediateCommit(false); } @@ -1089,9 +1093,13 @@ public class ShardTest extends AbstractShardTest { } @Test - public void testCommitWithPersistenceDisabled() throws Throwable { + public void testReadWriteCommitWithPersistenceDisabled() throws Throwable { + testCommitWithPersistenceDisabled(true); + } + + @Test + public void testWriteOnlyCommitWithPersistenceDisabled() throws Throwable { testCommitWithPersistenceDisabled(true); - testCommitWithPersistenceDisabled(false); } private void testCommitWithPersistenceDisabled(final boolean readWrite) throws Throwable { @@ -1141,8 +1149,12 @@ public class ShardTest extends AbstractShardTest { } @Test - public void testCommitWhenTransactionHasNoModifications() { + public void testReadWriteCommitWhenTransactionHasNoModifications() { testCommitWhenTransactionHasNoModifications(true); + } + + @Test + public void testWriteOnlyCommitWhenTransactionHasNoModifications() { testCommitWhenTransactionHasNoModifications(false); } @@ -1199,8 +1211,12 @@ public class ShardTest extends AbstractShardTest { } @Test - public void testCommitWhenTransactionHasModifications() { + public void testReadWriteCommitWhenTransactionHasModifications() { testCommitWhenTransactionHasModifications(true); + } + + @Test + public void testWriteOnlyCommitWhenTransactionHasModifications() { testCommitWhenTransactionHasModifications(false); } @@ -1277,7 +1293,7 @@ public class ShardTest extends AbstractShardTest { final ShardDataTreeCohort cohort1 = mock(ShardDataTreeCohort.class, "cohort1"); doReturn(Futures.immediateFuture(Boolean.TRUE)).when(cohort1).canCommit(); doReturn(Futures.immediateFuture(null)).when(cohort1).preCommit(); - doReturn(Futures.immediateFailedFuture(new IllegalStateException("mock"))).when(cohort1).commit(); + doReturn(Futures.immediateFailedFuture(new RuntimeException("mock"))).when(cohort1).commit(); doReturn(mockCandidate("cohort1-candidate")).when(cohort1).getCandidate(); final String transactionID2 = "tx2"; @@ -1995,9 +2011,9 @@ public class ShardTest extends AbstractShardTest { public Shard create() throws Exception { return new Shard(newShardBuilder()) { @Override - public void onReceiveCommand(final Object message) throws Exception { - super.onReceiveCommand(message); - if(message.equals(TX_COMMIT_TIMEOUT_CHECK_MESSAGE)) { + public void handleCommand(final Object message) { + super.handleCommand(message); + if(TX_COMMIT_TIMEOUT_CHECK_MESSAGE.equals(message)) { if(cleaupCheckLatch.get() != null) { cleaupCheckLatch.get().countDown(); } @@ -2094,7 +2110,8 @@ public class ShardTest extends AbstractShardTest { public void handleCommand(final Object message) { super.handleCommand(message); - if (message instanceof SaveSnapshotSuccess || message.equals("commit_snapshot")) { + // XXX: commit_snapshot equality check references RaftActorSnapshotMessageSupport.COMMIT_SNAPSHOT + if (message instanceof SaveSnapshotSuccess || "commit_snapshot".equals(message.toString())) { latch.get().countDown(); } } @@ -2273,11 +2290,11 @@ public class ShardTest extends AbstractShardTest { newShardProps().withDispatcher(Dispatchers.DefaultDispatcherId()), "testFollowerInitialSyncStatus"); - shard.underlyingActor().onReceiveCommand(new FollowerInitialSyncUpStatus(false, "member-1-shard-inventory-operational")); + shard.underlyingActor().handleNonRaftCommand(new FollowerInitialSyncUpStatus(false, "member-1-shard-inventory-operational")); assertEquals(false, shard.underlyingActor().getShardMBean().getFollowerInitialSyncStatus()); - shard.underlyingActor().onReceiveCommand(new FollowerInitialSyncUpStatus(true, "member-1-shard-inventory-operational")); + shard.underlyingActor().handleNonRaftCommand(new FollowerInitialSyncUpStatus(true, "member-1-shard-inventory-operational")); assertEquals(true, shard.underlyingActor().getShardMBean().getFollowerInitialSyncStatus()); }