@@ -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
@@ -306,13 +313,11 @@ public class RestTestsFromSnippetsTask extends SnippetsTask {
306313 * no shard succeeds. But we need to fail the tests on all of these
307314 * because they mean invalid syntax or broken queries or something
308315 * else that we don't want to teach people to do. The REST test
309- * framework doesn't allow us to has assertions in the setup
310- * section so we have to skip it there. We also have to skip _cat
311- * actions because they don't return json so we can't is_false
312- * them. That is ok because they don't have this
313- * partial-success-is-success thing.
316+ * framework doesn't allow us to have assertions in the setup
317+ * section so we have to skip it there. We also omit the assertion
318+ * from APIs that don't return a JSON object
314319 */
315- if (false == inSetup && false == path . startsWith( ' _cat ' )) {
320+ if (false == inSetup && shouldAddShardFailureCheck(path )) {
316321 current. println (" - is_false: _shards.failures" )
317322 }
318323 }
0 commit comments