diff --git a/server/src/internalClusterTest/java/org/opensearch/snapshots/SnapshotStatusApisIT.java b/server/src/internalClusterTest/java/org/opensearch/snapshots/SnapshotStatusApisIT.java index 9e859fdb67009..c3214022df663 100644 --- a/server/src/internalClusterTest/java/org/opensearch/snapshots/SnapshotStatusApisIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/snapshots/SnapshotStatusApisIT.java @@ -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(); @@ -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 { diff --git a/server/src/main/java/org/opensearch/action/admin/cluster/snapshots/status/SnapshotStatus.java b/server/src/main/java/org/opensearch/action/admin/cluster/snapshots/status/SnapshotStatus.java index dbd7cc244c37b..77aa72025a0a2 100644 --- a/server/src/main/java/org/opensearch/action/admin/cluster/snapshots/status/SnapshotStatus.java +++ b/server/src/main/java/org/opensearch/action/admin/cluster/snapshots/status/SnapshotStatus.java @@ -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(); } else { @@ -107,6 +108,17 @@ public class SnapshotStatus implements ToXContentObject, Writeable { updateShardStats(startTime, time, initialTotalSizeInBytes); } + SnapshotStatus( + Snapshot snapshot, + State state, + List shards, + Boolean includeGlobalState, + long startTime, + long time + ) { + this(snapshot, state, shards, includeGlobalState, startTime, time, 0L); + } + SnapshotStatus( Snapshot snapshot, State state, @@ -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); } diff --git a/server/src/main/java/org/opensearch/cluster/ClusterInfo.java b/server/src/main/java/org/opensearch/cluster/ClusterInfo.java index 200dd53b9fe5a..8437446b0265f 100644 --- a/server/src/main/java/org/opensearch/cluster/ClusterInfo.java +++ b/server/src/main/java/org/opensearch/cluster/ClusterInfo.java @@ -96,15 +96,7 @@ public ClusterInfo( final Map reservedSpace, final Map nodeFileCacheStats ) { - this( - leastAvailableSpaceUsage, - mostAvailableSpaceUsage, - shardSizes, - routingToDataPath, - reservedSpace, - nodeFileCacheStats, - 0L - ); + this(leastAvailableSpaceUsage, mostAvailableSpaceUsage, shardSizes, routingToDataPath, reservedSpace, nodeFileCacheStats, 0L); } /** @@ -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 { @@ -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); } diff --git a/server/src/main/java/org/opensearch/snapshots/SnapshotInfo.java b/server/src/main/java/org/opensearch/snapshots/SnapshotInfo.java index 6d34db35c8bc1..d300e17ccdb78 100644 --- a/server/src/main/java/org/opensearch/snapshots/SnapshotInfo.java +++ b/server/src/main/java/org/opensearch/snapshots/SnapshotInfo.java @@ -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(); } } @@ -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); } }