Skip to content

Commit c3c56d2

Browse files
committed
more test assertions
1 parent 4768d27 commit c3c56d2

File tree

1 file changed

+23
-2
lines changed

1 file changed

+23
-2
lines changed

server/src/test/java/org/elasticsearch/snapshots/PerNodeShardSnapshotCounterTests.java

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,30 @@ public void testNodesCapacities() {
9494
assertFalse(perNodeShardSnapshotCounter.completeShardSnapshotOnNode(nonSnapshotNodeId));
9595
}
9696

97+
// Cannot complete where there is nothing running
9798
for (var snapshotNodeId : snapshotNodeIds) {
98-
assertTrue(perNodeShardSnapshotCounter.tryStartShardSnapshotOnNode(snapshotNodeId));
99-
assertTrue(perNodeShardSnapshotCounter.completeShardSnapshotOnNode(snapshotNodeId));
99+
assertFalse(perNodeShardSnapshotCounter.completeShardSnapshotOnNode(snapshotNodeId));
100+
}
101+
102+
// Can start up to the limit
103+
for (int i = 0; i < perNodeLimit; i++) {
104+
for (var snapshotNodeId : snapshotNodeIds) {
105+
assertTrue(perNodeShardSnapshotCounter.tryStartShardSnapshotOnNode(snapshotNodeId));
106+
}
107+
}
108+
// Cannot start beyond the limit
109+
for (var snapshotNodeId : snapshotNodeIds) {
110+
assertFalse(perNodeShardSnapshotCounter.tryStartShardSnapshotOnNode(snapshotNodeId));
111+
}
112+
// Can complete all started snapshots
113+
for (int i = 0; i < perNodeLimit; i++) {
114+
for (var snapshotNodeId : snapshotNodeIds) {
115+
assertTrue(perNodeShardSnapshotCounter.completeShardSnapshotOnNode(snapshotNodeId));
116+
}
117+
}
118+
// Cannot complete when nothing is running
119+
for (var snapshotNodeId : snapshotNodeIds) {
120+
assertFalse(perNodeShardSnapshotCounter.completeShardSnapshotOnNode(snapshotNodeId));
100121
}
101122
}
102123

0 commit comments

Comments
 (0)