diff --git a/stacklight_tests/helpers/checkers.py b/stacklight_tests/helpers/checkers.py index 4adaef9..6f588aa 100644 --- a/stacklight_tests/helpers/checkers.py +++ b/stacklight_tests/helpers/checkers.py @@ -38,8 +38,8 @@ def check_http_get_response(url, expected_code=200, msg=None, **kwargs): :param url: the requested URL :type url: str - :param expected_code: the expected HTTP response code. Defaults to 200 - :type expected_code: int + :param expected_code: the expected HTTP response code(s). Defaults to 200 + :type expected_code: list(int) or int :param msg: the assertion message. Defaults to None :type msg: str :returns: HTTP response object @@ -50,8 +50,12 @@ def check_http_get_response(url, expected_code=200, msg=None, **kwargs): cert = helpers.get_fixture("https/rootCA.pem") msg = msg or "%s responded with {0}, expected {1}" % url r = s.get(url, verify=cert, **kwargs) - asserts.assert_equal( - r.status_code, expected_code, msg.format(r.status_code, expected_code)) + if isinstance(expected_code, int): + expected_code = [expected_code] + + asserts.assert_true( + r.status_code in expected_code, + msg.format(r.status_code, expected_code)) return r diff --git a/stacklight_tests/influxdb_grafana/api.py b/stacklight_tests/influxdb_grafana/api.py index 1f61068..642694c 100644 --- a/stacklight_tests/influxdb_grafana/api.py +++ b/stacklight_tests/influxdb_grafana/api.py @@ -107,7 +107,9 @@ class InfluxdbPluginApi(base_test.PluginApi): self.do_influxdb_query("show measurements") logger.info("Check that the InfluxDB user doesn't have admin rights") - self.do_influxdb_query("show stats", expected_code=401) + + # 401 is for InfluxDB 0.11 and 403 for InfluxDB 1.1 + self.do_influxdb_query("show stats", expected_code=[401, 403]) logger.info("Check that the InfluxDB root user has admin rights") self.do_influxdb_query("show stats",