From 2b6fc051cfc85ea48648a837aa31cddfa1165a7a Mon Sep 17 00:00:00 2001 From: Eyal Date: Mon, 7 Aug 2017 16:22:57 +0300 Subject: [PATCH] make tempest work under py3 use the -E for sudo when running testr this will pass the PYTHON environment variable so python3 will run Change-Id: I231090694fafb8dcc71c9595174ba82185b59348 --- devstack/gate_hook.sh | 2 ++ devstack/post_test_hook.sh | 33 +++++++++---------- vitrage/datasources/driver_base.py | 1 - vitrage_tempest_tests/tests/api/base.py | 10 +++--- .../api/datasources/test_static_physical.py | 4 +-- vitrage_tempest_tests/tests/utils.py | 4 +-- 6 files changed, 28 insertions(+), 26 deletions(-) diff --git a/devstack/gate_hook.sh b/devstack/gate_hook.sh index ab93f43c1..0562d8b33 100644 --- a/devstack/gate_hook.sh +++ b/devstack/gate_hook.sh @@ -29,6 +29,8 @@ DEVSTACK_LOCAL_CONFIG+=$'\nenable_plugin ceilometer git://git.openstack.org/open DEVSTACK_LOCAL_CONFIG+=$'\nenable_plugin aodh git://git.openstack.org/openstack/aodh' DEVSTACK_LOCAL_CONFIG+=$'\ndisable_service ceilometer-alarm-evaluator,ceilometer-alarm-notifier' DEVSTACK_LOCAL_CONFIG+=$'\ndisable_service n-net' +DEVSTACK_LOCAL_CONFIG+=$'\ndisable_service s-account s-container s-object s-proxy' + DEVSTACK_LOCAL_CONFIG+="$(cat < vitrage_tempest_tests.list') +sudo -E testr list-tests vitrage_tempest_tests +sudo -E testr list-tests vitrage_tempest_tests | grep -E "$TESTS" > /tmp/vitrage_tempest_tests.list echo "Testing $1: $TESTS..." -(cd $DEVSTACK_PATH/tempest/; sudo sh -c 'testr run --subunit --load-list=vitrage_tempest_tests.list | subunit-trace --fails') +sudo -E testr run --subunit --load-list=/tmp/vitrage_tempest_tests.list | subunit-trace --fails diff --git a/vitrage/datasources/driver_base.py b/vitrage/datasources/driver_base.py index 761763d35..5b133c719 100644 --- a/vitrage/datasources/driver_base.py +++ b/vitrage/datasources/driver_base.py @@ -94,7 +94,6 @@ class DriverBase(object): pass @staticmethod - @abc.abstractmethod def get_event_types(): """Return a list of all event types relevant to this datasource diff --git a/vitrage_tempest_tests/tests/api/base.py b/vitrage_tempest_tests/tests/api/base.py index 9ba0ee4cc..cdb27f17c 100644 --- a/vitrage_tempest_tests/tests/api/base.py +++ b/vitrage_tempest_tests/tests/api/base.py @@ -17,6 +17,7 @@ import traceback from oslo_log import log as logging from oslotest import base +from six.moves import filter from vitrage.common.constants import EdgeProperties from vitrage.common.constants import EntityCategory @@ -78,7 +79,7 @@ class BaseApiTest(base.BaseTestCase): count = 0 while count < 40: - LOG.info("wait_for_client - " + client_func.func_name) + LOG.info("wait_for_client - " + client_func.__name__) client = client_func(conf) if client: return client @@ -126,7 +127,7 @@ class BaseApiTest(base.BaseTestCase): host = filter( lambda item: item[VProps.VITRAGE_TYPE] == NOVA_HOST_DATASOURCE, topology['nodes']) - return host[0] + return next(host) def _create_instances(self, num_instances, set_public_network=False): kwargs = {} @@ -377,9 +378,10 @@ class BaseApiTest(base.BaseTestCase): public_nets = filter( lambda item: self._get_value(item, VProps.NAME) == 'public', networks['networks']) - if not public_nets: + try: + return next(public_nets) + except StopIteration: return None - return public_nets[0] def _print_entity_graph(self): api_graph = self.vitrage_client.topology.get(all_tenants=True) diff --git a/vitrage_tempest_tests/tests/api/datasources/test_static_physical.py b/vitrage_tempest_tests/tests/api/datasources/test_static_physical.py index ec4d75eda..975d907f6 100644 --- a/vitrage_tempest_tests/tests/api/datasources/test_static_physical.py +++ b/vitrage_tempest_tests/tests/api/datasources/test_static_physical.py @@ -67,14 +67,14 @@ class TestStaticPhysical(BaseApiTest): # template file file_path = '/etc/vitrage/static_physical_configuration.yaml' - with open(file_path, 'rb') as f: + with open(file_path, 'r') as f: template_data = f.read() template_data = template_data.replace('tmp-devstack', hostname) # new file new_file = open( '/etc/vitrage/static_datasources/' - 'static_physical_configuration.yaml', 'wb') + 'static_physical_configuration.yaml', 'w') new_file.write(template_data) new_file.close() diff --git a/vitrage_tempest_tests/tests/utils.py b/vitrage_tempest_tests/tests/utils.py index d30daeefe..9fd0eda75 100644 --- a/vitrage_tempest_tests/tests/utils.py +++ b/vitrage_tempest_tests/tests/utils.py @@ -73,7 +73,7 @@ def run_vitrage_command(command, conf): LOG.error('error from command %(command)s = %(error)s', {'error': stderr, 'command': full_command}) - return stdout + return stdout.decode('utf-8') def get_property_value(environment_name, conf_name, default_value, conf): @@ -120,7 +120,7 @@ def uni2str(text): def tempest_logger(func): - func_name = func.func_name + func_name = func.__name__ @wraps(func) def func_name_print_func(*args, **kwargs):