@@ -34,9 +34,10 @@ public void testStatsGetWriteLoad() {
3434 10 ,
3535 1_800_000_000L , // totalIndexingTimeSinceShardStartedInNanos - 1.8sec
3636 3_000_000_000L , // totalActiveTimeInNanos - 3sec
37- 0.1357 // recentWriteLoad
37+ 0.1357
3838 );
39- assertThat (stats .getWriteLoad (), closeTo (0.6 , DOUBLE_TOLERANCE ));
39+ double expectedWriteLoad = 0.6 ; // 1.8sec / 3sec
40+ assertThat (stats .getWriteLoad (), closeTo (expectedWriteLoad , DOUBLE_TOLERANCE ));
4041 }
4142
4243 public void testStatsAdd_indexCount () {
@@ -121,9 +122,11 @@ public void testStatsAdd_writeLoads() {
121122 IndexingStats .Stats statsAgg = sumOfStats (stats1 , stats2 );
122123 // The unweighted write loads for the two shards are 0.5 (1sec / 2sec) and 0.7 (2.1sec / 3sec) respectively.
123124 // The aggregated value should be the average weighted by the times, i.e. by 2sec and 3sec, giving weights of 0.4 and 0.6.
124- assertThat ( statsAgg . getWriteLoad (), closeTo ( 0.4 * 0.5 + 0.6 * 0.7 , DOUBLE_TOLERANCE )) ;
125+ double expectedWriteLoad = 0.4 * 0.5 + 0.6 * 0.7 ;
125126 // The aggregated value for the recent write load should be the average with the same weights.
126- assertThat (statsAgg .getRecentWriteLoad (), closeTo (0.4 * 0.1357 + 0.6 * 0.2468 , DOUBLE_TOLERANCE ));
127+ double expectedRecentWriteLoad = 0.4 * 0.1357 + 0.6 * 0.2468 ;
128+ assertThat (statsAgg .getWriteLoad (), closeTo (expectedWriteLoad , DOUBLE_TOLERANCE ));
129+ assertThat (statsAgg .getRecentWriteLoad (), closeTo (expectedRecentWriteLoad , DOUBLE_TOLERANCE ));
127130 }
128131
129132 private static IndexingStats .Stats sumOfStats (IndexingStats .Stats stats1 , IndexingStats .Stats stats2 ) {
0 commit comments