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