Skip to content

Commit 3bd6084

Browse files
committed
Test for presence of additional status in node stats payload
1 parent 1c5bc3c commit 3bd6084

File tree

1 file changed

+19
-5
lines changed

1 file changed

+19
-5
lines changed

server/src/internalClusterTest/java/org/elasticsearch/snapshots/RepositorySnapshotStatsIT.java

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,18 +21,23 @@
2121

2222
import java.util.Collections;
2323

24+
import static org.hamcrest.Matchers.equalTo;
2425
import static org.hamcrest.Matchers.greaterThan;
26+
import static org.hamcrest.Matchers.lessThan;
2527

2628
@ESIntegTestCase.ClusterScope(numDataNodes = 0, scope = ESIntegTestCase.Scope.TEST)
2729
public class RepositorySnapshotStatsIT extends AbstractSnapshotIntegTestCase {
2830

29-
public void testRepositorySnapshotStats() throws Exception {
31+
public void testRepositorySnapshotStats() {
3032

3133
logger.info("--> starting a node");
3234
internalCluster().startNode();
3335

3436
logger.info("--> create index");
35-
createIndexWithRandomDocs("test-idx", 100);
37+
final int numberOfShards = randomIntBetween(2, 6);
38+
createIndex("test-idx", numberOfShards, 0);
39+
ensureGreen();
40+
indexRandomDocs("test-idx", 100);
3641

3742
IndicesStatsResponse indicesStats = indicesAdmin().prepareStats("test-idx").get();
3843
IndexStats indexStats = indicesStats.getIndex("test-idx");
@@ -70,9 +75,18 @@ public void testRepositorySnapshotStats() throws Exception {
7075
NodesStatsResponse response = clusterAdmin().prepareNodesStats().setRepositoryStats(true).get();
7176
RepositoriesStats stats = response.getNodes().get(0).getRepositoriesStats();
7277

78+
// These are just broad sanity checks on the values. There are more detailed checks in SnapshotMetricsIT
7379
assertTrue(stats.getRepositoryThrottlingStats().containsKey("test-repo"));
74-
assertTrue(stats.getRepositoryThrottlingStats().get("test-repo").totalWriteThrottledNanos() > 0);
75-
assertTrue(stats.getRepositoryThrottlingStats().get("test-repo").totalReadThrottledNanos() > 0);
76-
80+
RepositoriesStats.SnapshotStats snapshotStats = stats.getRepositoryThrottlingStats().get("test-repo");
81+
assertThat(snapshotStats.totalWriteThrottledNanos(), greaterThan(0L));
82+
assertThat(snapshotStats.totalReadThrottledNanos(), greaterThan(0L));
83+
assertThat(snapshotStats.shardSnapshotsStarted(), equalTo((long) numberOfShards));
84+
assertThat(snapshotStats.shardSnapshotsCompleted(), equalTo((long) numberOfShards));
85+
assertThat(snapshotStats.shardSnapshotsInProgress(), equalTo(0L));
86+
assertThat(snapshotStats.numberOfBlobsUploaded(), greaterThan(0L));
87+
assertThat(snapshotStats.numberOfBytesUploaded(), greaterThan(0L));
88+
assertThat(snapshotStats.totalUploadTimeInNanos(), greaterThan(0L));
89+
assertThat(snapshotStats.totalUploadReadTimeInNanos(), greaterThan(0L));
90+
assertThat(snapshotStats.totalUploadReadTimeInNanos(), lessThan(snapshotStats.totalUploadTimeInNanos()));
7791
}
7892
}

0 commit comments

Comments
 (0)