Skip to content

Commit

Permalink
Add version change todos and fix potential breaking changes
Browse files Browse the repository at this point in the history
Signed-off-by: Lakshya Taragi <[email protected]>
  • Loading branch information
ltaragi committed Sep 23, 2024
1 parent 77ccc5d commit cefa0bc
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ public void testStatusApiConsistency() {
assertEquals(snapshotStatus.getStats().getTime(), snapshotInfo.endTime() - snapshotInfo.startTime());
}

public void testStatusAPICallForShallowCopySnapshot() throws Exception {
public void testStatusAPICallForShallowCopySnapshot() {
disableRepoConsistencyCheck("Remote store repository is being used for the test");
internalCluster().startClusterManagerOnlyNode();
internalCluster().startDataOnlyNode();
Expand All @@ -136,24 +136,15 @@ public void testStatusAPICallForShallowCopySnapshot() throws Exception {
final String snapshot = "snapshot";
createFullSnapshot(snapshotRepoName, snapshot);

assertBusy(() -> {
final SnapshotStatus snapshotStatus = client().admin()
.cluster()
.prepareSnapshotStatus(snapshotRepoName)
.setSnapshots(snapshot)
.execute()
.actionGet()
.getSnapshots()
.get(0);
assertThat(snapshotStatus.getState(), is(SnapshotsInProgress.State.SUCCESS));
final SnapshotStatus snapshotStatus = getSnapshotStatus(snapshotRepoName, snapshot);
assertThat(snapshotStatus.getState(), is(SnapshotsInProgress.State.SUCCESS));

final SnapshotIndexShardStatus snapshotShardState = stateFirstShard(snapshotStatus, indexName);
assertThat(snapshotShardState.getStage(), is(SnapshotIndexShardStage.DONE));
assertThat(snapshotShardState.getStats().getTotalFileCount(), greaterThan(0));
assertThat(snapshotShardState.getStats().getTotalSize(), greaterThan(0L));
assertThat(snapshotShardState.getStats().getIncrementalFileCount(), greaterThan(0));
assertThat(snapshotShardState.getStats().getIncrementalSize(), greaterThan(0L));
}, 1, TimeUnit.MINUTES);
final SnapshotIndexShardStatus snapshotShardState = stateFirstShard(snapshotStatus, indexName);
assertThat(snapshotShardState.getStage(), is(SnapshotIndexShardStage.DONE));
assertThat(snapshotShardState.getStats().getTotalFileCount(), greaterThan(0));
assertThat(snapshotShardState.getStats().getTotalSize(), greaterThan(0L));
assertThat(snapshotShardState.getStats().getIncrementalFileCount(), greaterThan(0));
assertThat(snapshotShardState.getStats().getIncrementalSize(), greaterThan(0L));
}

public void testStatusAPICallInProgressSnapshot() throws Exception {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ public class SnapshotStatus implements ToXContentObject, Writeable {
includeGlobalState = in.readOptionalBoolean();
final long startTime = in.readLong();
final long time = in.readLong();
// TODO: change version to 2_18_0
if (in.getVersion().onOrAfter(Version.CURRENT)) {
initialTotalSizeInBytes = in.readOptionalLong();

Check warning on line 104 in server/src/main/java/org/opensearch/action/admin/cluster/snapshots/status/SnapshotStatus.java

View check run for this annotation

Codecov / codecov/patch

server/src/main/java/org/opensearch/action/admin/cluster/snapshots/status/SnapshotStatus.java#L104

Added line #L104 was not covered by tests
} else {
Expand All @@ -107,6 +108,17 @@ public class SnapshotStatus implements ToXContentObject, Writeable {
updateShardStats(startTime, time, initialTotalSizeInBytes);

Check warning on line 108 in server/src/main/java/org/opensearch/action/admin/cluster/snapshots/status/SnapshotStatus.java

View check run for this annotation

Codecov / codecov/patch

server/src/main/java/org/opensearch/action/admin/cluster/snapshots/status/SnapshotStatus.java#L108

Added line #L108 was not covered by tests
}

SnapshotStatus(
Snapshot snapshot,
State state,
List<SnapshotIndexShardStatus> shards,
Boolean includeGlobalState,
long startTime,
long time
) {
this(snapshot, state, shards, includeGlobalState, startTime, time, 0L);
}

Check warning on line 120 in server/src/main/java/org/opensearch/action/admin/cluster/snapshots/status/SnapshotStatus.java

View check run for this annotation

Codecov / codecov/patch

server/src/main/java/org/opensearch/action/admin/cluster/snapshots/status/SnapshotStatus.java#L119-L120

Added lines #L119 - L120 were not covered by tests

SnapshotStatus(
Snapshot snapshot,
State state,
Expand Down Expand Up @@ -217,6 +229,7 @@ public void writeTo(StreamOutput out) throws IOException {
out.writeOptionalBoolean(includeGlobalState);
out.writeLong(stats.getStartTime());
out.writeLong(stats.getTime());
// TODO: change version to 2_18_0
if (out.getVersion().onOrAfter(Version.CURRENT)) {
out.writeOptionalLong(initialTotalSizeInBytes);

Check warning on line 234 in server/src/main/java/org/opensearch/action/admin/cluster/snapshots/status/SnapshotStatus.java

View check run for this annotation

Codecov / codecov/patch

server/src/main/java/org/opensearch/action/admin/cluster/snapshots/status/SnapshotStatus.java#L234

Added line #L234 was not covered by tests
}
Expand Down
12 changes: 3 additions & 9 deletions server/src/main/java/org/opensearch/cluster/ClusterInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -96,15 +96,7 @@ public ClusterInfo(
final Map<NodeAndPath, ReservedSpace> reservedSpace,
final Map<String, FileCacheStats> nodeFileCacheStats
) {
this(
leastAvailableSpaceUsage,
mostAvailableSpaceUsage,
shardSizes,
routingToDataPath,
reservedSpace,
nodeFileCacheStats,
0L
);
this(leastAvailableSpaceUsage, mostAvailableSpaceUsage, shardSizes, routingToDataPath, reservedSpace, nodeFileCacheStats, 0L);
}

Check warning on line 100 in server/src/main/java/org/opensearch/cluster/ClusterInfo.java

View check run for this annotation

Codecov / codecov/patch

server/src/main/java/org/opensearch/cluster/ClusterInfo.java#L99-L100

Added lines #L99 - L100 were not covered by tests

/**
Expand Down Expand Up @@ -155,6 +147,7 @@ public ClusterInfo(StreamInput in) throws IOException {
} else {
this.nodeFileCacheStats = Map.of();
}
// TODO: change version to 2_18_0
if (in.getVersion().onOrAfter(Version.CURRENT)) {
this.primaryStoreSize = in.readOptionalLong();
} else {
Expand Down Expand Up @@ -205,6 +198,7 @@ public void writeTo(StreamOutput out) throws IOException {
if (out.getVersion().onOrAfter(Version.V_2_10_0)) {
out.writeMap(this.nodeFileCacheStats, StreamOutput::writeString, (o, v) -> v.writeTo(o));
}
// TODO: change version to 2_18_0
if (out.getVersion().onOrAfter(Version.CURRENT)) {
out.writeOptionalLong(this.primaryStoreSize);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -528,6 +528,9 @@ public SnapshotInfo(final StreamInput in) throws IOException {
}
if (in.getVersion().onOrAfter(Version.V_2_17_0)) {
pinnedTimestamp = in.readVLong();
}
// TODO: change version to 2_18_0
if (in.getVersion().onOrAfter(Version.CURRENT)) {
snapshotSizeInBytes = in.readVLong();
}
}
Expand Down Expand Up @@ -1012,6 +1015,9 @@ public void writeTo(final StreamOutput out) throws IOException {
}
if (out.getVersion().onOrAfter(Version.V_2_17_0)) {
out.writeVLong(pinnedTimestamp);
}
// TODO: change version to 2_18_0
if (out.getVersion().onOrAfter(Version.CURRENT)) {
out.writeVLong(snapshotSizeInBytes);
}
}
Expand Down

0 comments on commit cefa0bc

Please sign in to comment.