From f8657552590928d34ad22735334dc0b04deb9321 Mon Sep 17 00:00:00 2001 From: David Roberts Date: Wed, 7 Jun 2017 14:22:05 +0100 Subject: [PATCH] [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@081ccaa0a6f2ec12d149bfaf415b59935fbcbb50 --- .../MlWithSecurityInsufficientRoleIT.java | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/qa/smoke-test-ml-with-security/src/test/java/org/elasticsearch/smoketest/MlWithSecurityInsufficientRoleIT.java b/qa/smoke-test-ml-with-security/src/test/java/org/elasticsearch/smoketest/MlWithSecurityInsufficientRoleIT.java index 60b0ef4e984..16c3716c283 100644 --- a/qa/smoke-test-ml-with-security/src/test/java/org/elasticsearch/smoketest/MlWithSecurityInsufficientRoleIT.java +++ b/qa/smoke-test-ml-with-security/src/test/java/org/elasticsearch/smoketest/MlWithSecurityInsufficientRoleIT.java @@ -22,11 +22,17 @@ public class MlWithSecurityInsufficientRoleIT extends MlWithSecurityIT { @Override public void test() throws IOException { - AssertionError ae = expectThrows(AssertionError.class, super::test); - assertThat(ae.getMessage(), - 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("is unauthorized for user [no_ml]")); + 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(), + 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("is unauthorized for user [no_ml]")); + } } @Override