|
21 | 21 |
|
22 | 22 | import java.util.Collections; |
23 | 23 |
|
| 24 | +import static org.hamcrest.Matchers.equalTo; |
24 | 25 | import static org.hamcrest.Matchers.greaterThan; |
| 26 | +import static org.hamcrest.Matchers.lessThan; |
25 | 27 |
|
26 | 28 | @ESIntegTestCase.ClusterScope(numDataNodes = 0, scope = ESIntegTestCase.Scope.TEST) |
27 | 29 | public class RepositorySnapshotStatsIT extends AbstractSnapshotIntegTestCase { |
28 | 30 |
|
29 | | - public void testRepositorySnapshotStats() throws Exception { |
| 31 | + public void testRepositorySnapshotStats() { |
30 | 32 |
|
31 | 33 | logger.info("--> starting a node"); |
32 | 34 | internalCluster().startNode(); |
33 | 35 |
|
34 | 36 | 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); |
36 | 41 |
|
37 | 42 | IndicesStatsResponse indicesStats = indicesAdmin().prepareStats("test-idx").get(); |
38 | 43 | IndexStats indexStats = indicesStats.getIndex("test-idx"); |
@@ -70,9 +75,18 @@ public void testRepositorySnapshotStats() throws Exception { |
70 | 75 | NodesStatsResponse response = clusterAdmin().prepareNodesStats().setRepositoryStats(true).get(); |
71 | 76 | RepositoriesStats stats = response.getNodes().get(0).getRepositoriesStats(); |
72 | 77 |
|
| 78 | + // These are just broad sanity checks on the values. There are more detailed checks in SnapshotMetricsIT |
73 | 79 | 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())); |
77 | 91 | } |
78 | 92 | } |
0 commit comments