From 0a7b3a9f912e3770bd809e41e97e20f9562f7e63 Mon Sep 17 00:00:00 2001 From: Eyal Date: Mon, 22 Jan 2018 12:29:11 +0200 Subject: [PATCH] suppress ResourceWarning: unclosed socket lets remove this clutter while testing Change-Id: Ib31ea5b98e705098acf317f032bf80e2e8981f88 --- .../tests/api/alarms/base.py | 6 +++++ .../tests/api/alarms/test_alarms.py | 6 +++++ vitrage_tempest_tests/tests/api/rca/base.py | 6 +++++ .../tests/api/rca/test_rca.py | 6 +++++ .../tests/api/resources/test_resources.py | 6 +++++ .../tests/api/templates/base.py | 6 +++++ .../tests/api/templates/test_template.py | 6 +++++ .../tests/api/topology/base.py | 6 +++++ .../tests/api/topology/test_topology.py | 6 +++++ vitrage_tempest_tests/tests/base.py | 22 +++++++++++++++++++ .../tests/database/test_persistor.py | 6 +++++ .../tests/datasources/test_aodh.py | 6 +++++ .../tests/datasources/test_cinder_volume.py | 6 +++++ .../tests/datasources/test_heat_stack.py | 6 +++++ .../tests/datasources/test_neutron.py | 6 +++++ .../tests/datasources/test_nova.py | 6 +++++ .../tests/datasources/test_static_physical.py | 6 +++++ .../tests/e2e/test_actions_base.py | 6 +++++ .../tests/e2e/test_basic_actions.py | 6 +++++ .../tests/e2e/test_overlapping_actions.py | 9 +++++++- .../tests/notifiers/test_mistral_notifier.py | 6 +++++ 21 files changed, 144 insertions(+), 1 deletion(-) diff --git a/vitrage_tempest_tests/tests/api/alarms/base.py b/vitrage_tempest_tests/tests/api/alarms/base.py index 068dce21d..5921071a0 100644 --- a/vitrage_tempest_tests/tests/api/alarms/base.py +++ b/vitrage_tempest_tests/tests/api/alarms/base.py @@ -24,6 +24,12 @@ TEMPLATES_SOURCES_PATH = '/etc/vitrage/templates/' class BaseAlarmsTest(BaseVitrageTempest): """Topology test class for Vitrage API tests.""" + def setUp(self): + super(BaseAlarmsTest, self).setUp() + + def tearDown(self): + super(BaseAlarmsTest, self).tearDown() + @classmethod def setUpClass(cls): super(BaseAlarmsTest, cls).setUpClass() diff --git a/vitrage_tempest_tests/tests/api/alarms/test_alarms.py b/vitrage_tempest_tests/tests/api/alarms/test_alarms.py index c7544411f..7da9ecee8 100644 --- a/vitrage_tempest_tests/tests/api/alarms/test_alarms.py +++ b/vitrage_tempest_tests/tests/api/alarms/test_alarms.py @@ -32,6 +32,12 @@ LOG = logging.getLogger(__name__) class TestAlarms(BaseAlarmsTest): """Alarms test class for Vitrage API tests.""" + def setUp(self): + super(TestAlarms, self).setUp() + + def tearDown(self): + super(TestAlarms, self).tearDown() + @classmethod def setUpClass(cls): super(TestAlarms, cls).setUpClass() diff --git a/vitrage_tempest_tests/tests/api/rca/base.py b/vitrage_tempest_tests/tests/api/rca/base.py index 4fb41c67e..2dd8ebd2b 100644 --- a/vitrage_tempest_tests/tests/api/rca/base.py +++ b/vitrage_tempest_tests/tests/api/rca/base.py @@ -42,6 +42,12 @@ VITRAGE_ALARM_NAME = 'instance_deduce' class BaseRcaTest(BaseAlarmsTest): + def setUp(self): + super(BaseRcaTest, self).setUp() + + def tearDown(self): + super(BaseRcaTest, self).tearDown() + @classmethod def setUpClass(cls): super(BaseRcaTest, cls).setUpClass() diff --git a/vitrage_tempest_tests/tests/api/rca/test_rca.py b/vitrage_tempest_tests/tests/api/rca/test_rca.py index 9ce01020d..eb451df6c 100644 --- a/vitrage_tempest_tests/tests/api/rca/test_rca.py +++ b/vitrage_tempest_tests/tests/api/rca/test_rca.py @@ -29,6 +29,12 @@ LOG = logging.getLogger(__name__) class TestRca(BaseRcaTest): """RCA test class for Vitrage API tests.""" + def setUp(self): + super(TestRca, self).setUp() + + def tearDown(self): + super(TestRca, self).tearDown() + @classmethod def setUpClass(cls): super(TestRca, cls).setUpClass() diff --git a/vitrage_tempest_tests/tests/api/resources/test_resources.py b/vitrage_tempest_tests/tests/api/resources/test_resources.py index 2facd679f..3866bc841 100644 --- a/vitrage_tempest_tests/tests/api/resources/test_resources.py +++ b/vitrage_tempest_tests/tests/api/resources/test_resources.py @@ -38,6 +38,12 @@ class TestResource(BaseVitrageTempest): VProps.STATE, VProps.VITRAGE_AGGREGATED_STATE) + def setUp(self): + super(TestResource, self).setUp() + + def tearDown(self): + super(TestResource, self).tearDown() + @classmethod def setUpClass(cls): super(TestResource, cls).setUpClass() diff --git a/vitrage_tempest_tests/tests/api/templates/base.py b/vitrage_tempest_tests/tests/api/templates/base.py index 5f8ce4380..2b959e5ac 100644 --- a/vitrage_tempest_tests/tests/api/templates/base.py +++ b/vitrage_tempest_tests/tests/api/templates/base.py @@ -40,6 +40,12 @@ class BaseTemplateTest(BaseVitrageTempest): OK_STATUS = 'validation OK' OK_MSG = 'Template validation is OK' + def setUp(self): + super(BaseTemplateTest, self).setUp() + + def tearDown(self): + super(BaseTemplateTest, self).tearDown() + @classmethod def setUpClass(cls): super(BaseTemplateTest, cls).setUpClass() diff --git a/vitrage_tempest_tests/tests/api/templates/test_template.py b/vitrage_tempest_tests/tests/api/templates/test_template.py index 37b5a3645..a564cf766 100644 --- a/vitrage_tempest_tests/tests/api/templates/test_template.py +++ b/vitrage_tempest_tests/tests/api/templates/test_template.py @@ -40,6 +40,12 @@ FAKE_UUID = 'ade68276-0fe9-42cd-9ec2-e7f20470a771' class TestValidate(BaseTemplateTest): """Template test class for Vitrage API tests.""" + def setUp(self): + super(TestValidate, self).setUp() + + def tearDown(self): + super(TestValidate, self).tearDown() + @classmethod def setUpClass(cls): super(TestValidate, cls).setUpClass() diff --git a/vitrage_tempest_tests/tests/api/topology/base.py b/vitrage_tempest_tests/tests/api/topology/base.py index 99e314cb2..c25cddb47 100644 --- a/vitrage_tempest_tests/tests/api/topology/base.py +++ b/vitrage_tempest_tests/tests/api/topology/base.py @@ -26,6 +26,12 @@ from vitrage_tempest_tests.tests.common import nova_utils class BaseTopologyTest(BaseVitrageTempest): """Topology test class for Vitrage API tests.""" + def setUp(self): + super(BaseTopologyTest, self).setUp() + + def tearDown(self): + super(BaseTopologyTest, self).tearDown() + @classmethod def setUpClass(cls): super(BaseTopologyTest, cls).setUpClass() diff --git a/vitrage_tempest_tests/tests/api/topology/test_topology.py b/vitrage_tempest_tests/tests/api/topology/test_topology.py index a0e5cda82..6720b3cd1 100644 --- a/vitrage_tempest_tests/tests/api/topology/test_topology.py +++ b/vitrage_tempest_tests/tests/api/topology/test_topology.py @@ -39,6 +39,12 @@ class TestTopology(BaseTopologyTest): NUM_INSTANCE = 3 NUM_VOLUME = 1 + def setUp(self): + super(TestTopology, self).setUp() + + def tearDown(self): + super(TestTopology, self).tearDown() + @classmethod def setUpClass(cls): super(TestTopology, cls).setUpClass() diff --git a/vitrage_tempest_tests/tests/base.py b/vitrage_tempest_tests/tests/base.py index 297c88948..373ace266 100644 --- a/vitrage_tempest_tests/tests/base.py +++ b/vitrage_tempest_tests/tests/base.py @@ -12,6 +12,7 @@ # License for the specific language governing permissions and limitations # under the License. +import six import traceback from oslo_log import log as logging @@ -37,8 +38,14 @@ from vitrage import service from vitrage_tempest_tests.tests.common.tempest_clients import TempestClients from vitrage_tempest_tests.tests import utils +import warnings + LOG = logging.getLogger(__name__) +if six.PY2: + class ResourceWarning(Warning): + pass + class BaseVitrageTempest(base.BaseTestCase): """Base test class for All Vitrage tests.""" @@ -46,10 +53,25 @@ class BaseVitrageTempest(base.BaseTestCase): NUM_VERTICES_PER_TYPE = 'num_vertices' NUM_EDGES_PER_TYPE = 'num_edges_per_type' + def setUp(self): + super(BaseVitrageTempest, self).setUp() + warnings.filterwarnings(action="ignore", + message="unclosed", + category=ResourceWarning) + + def tearDown(self): + super(BaseVitrageTempest, self).tearDown() + warnings.filterwarnings(action="ignore", + message="unclosed", + category=ResourceWarning) + # noinspection PyPep8Naming @classmethod def setUpClass(cls): super(BaseVitrageTempest, cls).setUpClass() + warnings.filterwarnings(action="ignore", + message="unclosed", + category=ResourceWarning) cls.conf = service.prepare_service([]) TempestClients.class_init(cls.conf) cls.vitrage_client = TempestClients.vitrage() diff --git a/vitrage_tempest_tests/tests/database/test_persistor.py b/vitrage_tempest_tests/tests/database/test_persistor.py index a5e2434c2..0571b03b7 100644 --- a/vitrage_tempest_tests/tests/database/test_persistor.py +++ b/vitrage_tempest_tests/tests/database/test_persistor.py @@ -54,6 +54,12 @@ def get_first_match(events, event): class TestEvents(BaseVitrageTempest): """Test class for Vitrage persisror service""" + def setUp(self): + super(TestEvents, self).setUp() + + def tearDown(self): + super(TestEvents, self).tearDown() + # noinspection PyPep8Naming @classmethod def setUpClass(cls): diff --git a/vitrage_tempest_tests/tests/datasources/test_aodh.py b/vitrage_tempest_tests/tests/datasources/test_aodh.py index 4cf5feb28..c4eebd600 100644 --- a/vitrage_tempest_tests/tests/datasources/test_aodh.py +++ b/vitrage_tempest_tests/tests/datasources/test_aodh.py @@ -27,6 +27,12 @@ class TestAodhAlarm(BaseAlarmsTest): NUM_INSTANCE = 1 NUM_ALARM = 1 + def setUp(self): + super(TestAodhAlarm, self).setUp() + + def tearDown(self): + super(TestAodhAlarm, self).tearDown() + @classmethod def setUpClass(cls): super(TestAodhAlarm, cls).setUpClass() diff --git a/vitrage_tempest_tests/tests/datasources/test_cinder_volume.py b/vitrage_tempest_tests/tests/datasources/test_cinder_volume.py index e822bd286..288c59ad5 100644 --- a/vitrage_tempest_tests/tests/datasources/test_cinder_volume.py +++ b/vitrage_tempest_tests/tests/datasources/test_cinder_volume.py @@ -23,6 +23,12 @@ class TestCinderVolume(BaseTopologyTest): NUM_INSTANCE = 3 NUM_VOLUME = 1 + def setUp(self): + super(TestCinderVolume, self).setUp() + + def tearDown(self): + super(TestCinderVolume, self).tearDown() + @classmethod def setUpClass(cls): super(TestCinderVolume, cls).setUpClass() diff --git a/vitrage_tempest_tests/tests/datasources/test_heat_stack.py b/vitrage_tempest_tests/tests/datasources/test_heat_stack.py index be4b6c3c8..2e7e43790 100644 --- a/vitrage_tempest_tests/tests/datasources/test_heat_stack.py +++ b/vitrage_tempest_tests/tests/datasources/test_heat_stack.py @@ -24,6 +24,12 @@ LOG = logging.getLogger(__name__) class TestHeatStack(BaseTopologyTest): NUM_STACKS = 1 + def setUp(self): + super(TestHeatStack, self).setUp() + + def tearDown(self): + super(TestHeatStack, self).tearDown() + @classmethod def setUpClass(cls): super(TestHeatStack, cls).setUpClass() diff --git a/vitrage_tempest_tests/tests/datasources/test_neutron.py b/vitrage_tempest_tests/tests/datasources/test_neutron.py index fbc413f50..fde1accf7 100644 --- a/vitrage_tempest_tests/tests/datasources/test_neutron.py +++ b/vitrage_tempest_tests/tests/datasources/test_neutron.py @@ -26,6 +26,12 @@ LOG = logging.getLogger(__name__) class TestNeutron(BaseTopologyTest): NUM_INSTANCE = 3 + def setUp(self): + super(TestNeutron, self).setUp() + + def tearDown(self): + super(TestNeutron, self).tearDown() + @classmethod def setUpClass(cls): super(TestNeutron, cls).setUpClass() diff --git a/vitrage_tempest_tests/tests/datasources/test_nova.py b/vitrage_tempest_tests/tests/datasources/test_nova.py index b3766ba24..f44af7e78 100644 --- a/vitrage_tempest_tests/tests/datasources/test_nova.py +++ b/vitrage_tempest_tests/tests/datasources/test_nova.py @@ -22,6 +22,12 @@ LOG = logging.getLogger(__name__) class TestNova(BaseTopologyTest): NUM_INSTANCE = 3 + def setUp(self): + super(TestNova, self).setUp() + + def tearDown(self): + super(TestNova, self).tearDown() + @classmethod def setUpClass(cls): super(TestNova, cls).setUpClass() diff --git a/vitrage_tempest_tests/tests/datasources/test_static_physical.py b/vitrage_tempest_tests/tests/datasources/test_static_physical.py index dd04550ae..c57155e46 100644 --- a/vitrage_tempest_tests/tests/datasources/test_static_physical.py +++ b/vitrage_tempest_tests/tests/datasources/test_static_physical.py @@ -26,6 +26,12 @@ LOG = logging.getLogger(__name__) class TestStaticPhysical(BaseVitrageTempest): NUM_SWITCH = 2 + def setUp(self): + super(TestStaticPhysical, self).setUp() + + def tearDown(self): + super(TestStaticPhysical, self).tearDown() + @classmethod def setUpClass(cls): super(TestStaticPhysical, cls).setUpClass() diff --git a/vitrage_tempest_tests/tests/e2e/test_actions_base.py b/vitrage_tempest_tests/tests/e2e/test_actions_base.py index 9e675fb3f..95cdf9a75 100644 --- a/vitrage_tempest_tests/tests/e2e/test_actions_base.py +++ b/vitrage_tempest_tests/tests/e2e/test_actions_base.py @@ -25,6 +25,12 @@ LOG = logging.getLogger(__name__) class TestActionsBase(BaseVitrageTempest): + def setUp(self): + super(TestActionsBase, self).setUp() + + def tearDown(self): + super(TestActionsBase, self).tearDown() + @classmethod def setUpClass(cls): super(TestActionsBase, cls).setUpClass() diff --git a/vitrage_tempest_tests/tests/e2e/test_basic_actions.py b/vitrage_tempest_tests/tests/e2e/test_basic_actions.py index 574e7ae17..b9e493e2c 100644 --- a/vitrage_tempest_tests/tests/e2e/test_basic_actions.py +++ b/vitrage_tempest_tests/tests/e2e/test_basic_actions.py @@ -49,6 +49,12 @@ DEDUCED_PROPS = { class TestBasicActions(TestActionsBase): + def setUp(self): + super(TestBasicActions, self).setUp() + + def tearDown(self): + super(TestBasicActions, self).tearDown() + @utils.tempest_logger def test_action_set_state_host(self): try: diff --git a/vitrage_tempest_tests/tests/e2e/test_overlapping_actions.py b/vitrage_tempest_tests/tests/e2e/test_overlapping_actions.py index 435dfabaa..33f8a7954 100644 --- a/vitrage_tempest_tests/tests/e2e/test_overlapping_actions.py +++ b/vitrage_tempest_tests/tests/e2e/test_overlapping_actions.py @@ -53,7 +53,14 @@ DEDUCED_PROPS = { } -class TestOverlappingcActions(TestActionsBase): +class TestOverlappingActions(TestActionsBase): + + def setUp(self): + super(TestOverlappingActions, self).setUp() + + def tearDown(self): + super(TestOverlappingActions, self).tearDown() + @utils.tempest_logger def test_overlapping_action_set_state(self): try: diff --git a/vitrage_tempest_tests/tests/notifiers/test_mistral_notifier.py b/vitrage_tempest_tests/tests/notifiers/test_mistral_notifier.py index bb1452d18..ac3be0f47 100644 --- a/vitrage_tempest_tests/tests/notifiers/test_mistral_notifier.py +++ b/vitrage_tempest_tests/tests/notifiers/test_mistral_notifier.py @@ -48,6 +48,12 @@ class TestMistralNotifier(BaseTestEvents): TRIGGER_ALARM_2 = "notifiers.mistral.trigger.alarm.2" TRIGGER_ALARM_FOR_FUNCTION = "notifiers.mistral.trigger.alarm.for.function" + def setUp(self): + super(TestMistralNotifier, self).setUp() + + def tearDown(self): + super(TestMistralNotifier, self).tearDown() + @classmethod def setUpClass(cls): super(TestMistralNotifier, cls).setUpClass()