You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/test/kotlin/org/opensearch/indexmanagement/indexstatemanagement/action/ConvertIndexToRemoteActionIT.kt
+21-26Lines changed: 21 additions & 26 deletions
Original file line number
Diff line number
Diff line change
@@ -131,36 +131,17 @@ class ConvertIndexToRemoteActionIT : IndexStateManagementRestTestCase() {
131
131
explainMetaData.info?.get("message"),
132
132
)
133
133
} catch (e:ResponseException) {
134
-
// If we get a 400 "no documents to get", the index was deleted (expected after restore)
135
-
if (e.response.restStatus() ==RestStatus.BAD_REQUEST) {
136
-
val errorBody = e.response.asMap()
137
-
val error = errorBody["error"] as?Map<*, *>
138
-
val reason = error?.get("reason") as?String
139
-
if (reason?.contains("no documents to get") ==true) {
140
-
// Index was deleted, which is expected - restore succeeded
141
-
// Just verify remote index exists below
142
-
return@waitFor
143
-
}
144
-
}
145
-
throw e // Re-throw if it's a different error
134
+
handleIndexDeletedException(e)
135
+
// Index was deleted, which is expected - restore succeeded
136
+
// Just verify remote index exists below
137
+
return@waitFor
146
138
}
147
139
}
148
140
}
149
141
} catch (e:ResponseException) {
150
-
// If we get a 400 "no documents to get", the index was deleted (expected after restore)
151
-
if (e.response.restStatus() ==RestStatus.BAD_REQUEST) {
152
-
val errorBody = e.response.asMap()
153
-
val error = errorBody["error"] as?Map<*, *>
154
-
val reason = error?.get("reason") as?String
155
-
if (reason?.contains("no documents to get") ==true) {
156
-
// Index was deleted, which is expected - restore succeeded
157
-
// Continue to verify remote index exists
158
-
} else {
159
-
throw e // Re-throw if it's a different error
160
-
}
161
-
} else {
162
-
throw e // Re-throw if it's not a 400
163
-
}
142
+
handleIndexDeletedException(e)
143
+
// Index was deleted, which is expected - restore succeeded
144
+
// Continue to verify remote index exists
164
145
}
165
146
166
147
val remoteIndexName ="${indexName}_remote"
@@ -169,4 +150,18 @@ class ConvertIndexToRemoteActionIT : IndexStateManagementRestTestCase() {
169
150
val isRemote = isIndexRemote(remoteIndexName)
170
151
assertTrue("Index $remoteIndexName is not a remote index", isRemote)
0 commit comments