From 002abda521f9a476148f11ad381df97e14cdfcf0 Mon Sep 17 00:00:00 2001 From: Lakshya Taragi Date: Tue, 3 Sep 2024 13:11:36 +0530 Subject: [PATCH] Fix build Signed-off-by: Lakshya Taragi --- .../snapshots/SnapshotStatusApisIT.java | 27 ++++++++++++------- .../snapshots/status/SnapshotStatus.java | 17 +----------- 2 files changed, 19 insertions(+), 25 deletions(-) diff --git a/server/src/internalClusterTest/java/org/opensearch/snapshots/SnapshotStatusApisIT.java b/server/src/internalClusterTest/java/org/opensearch/snapshots/SnapshotStatusApisIT.java index 5a043e69e9735..f88e8449154f5 100644 --- a/server/src/internalClusterTest/java/org/opensearch/snapshots/SnapshotStatusApisIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/snapshots/SnapshotStatusApisIT.java @@ -115,7 +115,7 @@ public void testStatusApiConsistency() { assertEquals(snapshotStatus.getStats().getTime(), snapshotInfo.endTime() - snapshotInfo.startTime()); } - public void testStatusAPICallForShallowCopySnapshot() { + public void testStatusAPICallForShallowCopySnapshot() throws Exception { disableRepoConsistencyCheck("Remote store repository is being used for the test"); internalCluster().startClusterManagerOnlyNode(); internalCluster().startDataOnlyNode(); @@ -135,15 +135,24 @@ public void testStatusAPICallForShallowCopySnapshot() { final String snapshot = "snapshot"; createFullSnapshot(snapshotRepoName, snapshot); - final SnapshotStatus snapshotStatus = getSnapshotStatus(snapshotRepoName, snapshot); - assertThat(snapshotStatus.getState(), is(SnapshotsInProgress.State.SUCCESS)); + assertBusy(() -> { + final SnapshotStatus snapshotStatus = client().admin() + .cluster() + .prepareSnapshotStatus(snapshotRepoName) + .setSnapshots(snapshot) + .execute() + .actionGet() + .getSnapshots() + .get(0); + 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)); + 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); } 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 e27c404c6e6bc..dbd7cc244c37b 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 @@ -240,7 +240,6 @@ public SnapshotStats getStats() { private static final String STATE = "state"; private static final String INDICES = "indices"; private static final String INCLUDE_GLOBAL_STATE = "include_global_state"; - private static final String INITIAL_TOTAL_SIZE_IN_BYTES = "initial_total_size_in_bytes"; @Override public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { @@ -252,9 +251,6 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws if (includeGlobalState != null) { builder.field(INCLUDE_GLOBAL_STATE, includeGlobalState); } - if (initialTotalSizeInBytes != 0) { - builder.field(INITIAL_TOTAL_SIZE_IN_BYTES, initialTotalSizeInBytes); - } builder.field(SnapshotShardsStats.Fields.SHARDS_STATS, shardsStats, params); builder.field(SnapshotStats.Fields.STATS, stats, params); builder.startObject(INDICES); @@ -276,7 +272,6 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws String uuid = (String) parsedObjects[i++]; String rawState = (String) parsedObjects[i++]; Boolean includeGlobalState = (Boolean) parsedObjects[i++]; - Long initialTotalSizeInBytes = (Long) parsedObjects[i++]; SnapshotStats stats = ((SnapshotStats) parsedObjects[i++]); SnapshotShardsStats shardsStats = ((SnapshotShardsStats) parsedObjects[i++]); @SuppressWarnings("unchecked") @@ -297,16 +292,7 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws shards.addAll(index.getShards().values()); } } - return new SnapshotStatus( - snapshot, - state, - shards, - indicesStatus, - shardsStats, - stats, - includeGlobalState, - initialTotalSizeInBytes - ); + return new SnapshotStatus(snapshot, state, shards, indicesStatus, shardsStats, stats, includeGlobalState, 0L); } ); static { @@ -315,7 +301,6 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws PARSER.declareString(constructorArg(), new ParseField(UUID)); PARSER.declareString(constructorArg(), new ParseField(STATE)); PARSER.declareBoolean(optionalConstructorArg(), new ParseField(INCLUDE_GLOBAL_STATE)); - PARSER.declareLong(optionalConstructorArg(), new ParseField(INITIAL_TOTAL_SIZE_IN_BYTES)); PARSER.declareField( constructorArg(), SnapshotStats::fromXContent,