Skip to content

Commit 5c00341

Browse files
authored
Handle 404s from the _cat/indices api in FullClusterRestartIT (#122537)
1 parent 5d48ded commit 5c00341

File tree

3 files changed

+18
-17
lines changed

3 files changed

+18
-17
lines changed

modules/ingest-geoip/qa/full-cluster-restart/src/javaRestTest/java/org/elasticsearch/ingest/geoip/FullClusterRestartIT.java

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import org.elasticsearch.common.settings.Settings;
2121
import org.elasticsearch.common.util.concurrent.ThreadContext;
2222
import org.elasticsearch.core.Nullable;
23+
import org.elasticsearch.rest.RestStatus;
2324
import org.elasticsearch.test.cluster.ElasticsearchCluster;
2425
import org.elasticsearch.test.cluster.FeatureFlag;
2526
import org.elasticsearch.test.cluster.local.distribution.DistributionType;
@@ -170,7 +171,7 @@ public void testGeoIpSystemFeaturesMigration() throws Exception {
170171
@SuppressWarnings("unchecked")
171172
private void testDatabasesLoaded() throws IOException {
172173
Request getTaskState = new Request("GET", "/_cluster/state");
173-
ObjectPath state = ObjectPath.createFromResponse(client().performRequest(getTaskState));
174+
ObjectPath state = ObjectPath.createFromResponse(assertOK(client().performRequest(getTaskState)));
174175

175176
List<?> tasks = state.evaluate("metadata.persistent_tasks.tasks");
176177
// Short-circuit to avoid using steams if the list is empty
@@ -196,7 +197,10 @@ private void testDatabasesLoaded() throws IOException {
196197

197198
private void testCatIndices(List<String> indexNames, @Nullable List<String> additionalIndexNames) throws IOException {
198199
Request catIndices = new Request("GET", "_cat/indices/*?s=index&h=index&expand_wildcards=all");
199-
String response = EntityUtils.toString(client().performRequest(catIndices).getEntity());
200+
// the cat APIs can sometimes 404, erroneously
201+
// see https://github.com/elastic/elasticsearch/issues/104371
202+
setIgnoredErrorResponseCodes(catIndices, RestStatus.NOT_FOUND);
203+
String response = EntityUtils.toString(assertOK(client().performRequest(catIndices)).getEntity());
200204
List<String> indices = List.of(response.trim().split("\\s+"));
201205

202206
if (additionalIndexNames != null && additionalIndexNames.isEmpty() == false) {
@@ -215,7 +219,7 @@ private void testIndexGeoDoc() throws IOException {
215219
assertOK(client().performRequest(putDoc));
216220

217221
Request getDoc = new Request("GET", "/my-index-00001/_doc/my_id");
218-
ObjectPath doc = ObjectPath.createFromResponse(client().performRequest(getDoc));
222+
ObjectPath doc = ObjectPath.createFromResponse(assertOK(client().performRequest(getDoc)));
219223
assertNull(doc.evaluate("_source.tags"));
220224
assertEquals("Sweden", doc.evaluate("_source.geo.country_name"));
221225
}
@@ -225,8 +229,7 @@ private void testGetStar(List<String> indexNames, @Nullable List<String> additio
225229
getStar.setOptions(
226230
RequestOptions.DEFAULT.toBuilder().setWarningsHandler(WarningsHandler.PERMISSIVE) // we don't care about warnings, just errors
227231
);
228-
Response response = client().performRequest(getStar);
229-
assertOK(response);
232+
Response response = assertOK(client().performRequest(getStar));
230233

231234
if (additionalIndexNames != null && additionalIndexNames.isEmpty() == false) {
232235
indexNames = new ArrayList<>(indexNames); // recopy into a mutable list
@@ -244,8 +247,7 @@ private void testGetStarAsKibana(List<String> indexNames, @Nullable List<String>
244247
.addHeader("X-elastic-product-origin", "kibana")
245248
.setWarningsHandler(WarningsHandler.PERMISSIVE) // we don't care about warnings, just errors
246249
);
247-
Response response = client().performRequest(getStar);
248-
assertOK(response);
250+
Response response = assertOK(client().performRequest(getStar));
249251

250252
if (additionalIndexNames != null && additionalIndexNames.isEmpty() == false) {
251253
indexNames = new ArrayList<>(indexNames); // recopy into a mutable list

muted-tests.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -323,9 +323,6 @@ tests:
323323
- class: org.elasticsearch.xpack.security.profile.ProfileIntegTests
324324
method: testSuggestProfileWithData
325325
issue: https://github.com/elastic/elasticsearch/issues/121258
326-
- class: org.elasticsearch.ingest.geoip.FullClusterRestartIT
327-
method: testGeoIpSystemFeaturesMigration {cluster=UPGRADED}
328-
issue: https://github.com/elastic/elasticsearch/issues/121115
329326
- class: org.elasticsearch.smoketest.DocsClientYamlTestSuiteIT
330327
method: test {yaml=reference/cat/health/cat-health-no-timestamp-example}
331328
issue: https://github.com/elastic/elasticsearch/issues/121867

qa/full-cluster-restart/src/javaRestTest/java/org/elasticsearch/upgrades/FullClusterRestartIT.java

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
import org.elasticsearch.index.IndexVersion;
3232
import org.elasticsearch.index.IndexVersions;
3333
import org.elasticsearch.index.mapper.DateFieldMapper;
34+
import org.elasticsearch.rest.RestStatus;
3435
import org.elasticsearch.rest.action.admin.indices.RestPutIndexTemplateAction;
3536
import org.elasticsearch.search.SearchFeatures;
3637
import org.elasticsearch.test.NotEqualMessageBuilder;
@@ -628,13 +629,14 @@ public void testRollover() throws Exception {
628629
)
629630
);
630631

631-
// assertBusy to work around https://github.com/elastic/elasticsearch/issues/104371
632-
assertBusy(
633-
() -> assertThat(
634-
EntityUtils.toString(client().performRequest(new Request("GET", "/_cat/indices?v&error_trace")).getEntity()),
635-
containsString("testrollover-000002")
636-
)
637-
);
632+
assertBusy(() -> {
633+
Request catIndices = new Request("GET", "/_cat/indices?v&error_trace");
634+
// the cat APIs can sometimes 404, erroneously
635+
// see https://github.com/elastic/elasticsearch/issues/104371
636+
setIgnoredErrorResponseCodes(catIndices, RestStatus.NOT_FOUND);
637+
Response response = assertOK(client().performRequest(catIndices));
638+
assertThat(EntityUtils.toString(response.getEntity()), containsString("testrollover-000002"));
639+
});
638640
}
639641

640642
Request countRequest = new Request("POST", "/" + index + "-*/_search");

0 commit comments

Comments
 (0)