Skip to content

Commit db9a2b6

Browse files
committed
Fixed failing BWC tests when listing views unexpectedly works
ES 8.x returns 405 because it sees _query/views as invalid GET _query ResponseException: method [GET], host [http://[::1]:38479], URI [/_query/views], status line [HTTP/1.1 405 Method Not Allowed]
1 parent 32b3f65 commit db9a2b6

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

x-pack/plugin/esql/qa/testFixtures/src/main/java/org/elasticsearch/xpack/esql/CsvTestsDataLoader.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -653,7 +653,8 @@ private static boolean clusterHasViewSupport(RestClient client, Logger logger) t
653653
} catch (ResponseException e) {
654654
logger.info("View listing error: {}", e.getMessage());
655655
int code = e.getResponse().getStatusLine().getStatusCode();
656-
if (code == 400 || code == 500) {
656+
// Different versions of Elasticsearch return different codes when views are not supported
657+
if (code == 400 || code == 500 || code == 405) {
657658
return false;
658659
}
659660
throw e;
@@ -667,8 +668,8 @@ private static void deleteView(RestClient client, String viewName, Logger logger
667668
} catch (ResponseException e) {
668669
logger.info("View delete error: {}", e.getMessage());
669670
int code = e.getResponse().getStatusLine().getStatusCode();
670-
// On older servers the view listing succeeds when it should, so we get here when we should not, hence the 400
671-
if (code != 404 && code != 400) {
671+
// On older servers the view listing succeeds when it should not, so we get here when we should not, hence the 400 and 500
672+
if (code != 404 && code != 400 && code != 500) {
672673
throw e;
673674
}
674675
}

0 commit comments

Comments
 (0)