@@ -27,7 +27,6 @@ import org.gradle.api.tasks.OutputDirectory
27
27
28
28
import java.nio.file.Files
29
29
import java.nio.file.Path
30
- import java.util.regex.Matcher
31
30
32
31
/**
33
32
* Generates REST tests for each snippet marked // TEST.
@@ -100,6 +99,14 @@ public class RestTestsFromSnippetsTask extends SnippetsTask {
100
99
return snippet. language == ' js' || snippet. curl
101
100
}
102
101
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
+
103
110
/**
104
111
* Converts Kibana's block quoted strings into standard JSON. These
105
112
* {@code """ } delimited strings can be embedded in CONSOLE and can
@@ -308,13 +315,11 @@ public class RestTestsFromSnippetsTask extends SnippetsTask {
308
315
* no shard succeeds. But we need to fail the tests on all of these
309
316
* because they mean invalid syntax or broken queries or something
310
317
* 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
316
321
*/
317
- if (false == inSetup && false == path . startsWith( ' _cat ' )) {
322
+ if (false == inSetup && shouldAddShardFailureCheck(path )) {
318
323
current. println (" - is_false: _shards.failures" )
319
324
}
320
325
}
0 commit comments