rpuch commented on code in PR #7769:
URL: https://github.com/apache/ignite-3/pull/7769#discussion_r3039039467


##########
modules/placement-driver/src/test/java/org/apache/ignite/internal/placementdriver/leases/LeaseBatchSerializerTest.java:
##########
@@ -318,6 +320,71 @@ void v1CanBeDeserialized(String serializedString, 
List<Lease> expectedLeases) {
         );
     }
 
+    @Test
+    void v2CanBeDeserialized() {
+        LeaseBatch originalBatch = new LeaseBatch(createLeases(baseTs(), 
TablePartitionId::new));
+
+        byte[] bytes = VersionedSerialization.toBytes(originalBatch, 
serializer);
+
+        // VersionedSerializer header stores protocol version in the first 
byte.
+        assertEquals(2, bytes[0] & 0xFF);
+
+        LeaseBatch restoredBatch = VersionedSerialization.fromBytes(bytes, 
serializer);
+
+        assertThat(restoredBatch.leases(), 
containsInAnyOrder(originalBatch.leases().toArray()));
+        assertEquals(
+                
originalBatch.leases().stream().map(Lease::proposedCandidate).collect(toList()),
+                
restoredBatch.leases().stream().map(Lease::proposedCandidate).collect(toList())
+        );
+    }
+
+    @Test
+    void 
v2WithExactly8NamesAndMoreThan8NodeIdsDoesNotUseCompactNodesInfoEncoding() 
throws IOException {
+        List<Lease> originalLeases = new ArrayList<>();
+
+        for (int i = 0; i < 8; i++) {
+            originalLeases.add(tableLease("node" + i, new UUID(0, i + 1), 
null, i));
+        }
+
+        originalLeases.add(tableLease("node2", new UUID(0, 9), "node3", 8));
+
+        byte[] bytes = VersionedSerialization.toBytes(new 
LeaseBatch(originalLeases), serializer);
+
+        try (IgniteUnsafeDataInput in = new IgniteUnsafeDataInput(bytes)) {
+            in.readInt(); // Header written by VersionedSerializer.

Review Comment:
   Why do we need to read on such a low level (directly from the stream)?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to