From 10c01cba61bf32f5845dfcf135be4e063f56442b Mon Sep 17 00:00:00 2001 From: Mark Andrews Date: Fri, 17 Sep 2021 16:34:25 +1000 Subject: [PATCH] Don't tests stats channels that haven't been configured pytest was failing because it was testing features that had not been configured. test to see if those features have been configured before running the tests. --- bin/tests/system/statschannel/tests-json.py | 10 ++++++++++ bin/tests/system/statschannel/tests-xml.py | 10 ++++++++++ 2 files changed, 20 insertions(+) diff --git a/bin/tests/system/statschannel/tests-json.py b/bin/tests/system/statschannel/tests-json.py index fd0284233e..33cc0b1f96 100755 --- a/bin/tests/system/statschannel/tests-json.py +++ b/bin/tests/system/statschannel/tests-json.py @@ -12,6 +12,8 @@ from datetime import datetime +import os + import pytest import requests @@ -72,6 +74,8 @@ def load_zone_json(zone): @pytest.mark.json @pytest.mark.requests +@pytest.mark.skipif(os.getenv("HAVEJSONSTATS", "unset") != "1", + reason="JSON not configured") def test_zone_timers_primary_json(statsport): generic.test_zone_timers_primary(fetch_zones_json, load_timers_json, statsip="10.53.0.1", statsport=statsport, @@ -80,6 +84,8 @@ def test_zone_timers_primary_json(statsport): @pytest.mark.json @pytest.mark.requests +@pytest.mark.skipif(os.getenv("HAVEJSONSTATS", "unset") != "1", + reason="JSON not configured") def test_zone_timers_secondary_json(statsport): generic.test_zone_timers_secondary(fetch_zones_json, load_timers_json, statsip="10.53.0.3", statsport=statsport, @@ -88,6 +94,8 @@ def test_zone_timers_secondary_json(statsport): @pytest.mark.json @pytest.mark.requests +@pytest.mark.skipif(os.getenv("HAVEJSONSTATS", "unset") != "1", + reason="JSON not configured") def test_zone_with_many_keys_json(statsport): generic.test_zone_with_many_keys(fetch_zones_json, load_zone_json, statsip="10.53.0.2", statsport=statsport) @@ -96,6 +104,8 @@ def test_zone_with_many_keys_json(statsport): @pytest.mark.json @pytest.mark.requests @pytest.mark.dnspython +@pytest.mark.skipif(os.getenv("HAVEJSONSTATS", "unset") != "1", + reason="JSON not configured") def test_traffic_json(port, statsport): generic.test_traffic(fetch_traffic_json, statsip="10.53.0.2", statsport=statsport, diff --git a/bin/tests/system/statschannel/tests-xml.py b/bin/tests/system/statschannel/tests-xml.py index 3f1b0d7236..b181385cbc 100755 --- a/bin/tests/system/statschannel/tests-xml.py +++ b/bin/tests/system/statschannel/tests-xml.py @@ -13,6 +13,8 @@ import xml.etree.ElementTree as ET from datetime import datetime +import os + import pytest import requests @@ -102,6 +104,8 @@ def load_zone_xml(zone): @pytest.mark.xml @pytest.mark.requests +@pytest.mark.skipif(os.getenv("HAVEXMLSTATS", "unset") != "1", + reason="XML not configured") def test_zone_timers_primary_xml(statsport): generic.test_zone_timers_primary(fetch_zones_xml, load_timers_xml, statsip="10.53.0.1", statsport=statsport, @@ -110,6 +114,8 @@ def test_zone_timers_primary_xml(statsport): @pytest.mark.xml @pytest.mark.requests +@pytest.mark.skipif(os.getenv("HAVEXMLSTATS", "unset") != "1", + reason="XML not configured") def test_zone_timers_secondary_xml(statsport): generic.test_zone_timers_secondary(fetch_zones_xml, load_timers_xml, statsip="10.53.0.3", statsport=statsport, @@ -118,6 +124,8 @@ def test_zone_timers_secondary_xml(statsport): @pytest.mark.xml @pytest.mark.requests +@pytest.mark.skipif(os.getenv("HAVEXMLSTATS", "unset") != "1", + reason="XML not configured") def test_zone_with_many_keys_xml(statsport): generic.test_zone_with_many_keys(fetch_zones_xml, load_zone_xml, statsip="10.53.0.2", statsport=statsport) @@ -126,6 +134,8 @@ def test_zone_with_many_keys_xml(statsport): @pytest.mark.xml @pytest.mark.requests @pytest.mark.dnspython +@pytest.mark.skipif(os.getenv("HAVEXMLSTATS", "unset") != "1", + reason="XML not configured") def test_traffic_xml(port, statsport): generic.test_traffic(fetch_traffic_xml, statsip="10.53.0.2", statsport=statsport,