From ab01a692ac63299ef5a2e80e00c6bd1b04040b22 Mon Sep 17 00:00:00 2001 From: aggarwalShivani Date: Fri, 12 Apr 2024 23:47:43 +0530 Subject: [PATCH] Updated the testcases to reuse existing getSnapshotStatus() method Signed-off-by: aggarwalShivani --- CHANGELOG-3.0.md | 1 + .../snapshots/SnapshotStatusApisIT.java | 17 +++++------------ 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/CHANGELOG-3.0.md b/CHANGELOG-3.0.md index 0715c6de49ca4..7ce1516fb4bad 100644 --- a/CHANGELOG-3.0.md +++ b/CHANGELOG-3.0.md @@ -98,6 +98,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), - [Bug] Check phase name before SearchRequestOperationsListener onPhaseStart ([#12035](https://github.com/opensearch-project/OpenSearch/pull/12035)) - Fix Span operation names generated from RestActions ([#12005](https://github.com/opensearch-project/OpenSearch/pull/12005)) - Fix error in RemoteSegmentStoreDirectory when debug logging is enabled ([#12328](https://github.com/opensearch-project/OpenSearch/pull/12328)) +- Fix snapshot _status API to return correct status for partial snapshots ([#12812](https://github.com/opensearch-project/OpenSearch/pull/12812)) ### Security diff --git a/server/src/internalClusterTest/java/org/opensearch/snapshots/SnapshotStatusApisIT.java b/server/src/internalClusterTest/java/org/opensearch/snapshots/SnapshotStatusApisIT.java index e607b668fb334..c9af40f12b42a 100644 --- a/server/src/internalClusterTest/java/org/opensearch/snapshots/SnapshotStatusApisIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/snapshots/SnapshotStatusApisIT.java @@ -101,13 +101,9 @@ public void testStatusApiConsistency() { assertThat(snapshotInfo.state(), equalTo(SnapshotState.SUCCESS)); assertThat(snapshotInfo.version(), equalTo(Version.CURRENT)); - final List snapshotStatus = clusterAdmin().snapshotsStatus( - new SnapshotsStatusRequest("test-repo", new String[] { "test-snap" }) - ).actionGet().getSnapshots(); - assertThat(snapshotStatus.size(), equalTo(1)); - final SnapshotStatus snStatus = snapshotStatus.get(0); - assertEquals(snStatus.getStats().getStartTime(), snapshotInfo.startTime()); - assertEquals(snStatus.getStats().getTime(), snapshotInfo.endTime() - snapshotInfo.startTime()); + final SnapshotStatus snapshotStatus = getSnapshotStatus("test-repo", "test-snap"); + assertEquals(snapshotStatus.getStats().getStartTime(), snapshotInfo.startTime()); + assertEquals(snapshotStatus.getStats().getTime(), snapshotInfo.endTime() - snapshotInfo.startTime()); } public void testStatusAPICallForShallowCopySnapshot() { @@ -369,11 +365,8 @@ public void testSnapshotStatusOnPartialSnapshot() throws Exception { logger.info("--> stopping data node before creating snapshot"); stopNode(dataNode); startFullSnapshot(repoName, snapshotName, true).get(); - final List snapshotStatus = clusterAdmin().snapshotsStatus( - new SnapshotsStatusRequest(repoName, new String[] { snapshotName }) - ).actionGet().getSnapshots(); - assertThat(snapshotStatus.size(), equalTo(1)); - assertEquals(SnapshotsInProgress.State.PARTIAL, snapshotStatus.get(0).getState()); + final SnapshotStatus snapshotStatus = getSnapshotStatus(repoName, snapshotName); + assertEquals(SnapshotsInProgress.State.PARTIAL, snapshotStatus.getState()); } public void testStatusAPICallInProgressShallowSnapshot() throws Exception {