[ML] Tolerate InternalAssumptionViolatedException in overridden test (elastic/x-pack-elasticsearch#1657)

In order for elastic/elasticsearch#25100 to work, overridden test()
methods that call ESClientYamlSuiteTestCase.test() must not consume
any InternalAssumptionViolatedException that
ESClientYamlSuiteTestCase.test() throws.

Relates elastic/x-pack-elasticsearch#1650

Original commit: elastic/x-pack-elasticsearch@081ccaa0a6
This commit is contained in:
David Roberts 2017-06-07 14:22:05 +01:00 committed by GitHub
parent 887538d6bc
commit f865755259
1 changed files with 11 additions and 5 deletions

View File

@ -22,12 +22,18 @@ public class MlWithSecurityInsufficientRoleIT extends MlWithSecurityIT {
@Override @Override
public void test() throws IOException { public void test() throws IOException {
AssertionError ae = expectThrows(AssertionError.class, super::test); try {
// Cannot use expectThrows here because blacklisted tests will throw an
// InternalAssumptionViolatedException rather than an AssertionError
super.test();
fail("should have failed because of missing role");
} catch (AssertionError ae) {
assertThat(ae.getMessage(), assertThat(ae.getMessage(),
either(containsString("action [cluster:monitor/xpack/ml")).or(containsString("action [cluster:admin/xpack/ml"))); either(containsString("action [cluster:monitor/xpack/ml")).or(containsString("action [cluster:admin/xpack/ml")));
assertThat(ae.getMessage(), containsString("returned [403 Forbidden]")); assertThat(ae.getMessage(), containsString("returned [403 Forbidden]"));
assertThat(ae.getMessage(), containsString("is unauthorized for user [no_ml]")); assertThat(ae.getMessage(), containsString("is unauthorized for user [no_ml]"));
} }
}
@Override @Override
protected String[] getCredentials() { protected String[] getCredentials() {