Improve tell-based protocol assumptions 89/98389/2
authorRobert Varga <robert.varga@pantheon.tech>
Wed, 10 Nov 2021 11:34:30 +0000 (12:34 +0100)
committerRobert Varga <robert.varga@pantheon.tech>
Wed, 10 Nov 2021 11:37:15 +0000 (12:37 +0100)
Make failures a bit more visible by comparing human-readable things.

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

index d5035b9..542a798 100644 (file)
@@ -37,7 +37,6 @@ import akka.testkit.javadsl.TestKit;
 import com.google.common.base.Stopwatch;
 import com.google.common.base.Throwables;
 import com.google.common.collect.ImmutableMap;
 import com.google.common.base.Stopwatch;
 import com.google.common.base.Throwables;
 import com.google.common.collect.ImmutableMap;
-import com.google.common.primitives.UnsignedLong;
 import com.google.common.util.concurrent.ListenableFuture;
 import com.google.common.util.concurrent.MoreExecutors;
 import com.google.common.util.concurrent.Uninterruptibles;
 import com.google.common.util.concurrent.ListenableFuture;
 import com.google.common.util.concurrent.MoreExecutors;
 import com.google.common.util.concurrent.Uninterruptibles;
@@ -84,6 +83,7 @@ import org.opendaylight.controller.cluster.datastore.persisted.FrontendClientMet
 import org.opendaylight.controller.cluster.datastore.persisted.FrontendShardDataTreeSnapshotMetadata;
 import org.opendaylight.controller.cluster.datastore.persisted.MetadataShardDataTreeSnapshot;
 import org.opendaylight.controller.cluster.datastore.persisted.ShardSnapshotState;
 import org.opendaylight.controller.cluster.datastore.persisted.FrontendShardDataTreeSnapshotMetadata;
 import org.opendaylight.controller.cluster.datastore.persisted.MetadataShardDataTreeSnapshot;
 import org.opendaylight.controller.cluster.datastore.persisted.ShardSnapshotState;
+import org.opendaylight.controller.cluster.datastore.utils.UnsignedLongBitmap;
 import org.opendaylight.controller.cluster.raft.base.messages.TimeoutNow;
 import org.opendaylight.controller.cluster.raft.client.messages.GetOnDemandRaftState;
 import org.opendaylight.controller.cluster.raft.client.messages.OnDemandRaftState;
 import org.opendaylight.controller.cluster.raft.base.messages.TimeoutNow;
 import org.opendaylight.controller.cluster.raft.client.messages.GetOnDemandRaftState;
 import org.opendaylight.controller.cluster.raft.client.messages.OnDemandRaftState;
@@ -370,10 +370,9 @@ public class DistributedDataStoreRemotingIntegrationTest extends AbstractTest {
             writeTx.write(CarsModel.newCarPath("car" + i), CarsModel.newCarEntry("car" + i, Uint64.valueOf(20000)));
             followerTestKit.doCommit(writeTx.ready());
 
             writeTx.write(CarsModel.newCarPath("car" + i), CarsModel.newCarEntry("car" + i, Uint64.valueOf(20000)));
             followerTestKit.doCommit(writeTx.ready());
 
-            DOMStoreReadTransaction domStoreReadTransaction = txChain.newReadOnlyTransaction();
-            domStoreReadTransaction.read(CarsModel.BASE_PATH).get();
-
-            domStoreReadTransaction.close();
+            try (var tx = txChain.newReadOnlyTransaction()) {
+                tx.read(CarsModel.BASE_PATH).get();
+            }
         }
 
         // wait to let the shard catch up with purged
         }
 
         // wait to let the shard catch up with purged
@@ -413,17 +412,11 @@ public class DistributedDataStoreRemotingIntegrationTest extends AbstractTest {
             metadata = iterator.next();
         }
 
             metadata = iterator.next();
         }
 
-        assertEquals(0, metadata.getClosedTransactions().size());
-
-        final var purgedRanges = metadata.getPurgedTransactions().ranges();
-
         // FIXME: CONTROLLER-1991: remove this assumption
         assumeTrue(false);
 
         // FIXME: CONTROLLER-1991: remove this assumption
         assumeTrue(false);
 
-        assertEquals(1, purgedRanges.size());
-        final var purgedRange = purgedRanges.first();
-        assertEquals(UnsignedLong.ZERO, purgedRange.lower());
-        assertEquals(UnsignedLong.valueOf(10), purgedRange.upper());
+        assertEquals(UnsignedLongBitmap.of(), metadata.getClosedTransactions());
+        assertEquals("[[0.." + numCars * 2 + "]]", metadata.getPurgedTransactions().toString());
     }
 
     @Test
     }
 
     @Test
@@ -445,10 +438,9 @@ public class DistributedDataStoreRemotingIntegrationTest extends AbstractTest {
             writeTx = txChain.newWriteOnlyTransaction();
             writeTx.close();
 
             writeTx = txChain.newWriteOnlyTransaction();
             writeTx.close();
 
-            DOMStoreReadTransaction domStoreReadTransaction = txChain.newReadOnlyTransaction();
-            domStoreReadTransaction.read(CarsModel.BASE_PATH).get();
-
-            domStoreReadTransaction.close();
+            try (var tx = txChain.newReadOnlyTransaction()) {
+                tx.read(CarsModel.BASE_PATH).get();
+            }
         }
 
         writeTx = txChain.newWriteOnlyTransaction();
         }
 
         writeTx = txChain.newWriteOnlyTransaction();