diff --git a/rockoon/tests/functional/exporter/parallel/test_nova_collector.py b/rockoon/tests/functional/exporter/parallel/test_nova_collector.py index c38cc37..2c5af00 100644 --- a/rockoon/tests/functional/exporter/parallel/test_nova_collector.py +++ b/rockoon/tests/functional/exporter/parallel/test_nova_collector.py @@ -1,5 +1,6 @@ from parameterized import parameterized import pytest +import unittest from retry import retry @@ -417,13 +418,21 @@ def setUp(self): ] self.aggregate = None - self.aggregate_compute = [ - x - for x in self.ocm.oc.compute.services(binary="nova-compute") - if x.get("availability_zone") == "nova" - and "nova-compute-ironic" not in x["host"] - ][0]["host"] + compute_services = self.ocm.oc.compute.services(binary="nova-compute") + filtered_services = [ + service + for service in compute_services + if service.get("availability_zone") == "nova" + and "nova-compute-ironic" not in service["host"] + and len(self.ocm.compute_get_all_servers(host=service["host"])) + == 0 + ] + if not filtered_services: + raise unittest.SkipTest( + "There are no nova compute hosts available for aggregate" + ) + self.aggregate_compute = filtered_services[0]["host"] self.server = None def tearDown(self):