@@ -27,7 +27,6 @@ import org.gradle.api.tasks.OutputDirectory
2727
2828import java.nio.file.Files
2929import java.nio.file.Path
30- import java.util.regex.Matcher
3130
3231/**
3332 * Generates REST tests for each snippet marked // TEST.
@@ -100,6 +99,14 @@ public class RestTestsFromSnippetsTask extends SnippetsTask {
10099 return snippet. language == ' js' || snippet. curl
101100 }
102101
102+ /**
103+ * Certain requests should not have the shard failure check because the
104+ * format of the response is incompatible i.e. it is not a JSON object.
105+ */
106+ static shouldAddShardFailureCheck (String path ) {
107+ return path. startsWith(' _cat' ) == false && path. startsWith(' _xpack/ml/datafeeds/' ) == false
108+ }
109+
103110 /**
104111 * Converts Kibana's block quoted strings into standard JSON. These
105112 * {@code """ } delimited strings can be embedded in CONSOLE and can
@@ -309,13 +316,11 @@ public class RestTestsFromSnippetsTask extends SnippetsTask {
309316 * no shard succeeds. But we need to fail the tests on all of these
310317 * because they mean invalid syntax or broken queries or something
311318 * else that we don't want to teach people to do. The REST test
312- * framework doesn't allow us to has assertions in the setup
313- * section so we have to skip it there. We also have to skip _cat
314- * actions because they don't return json so we can't is_false
315- * them. That is ok because they don't have this
316- * partial-success-is-success thing.
319+ * framework doesn't allow us to have assertions in the setup
320+ * section so we have to skip it there. We also omit the assertion
321+ * from APIs that don't return a JSON object
317322 */
318- if (false == inSetup && false == path . startsWith( ' _cat ' )) {
323+ if (false == inSetup && shouldAddShardFailureCheck(path )) {
319324 current. println (" - is_false: _shards.failures" )
320325 }
321326 }
0 commit comments