dcapwell commented on code in PR #3310:
URL: https://github.com/apache/cassandra/pull/3310#discussion_r1605542371
##########
test/unit/org/apache/cassandra/service/accord/serializers/CommandsForKeySerializerTest.java:
##########
@@ -465,16 +469,46 @@ public void test()
next = txnIdGen.next(rs0);
return next;
}).unique().ofSizeBetween(0, 10).next(rs);
+ Arrays.sort(ids, Comparator.naturalOrder());
TxnInfo[] info = new TxnInfo[ids.length];
for (int i = 0; i < info.length; i++)
info[i] = TxnInfo.create(ids[i],
rs.pick(InternalStatus.values()), ids[i], CommandsForKey.NO_TXNIDS);
- Arrays.sort(info, Comparator.naturalOrder());
- CommandsForKey expected =
CommandsForKey.SerializerSupport.create(pk, info,
CommandsForKey.NO_PENDING_UNMANAGED);
+ Gen<Unmanaged.Pending> pendingGen =
Gens.enums().allMixedDistribution(Unmanaged.Pending.class).next(rs);
+
+ Unmanaged[] unmanaged = Gens.lists(txnIdGen)
+ .unique()
+ .ofSizeBetween(0, 10)
+ .map((rs0, txnIds) ->
txnIds.stream().map(i -> new Unmanaged(pendingGen.next(rs0), i,
i)).toArray(Unmanaged[]::new))
+ .next(rs);
+ Arrays.sort(unmanaged, Comparator.naturalOrder());
+ if (unmanaged.length > 0)
+ {
+ // when registering unmanaged, if the txn is "missing" in
TxnInfo we add it
+ List<TxnInfo> missing = new ArrayList<>(unmanaged.length);
+ for (Unmanaged u : unmanaged)
+ {
+ int idx = Arrays.binarySearch(ids, u.txnId);
+ if (idx < 0)
+ missing.add(TxnInfo.create(u.txnId,
InternalStatus.TRANSITIVELY_KNOWN));
+ }
+ if (!missing.isEmpty())
+ {
+ info = ArrayUtils.addAll(info,
missing.toArray(TxnInfo[]::new));
+ Arrays.sort(info, Comparator.naturalOrder());
+ }
+ }
+ else unmanaged = CommandsForKey.NO_PENDING_UNMANAGED;
+
+ CommandsForKey expected =
CommandsForKey.SerializerSupport.create(pk, info, unmanaged);
ByteBuffer buffer =
CommandsForKeySerializer.toBytesWithoutKey(expected);
CommandsForKey roundTrip = CommandsForKeySerializer.fromBytes(pk,
buffer);
Assert.assertEquals(expected, roundTrip);
+ // now validate unmanaged
+
Assertions.assertThat(roundTrip.unmanagedCount()).isEqualTo(expected.unmanagedCount());
Review Comment:
equals doesn't include... I don't know why...
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]