Skip to content

Commit ce6150c

Browse files
committed
Add transaction tests
Signed-off-by: Andrew Carbonetto <[email protected]>
1 parent e559b87 commit ce6150c

File tree

2 files changed

+61
-22
lines changed

2 files changed

+61
-22
lines changed

java/integTest/src/test/java/glide/TransactionTestUtilities.java

Lines changed: 58 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
import glide.api.models.commands.geospatial.GeoUnit;
3838
import glide.api.models.commands.geospatial.GeospatialData;
3939
import glide.api.models.commands.stream.StreamAddOptions;
40+
import glide.api.models.commands.stream.StreamClaimOptions;
4041
import glide.api.models.commands.stream.StreamGroupOptions;
4142
import glide.api.models.commands.stream.StreamRange;
4243
import glide.api.models.commands.stream.StreamRange.IdBound;
@@ -66,29 +67,37 @@ public interface TransactionBuilder extends Function<BaseTransaction<?>, Object[
6667
/** Generate test samples for parametrized tests. Could be routed to random node. */
6768
public static Stream<Arguments> getCommonTransactionBuilders() {
6869
return Stream.of(
70+
// Arguments.of(
71+
// "Generic Commands", (TransactionBuilder)
72+
// TransactionTestUtilities::genericCommands),
73+
// Arguments.of(
74+
// "String Commands", (TransactionBuilder)
75+
// TransactionTestUtilities::stringCommands),
76+
// Arguments.of("Hash Commands", (TransactionBuilder)
77+
// TransactionTestUtilities::hashCommands),
78+
// Arguments.of("List Commands", (TransactionBuilder)
79+
// TransactionTestUtilities::listCommands),
80+
// Arguments.of("Set Commands", (TransactionBuilder)
81+
// TransactionTestUtilities::setCommands),
82+
// Arguments.of(
83+
// "Sorted Set Commands",
84+
// (TransactionBuilder) TransactionTestUtilities::sortedSetCommands),
85+
// Arguments.of(
86+
// "HyperLogLog Commands",
87+
// (TransactionBuilder)
88+
// TransactionTestUtilities::hyperLogLogCommands),
6989
Arguments.of(
70-
"Generic Commands", (TransactionBuilder) TransactionTestUtilities::genericCommands),
71-
Arguments.of(
72-
"String Commands", (TransactionBuilder) TransactionTestUtilities::stringCommands),
73-
Arguments.of("Hash Commands", (TransactionBuilder) TransactionTestUtilities::hashCommands),
74-
Arguments.of("List Commands", (TransactionBuilder) TransactionTestUtilities::listCommands),
75-
Arguments.of("Set Commands", (TransactionBuilder) TransactionTestUtilities::setCommands),
76-
Arguments.of(
77-
"Sorted Set Commands",
78-
(TransactionBuilder) TransactionTestUtilities::sortedSetCommands),
79-
Arguments.of(
80-
"HyperLogLog Commands",
81-
(TransactionBuilder) TransactionTestUtilities::hyperLogLogCommands),
82-
Arguments.of(
83-
"Stream Commands", (TransactionBuilder) TransactionTestUtilities::streamCommands),
84-
Arguments.of(
85-
"Connection Management Commands",
86-
(TransactionBuilder) TransactionTestUtilities::connectionManagementCommands),
87-
Arguments.of(
88-
"Geospatial Commands",
89-
(TransactionBuilder) TransactionTestUtilities::geospatialCommands),
90-
Arguments.of(
91-
"Bitmap Commands", (TransactionBuilder) TransactionTestUtilities::bitmapCommands));
90+
"Stream Commands", (TransactionBuilder) TransactionTestUtilities::streamCommands));
91+
// Arguments.of(
92+
// "Connection Management Commands",
93+
// (TransactionBuilder)
94+
// TransactionTestUtilities::connectionManagementCommands),
95+
// Arguments.of(
96+
// "Geospatial Commands",
97+
// (TransactionBuilder) TransactionTestUtilities::geospatialCommands),
98+
// Arguments.of(
99+
// "Bitmap Commands", (TransactionBuilder)
100+
// TransactionTestUtilities::bitmapCommands));
92101
}
93102

94103
/** Generate test samples for parametrized tests. Could be routed to primary nodes only. */
@@ -805,6 +814,22 @@ private static Object[] streamCommands(BaseTransaction<?> transaction) {
805814
groupName1,
806815
consumer1,
807816
StreamReadGroupOptions.builder().count(2L).build())
817+
.xclaim(streamKey1, groupName1, consumer1, 0L, new String[] {"0-1"})
818+
.xclaim(
819+
streamKey1,
820+
groupName1,
821+
consumer1,
822+
0L,
823+
new String[] {"0-3"},
824+
StreamClaimOptions.builder().force().build())
825+
.xclaimJustId(streamKey1, groupName1, consumer1, 0L, new String[] {"0-3"})
826+
.xclaimJustId(
827+
streamKey1,
828+
groupName1,
829+
consumer1,
830+
0L,
831+
new String[] {"0-4"},
832+
StreamClaimOptions.builder().force().build())
808833
.xpending(streamKey1, groupName1)
809834
.xack(streamKey1, groupName1, new String[] {"0-3"})
810835
.xpending(
@@ -850,6 +875,17 @@ private static Object[] streamCommands(BaseTransaction<?> transaction) {
850875
Map.of(
851876
streamKey1,
852877
Map.of()), // xreadgroup(Map.of(streamKey1, ">"), groupName1, consumer1, options);
878+
Map.of(), // xclaim(streamKey1, groupName1, consumer1, 0L, new String[] {"0-1"})
879+
Map.of(
880+
"0-3",
881+
new String[] {
882+
"field3", "value3"
883+
}), // xclaim(streamKey1, groupName1, consumer1, 0L, {"0-3"}, options)
884+
new String[] {
885+
"0-3"
886+
}, // xclaimJustId(streamKey1, groupName1, consumer1, 0L, new String[] {"0-3"})
887+
new String
888+
[0], // xclaimJustId(streamKey1, groupName1, consumer1, 0L, new String[] {"0-4"}, options)
853889
new Object[] {
854890
1L, "0-3", "0-3", new Object[][] {{consumer1, "1"}}
855891
}, // xpending(streamKey1, groupName1)

java/integTest/src/test/java/glide/cluster/ClusterTransactionTests.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,9 @@ public void transactions_with_group_of_commands(String testName, TransactionBuil
8585
Object[] expectedResult = builder.apply(transaction);
8686

8787
Object[] results = clusterClient.exec(transaction).get();
88+
if (testName.equals("Stream Commands")) {
89+
System.out.println(results);
90+
}
8891
assertDeepEquals(expectedResult, results);
8992
}
9093

0 commit comments

Comments
 (0)