Skip to content

Commit

Permalink
Added deletion test
Browse files Browse the repository at this point in the history
  • Loading branch information
merlimat committed Oct 9, 2024
1 parent 7d2a27b commit ee04a40
Showing 1 changed file with 33 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -625,47 +625,49 @@ void testSecondaryIndex() throws Exception {
@Cleanup
SyncOxiaClient client = OxiaClientBuilder.create(oxia.getServiceAddress()).syncClient();

client.put(
"si-a",
"0".getBytes(),
Set.of(PutOption.PartitionKey("x"), PutOption.SecondaryIndex("val", "0")));
client.put(
"si-b",
"1".getBytes(),
Set.of(PutOption.PartitionKey("x"), PutOption.SecondaryIndex("val", "1")));
client.put(
"si-c",
"2".getBytes(),
Set.of(PutOption.PartitionKey("x"), PutOption.SecondaryIndex("val", "2")));
client.put(
"si-d",
"3".getBytes(),
Set.of(PutOption.PartitionKey("x"), PutOption.SecondaryIndex("val", "3")));
client.put(
"si-e",
"4".getBytes(),
Set.of(PutOption.PartitionKey("x"), PutOption.SecondaryIndex("val", "4")));
client.put(
"si-f",
"5".getBytes(),
Set.of(PutOption.PartitionKey("x"), PutOption.SecondaryIndex("val", "5")));
client.put(
"si-g",
"6".getBytes(),
Set.of(PutOption.PartitionKey("x"), PutOption.SecondaryIndex("val", "6")));
client.put("si-a", "0".getBytes(),
Set.of(PutOption.SecondaryIndex("val", "0")));
client.put("si-b", "1".getBytes(),
Set.of(PutOption.SecondaryIndex("val", "1")));
client.put("si-c", "2".getBytes(),
Set.of(PutOption.SecondaryIndex("val", "2")));
client.put("si-d", "3".getBytes(),
Set.of(PutOption.SecondaryIndex("val", "3")));
client.put("si-e", "4".getBytes(),
Set.of(PutOption.SecondaryIndex("val", "4")));
client.put("si-f", "5".getBytes(),
Set.of(PutOption.SecondaryIndex("val", "5")));
client.put("si-g", "6".getBytes(),
Set.of(PutOption.SecondaryIndex("val", "6")));

List<String> list =
client.list("1", "4", Set.of(ListOption.PartitionKey("x"), ListOption.UseIndex("val")));
assertThat(list).isEqualTo(List.of("si-b", "si-c", "si-d"));
client.list("1", "4", Set.of(ListOption.UseIndex("val")));
assertThat(list).containsExactly("si-b", "si-c", "si-d");

Iterable<GetResult> iterable =
client.rangeScan(
"2", "5", Set.of(RangeScanOption.PartitionKey("x"), RangeScanOption.UseIndex("val")));
"2", "5", Set.of(RangeScanOption.UseIndex("val")));
list =
StreamSupport.stream(iterable.spliterator(), false)
.map(GetResult::getKey)
.sorted()
.toList();
assertThat(list).containsExactly("si-c", "si-d", "si-e");

// Deletion
client.delete("si-b");

list = client.list("0", "3", Set.of(ListOption.UseIndex("val")));
assertThat(list).containsExactly("si-a", "si-c");

iterable =
client.rangeScan(
"0", "3", Set.of(RangeScanOption.UseIndex("val")));
list =
StreamSupport.stream(iterable.spliterator(), false)
.map(GetResult::getKey)
.sorted()
.toList();
assertThat(list).containsExactly("si-a", "si-c");
}
}

0 comments on commit ee04a40

Please sign in to comment.