Skip to content

Commit

Permalink
Update IndexShardTests, Randomize remote store stats check in LocalTr…
Browse files Browse the repository at this point in the history
…anslogTests

Signed-off-by: Bhumika Saini <sabhumik@amazon.com>
  • Loading branch information
Bhumika Saini committed Sep 6, 2023
1 parent f88bb79 commit 36b20d8
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,8 @@ public RemoteTranslogStats getRemoteTranslogStats() {
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
builder.startObject(TRANSLOG);
addLocalTranslogStatsXContent(builder);
if (remoteTranslogStats != null) {
// TODO: V_2_10_0
if (remoteTranslogStats != null && Version.CURRENT.onOrAfter(Version.V_3_0_0)) {
builder = remoteTranslogStats.toXContent(builder, params);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4907,9 +4907,7 @@ public void testRecordsForceMerges() throws IOException {
}

private void populateSampleRemoteSegmentStats(RemoteSegmentTransferTracker tracker) {
tracker.addUploadBytesStarted(10L);
tracker.addUploadBytesStarted(10L);
tracker.addUploadBytesStarted(10L);
tracker.addUploadBytesStarted(30L);
tracker.addUploadBytesSucceeded(10L);
tracker.addUploadBytesFailed(10L);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -509,9 +509,23 @@ public void testStats() throws IOException {

{
final TranslogStats stats = stats();
// TODO: Once we can find a way to pass the version check in TranslogStats.toXContent()
// for a version before 2.10, we can change the "true" below to randomBoolean()
boolean shouldValidateRemoteStoreStats = true;
final BytesStreamOutput out = new BytesStreamOutput();
if (shouldValidateRemoteStoreStats == false) {
// Set a version before 2.10
out.setVersion(Version.V_2_0_0);
}

stats.writeTo(out);
final TranslogStats copy = new TranslogStats(out.bytes().streamInput());
StreamInput in = out.bytes().streamInput();
if (shouldValidateRemoteStoreStats == false) {
// Set a version before 2.10
in.setVersion(Version.V_2_0_0);
}

final TranslogStats copy = new TranslogStats(in);
assertThat(copy.estimatedNumberOfOperations(), equalTo(4));
assertThat(copy.getTranslogSizeInBytes(), equalTo(326L));

Expand Down

0 comments on commit 36b20d8

Please sign in to comment.