From: Robert Varga Date: Sat, 6 Nov 2021 09:08:05 +0000 (+0100) Subject: Correct Frontend{Client,History}Metadata deserialization X-Git-Tag: v4.0.6~8 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=commitdiff_plain;h=546cd1fd100dbaa36908b22c2f422320dbd8c4b2 Correct Frontend{Client,History}Metadata deserialization We are turning Range.closedOpen() into Range.closed() during deserialization, which the resulting ends up also covering the upper bound, which it should not. JIRA: CONTROLLER-1942 Change-Id: Ib8f9016e2eddcf014ff5e451ac82cd77b66d7019 Signed-off-by: Robert Varga --- diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/persisted/FrontendClientMetadata.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/persisted/FrontendClientMetadata.java index a3f41ed65d..c9b2430528 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/persisted/FrontendClientMetadata.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/persisted/FrontendClientMetadata.java @@ -78,7 +78,7 @@ public final class FrontendClientMetadata implements Identifiable new FrontendShardDataTreeSnapshotMetadata(null)); } @Test - public final void testCreateMetadataSnapshotEmptyInput() throws Exception { + public void testCreateMetadataSnapshotEmptyInput() throws Exception { final FrontendShardDataTreeSnapshotMetadata emptyOrigSnapshot = createEmptyMetadataSnapshot(); final FrontendShardDataTreeSnapshotMetadata emptyCopySnapshot = copy(emptyOrigSnapshot, 127); testMetadataSnapshotEqual(emptyOrigSnapshot, emptyCopySnapshot); } @Test - public final void testSerializeMetadataSnapshotWithOneClient() throws Exception { + public void testSerializeMetadataSnapshotWithOneClient() throws Exception { final FrontendShardDataTreeSnapshotMetadata origSnapshot = createMetadataSnapshot(1); final FrontendShardDataTreeSnapshotMetadata copySnapshot = copy(origSnapshot, 162); testMetadataSnapshotEqual(origSnapshot, copySnapshot); } @Test - public final void testSerializeMetadataSnapshotWithMoreClients() throws Exception { + public void testSerializeMetadataSnapshotWithMoreClients() throws Exception { final FrontendShardDataTreeSnapshotMetadata origSnapshot = createMetadataSnapshot(5); final FrontendShardDataTreeSnapshotMetadata copySnapshot = copy(origSnapshot, 314); testMetadataSnapshotEqual(origSnapshot, copySnapshot); @@ -68,7 +68,7 @@ public class FrontendShardDataTreeSnapshotMetadataTest { final List origClientList = origSnapshot.getClients(); final List copyClientList = copySnapshot.getClients(); - assertTrue(origClientList.size() == copyClientList.size()); + assertEquals(origClientList.size(), copyClientList.size()); final Map origIdent = new HashMap<>(); final Map copyIdent = new HashMap<>(); @@ -81,13 +81,13 @@ public class FrontendShardDataTreeSnapshotMetadataTest { origIdent.values().forEach(client -> { final FrontendClientMetadata copyClient = copyIdent.get(client.getIdentifier()); testObject(client.getIdentifier(), copyClient.getIdentifier()); - assertTrue(client.getPurgedHistories().equals(copyClient.getPurgedHistories())); - assertTrue(client.getCurrentHistories().equals(copyClient.getCurrentHistories())); + assertEquals(client.getPurgedHistories(), copyClient.getPurgedHistories()); + assertEquals(client.getCurrentHistories(), copyClient.getCurrentHistories()); }); } private static FrontendShardDataTreeSnapshotMetadata createEmptyMetadataSnapshot() { - return new FrontendShardDataTreeSnapshotMetadata(Collections.emptyList()); + return new FrontendShardDataTreeSnapshotMetadata(List.of()); } private static FrontendShardDataTreeSnapshotMetadata createMetadataSnapshot(final int size) { @@ -106,9 +106,9 @@ public class FrontendShardDataTreeSnapshotMetadataTest { final ClientIdentifier clientIdentifier = ClientIdentifier.create(frontendIdentifier, num); final RangeSet purgedHistories = TreeRangeSet.create(); - purgedHistories.add(Range.closed(UnsignedLong.ZERO, UnsignedLong.ONE)); + purgedHistories.add(Range.closedOpen(UnsignedLong.ZERO, UnsignedLong.ONE)); - final Collection currentHistories = Collections.singleton( + final Set currentHistories = Set.of( new FrontendHistoryMetadata(num, num, true, ImmutableMap.of(UnsignedLong.ZERO, Boolean.TRUE), purgedHistories));