Remove superfluous ShardTest tests 16/114216/28
authorRobert Varga <robert.varga@pantheon.tech>
Sat, 26 Oct 2024 13:01:46 +0000 (15:01 +0200)
committerRobert Varga <robert.varga@pantheon.tech>
Mon, 28 Oct 2024 16:31:04 +0000 (17:31 +0100)
testCreateTransaction(OnChain)'s functionality has no
equivalent in Tell-based protocol. Remove these both.

testBatchedModificationsReadyWithIncorrectTotalMessageCount() tests just
an ask-based ordering specific -- we account for that through Envelope
sequencing instead.

testOnBatchedModificationsWhenNotLeader() is not applicable -- this test
scenario indicates NotLeaderException during connect -- and we already
check for that.

JIRA: CONTROLLER-2129
Change-Id: I7e19cc63a99873e8190c69aacb9bd3997df679cd
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/ShardTest.java

index 2b066dfad54eb3081c83657d4c09630da3b80705..7229fbadd7f5fbc9fdb1fc5d227c10a15f14bb87 100644 (file)
@@ -8,7 +8,6 @@
 package org.opendaylight.controller.cluster.datastore;
 
 import static org.apache.pekko.actor.ActorRef.noSender;
-import static org.hamcrest.CoreMatchers.containsString;
 import static org.hamcrest.CoreMatchers.endsWith;
 import static org.hamcrest.MatcherAssert.assertThat;
 import static org.junit.Assert.assertEquals;
@@ -18,7 +17,6 @@ import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertSame;
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
-import static org.junit.jupiter.api.Assertions.assertInstanceOf;
 import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.Mockito.doThrow;
 import static org.mockito.Mockito.inOrder;
@@ -37,7 +35,6 @@ import java.util.Optional;
 import java.util.Set;
 import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.TimeUnit;
-import java.util.concurrent.atomic.AtomicBoolean;
 import java.util.concurrent.atomic.AtomicReference;
 import org.apache.pekko.actor.ActorRef;
 import org.apache.pekko.actor.ActorSelection;
@@ -230,45 +227,6 @@ public class ShardTest extends AbstractShardTest {
         listener.waitForChangeEvents();
     }
 
-    @Test
-    public void testCreateTransaction() {
-        final ShardTestKit testKit = new ShardTestKit(getSystem());
-        final ActorRef shard = actorFactory.createActor(newShardProps(), "testCreateTransaction");
-
-        ShardTestKit.waitUntilLeader(shard);
-
-        shard.tell(new UpdateSchemaContext(TestModel.createTestContext()), testKit.getRef());
-
-        shard.tell(new CreateTransaction(nextTransactionId(), TransactionType.READ_ONLY.ordinal(),
-            DataStoreVersions.CURRENT_VERSION).toSerializable(), testKit.getRef());
-
-        final CreateTransactionReply reply = testKit.expectMsgClass(Duration.ofSeconds(3),
-            CreateTransactionReply.class);
-
-        final String path = reply.getTransactionPath().toString();
-        assertThat(path, containsString(String.format("/user/testCreateTransaction/shard-%s-%s:ShardTransactionTest@0:",
-            shardID.getShardName(), shardID.getMemberName().getName())));
-    }
-
-    @Test
-    public void testCreateTransactionOnChain() {
-        final ShardTestKit testKit = new ShardTestKit(getSystem());
-        final ActorRef shard = actorFactory.createActor(newShardProps(), "testCreateTransactionOnChain");
-
-        ShardTestKit.waitUntilLeader(shard);
-
-        shard.tell(new CreateTransaction(nextTransactionId(), TransactionType.READ_ONLY.ordinal(),
-            DataStoreVersions.CURRENT_VERSION).toSerializable(), testKit.getRef());
-
-        final CreateTransactionReply reply = testKit.expectMsgClass(Duration.ofSeconds(3),
-            CreateTransactionReply.class);
-
-        final String path = reply.getTransactionPath().toString();
-        assertThat(path, containsString(String.format(
-            "/user/testCreateTransactionOnChain/shard-%s-%s:ShardTransactionTest@0:",
-            shardID.getShardName(), shardID.getMemberName().getName())));
-    }
-
     @Test
     public void testPeerAddressResolved() {
         final ShardTestKit testKit = new ShardTestKit(getSystem());
@@ -634,28 +592,6 @@ public class ShardTest extends AbstractShardTest {
         verifyOuterListEntry(shard, 1);
     }
 
-    @Test
-    @Deprecated(since = "9.0.0", forRemoval = true)
-    public void testBatchedModificationsReadyWithIncorrectTotalMessageCount() {
-        final ShardTestKit testKit = new ShardTestKit(getSystem());
-        final TestActorRef<Shard> shard = actorFactory.createTestActor(
-            newShardProps().withDispatcher(Dispatchers.DefaultDispatcherId()),
-            "testBatchedModificationsReadyWithIncorrectTotalMessageCount");
-
-        ShardTestKit.waitUntilLeader(shard);
-
-        final TransactionIdentifier transactionID = nextTransactionId();
-        final BatchedModifications batched = new BatchedModifications(transactionID,
-            DataStoreVersions.CURRENT_VERSION);
-        batched.setReady();
-        batched.setTotalMessagesSent(2);
-
-        shard.tell(batched, testKit.getRef());
-
-        final Failure failure = testKit.expectMsgClass(Duration.ofSeconds(5), Failure.class);
-        assertInstanceOf(IllegalStateException.class, failure.cause());
-    }
-
     @Test
     @Deprecated(since = "9.0.0", forRemoval = true)
     public void testBatchedModificationsWithOperationFailure() {
@@ -746,47 +682,6 @@ public class ShardTest extends AbstractShardTest {
         assertEquals("Stored node", containerNode, actualNode);
     }
 
-    @Test
-    @Deprecated(since = "9.0.0", forRemoval = true)
-    public void testOnBatchedModificationsWhenNotLeader() {
-        final AtomicBoolean overrideLeaderCalls = new AtomicBoolean();
-        final ShardTestKit testKit = new ShardTestKit(getSystem());
-        final Creator<Shard> creator = new Creator<>() {
-            private static final long serialVersionUID = 1L;
-
-            @Override
-            public Shard create() {
-                return new Shard(newShardBuilder()) {
-                    @Override
-                    protected boolean isLeader() {
-                        return overrideLeaderCalls.get() ? false : super.isLeader();
-                    }
-
-                    @Override
-                    public ActorSelection getLeader() {
-                        return overrideLeaderCalls.get() ? getSystem().actorSelection(testKit.getRef().path())
-                                : super.getLeader();
-                    }
-                };
-            }
-        };
-
-        final TestActorRef<Shard> shard = actorFactory.createTestActor(Props.create(Shard.class,
-            new DelegatingShardCreator(creator)).withDispatcher(Dispatchers.DefaultDispatcherId()),
-            "testOnBatchedModificationsWhenNotLeader");
-
-        ShardTestKit.waitUntilLeader(shard);
-
-        overrideLeaderCalls.set(true);
-
-        final BatchedModifications batched = new BatchedModifications(nextTransactionId(),
-            DataStoreVersions.CURRENT_VERSION);
-
-        shard.tell(batched, noSender());
-
-        testKit.expectMsgEquals(batched);
-    }
-
     @Test
     @Deprecated(since = "9.0.0", forRemoval = true)
     public void testTransactionMessagesWithNoLeader() {