Return private vars
diff --git a/tcp_tests/fixtures/openstack_fixtures.py b/tcp_tests/fixtures/openstack_fixtures.py
index c4ffa35..daf55a3 100644
--- a/tcp_tests/fixtures/openstack_fixtures.py
+++ b/tcp_tests/fixtures/openstack_fixtures.py
@@ -21,12 +21,13 @@
from tcp_tests.helpers import ext
from tcp_tests import settings
from tcp_tests.managers import openstack_manager
+from tcp_tests.helpers import utils
LOG = logger.logger
@pytest.fixture(scope='function')
-def openstack_actions(config, underlay, salt_actions):
+def openstack_actions(config, underlay, salt_deployed):
"""Fixture that provides various actions for K8S
:param config: fixture provides oslo.config
@@ -35,7 +36,7 @@
For use in tests or fixtures to deploy a custom K8S
"""
- return openstack_manager.OpenstackManager(config, underlay, salt_actions)
+ return openstack_manager.OpenstackManager(config, underlay, salt_deployed)
@pytest.mark.revert_snapshot(ext.SNAPSHOT.openstack_deployed)
diff --git a/tcp_tests/managers/common_services_manager.py b/tcp_tests/managers/common_services_manager.py
index dee792c..0d5cc11 100644
--- a/tcp_tests/managers/common_services_manager.py
+++ b/tcp_tests/managers/common_services_manager.py
@@ -18,16 +18,16 @@
class CommonServicesManager(ExecuteCommandsMixin):
"""docstring for CommonServicesManager"""
- _config = None
- _underlay = None
+ __config = None
+ __underlay = None
def __init__(self, config, underlay, salt=None):
- self._config = config
- self._underlay = underlay
+ self.__config = config
+ self.__underlay = underlay
self._salt = salt
super(CommonServicesManager, self).__init__()
def install(self, commands):
self.execute_commands(commands,
label='Install common services')
- self._config.common_services.common_services_installed = True
+ self.__config.common_services.common_services_installed = True
diff --git a/tcp_tests/managers/execute_commands.py b/tcp_tests/managers/execute_commands.py
index 76f4bc9..03265c1 100644
--- a/tcp_tests/managers/execute_commands.py
+++ b/tcp_tests/managers/execute_commands.py
@@ -10,6 +10,14 @@
class ExecuteCommandsMixin(object):
"""docstring for ExecuteCommands"""
+ __config = None
+ __underlay = None
+
+ def __init__(self, config, underlay):
+ self.__config = config
+ self.__underlay = underlay
+ super(ExecuteCommandsMixin, self).__init__()
+
def ensure_running_service(self, service_name, host, check_cmd,
state_running='start/running'):
"""Check if the service_name running or try to restart it
@@ -21,7 +29,7 @@
"""
cmd = "service {0} status | grep -q '{1}'".format(
service_name, state_running)
- with self._underlay.remote(host=host) as remote:
+ with self.__underlay.remote(host=host) as remote:
result = remote.execute(cmd)
if result.exit_code != 0:
LOG.info("{0} is not in running state on the node {1},"
@@ -97,7 +105,7 @@
retry_delay = retry.get('delay', 1)
skip_fail = step.get('skip_fail', False)
- with self._underlay.remote(node_name=node_name) as remote:
+ with self.__underlay.remote(node_name=node_name) as remote:
for x in range(retry_count, 0, -1):
time.sleep(3)
@@ -122,16 +130,16 @@
" === RETRY ({0}/{1}) ======================="
.format(x - 1, retry_count))
else:
- if self._config.salt.salt_master_host != '0.0.0.0':
+ if self.__config.salt.salt_master_host != '0.0.0.0':
# Workarounds for crashed services
self.ensure_running_service(
"salt-master",
- self._config.salt.salt_master_host,
+ self.__config.salt.salt_master_host,
"salt-call pillar.items",
'active (running)') # Hardcoded for now
self.ensure_running_service(
"salt-minion",
- self._config.salt.salt_master_host,
+ self.__config.salt.salt_master_host,
"salt 'cfg01*' pillar.items",
"active (running)") # Hardcoded for now
break
diff --git a/tcp_tests/managers/opencontrail_manager.py b/tcp_tests/managers/opencontrail_manager.py
index 108794d..1bb7f43 100644
--- a/tcp_tests/managers/opencontrail_manager.py
+++ b/tcp_tests/managers/opencontrail_manager.py
@@ -18,15 +18,16 @@
class OpenContrailManager(ExecuteCommandsMixin):
"""docstring for OpenstackManager"""
- _config = None
- _underlay = None
+ __config = None
+ __underlay = None
_openstack_actions = None
def __init__(self, config, underlay, openstack_deployed):
- self._config = config
- self._underlay = underlay
+ self.__config = config
+ self.__underlay = underlay
self._openstack_actions = openstack_deployed
- super(OpenContrailManager, self).__init__()
+ super(OpenContrailManager, self).__init__(
+ config=config, underlay=underlay)
def prepare_tests(self, commands):
self.execute_commands(commands=commands,
@@ -34,18 +35,19 @@
def run_tests(self, tags='', features=''):
cmd = "salt 'ctl01*' grains.get fqdn|tail -n1"
- result = self._underlay.check_call(
- cmd, host=self._config.salt.salt_master_host)
+ result = self.__underlay.check_call(
+ cmd, host=self.__config.salt.salt_master_host)
ctl01_name = result['stdout'].strip()
- cmd = '. /etc/contrail/openstackrc; cd /opt/contrail-test; ./run_tests.sh'
+ cmd = '. /etc/contrail/openstackrc; ' \
+ 'cd /opt/contrail-test; ./run_tests.sh'
if tags != '':
cmd += ' --tags ' + tags
if features != '':
cmd += ' --features ' + features
- self._underlay.check_call(
+ self.__underlay.check_call(
cmd,
node_name=ctl01_name)
diff --git a/tcp_tests/managers/openstack_manager.py b/tcp_tests/managers/openstack_manager.py
index 55af1e2..b3b7a7e 100644
--- a/tcp_tests/managers/openstack_manager.py
+++ b/tcp_tests/managers/openstack_manager.py
@@ -18,14 +18,15 @@
class OpenstackManager(ExecuteCommandsMixin):
"""docstring for OpenstackManager"""
- _config = None
- _underlay = None
+ __config = None
+ __underlay = None
def __init__(self, config, underlay, salt):
- self._config = config
- self._underlay = underlay
+ self.__config = config
+ self.__underlay = underlay
self._salt = salt
- super(OpenstackManager, self).__init__()
+ super(OpenstackManager, self).__init__(
+ config=config, underlay=underlay)
def install(self, commands):
self.execute_commands(commands,
diff --git a/tcp_tests/managers/saltmanager.py b/tcp_tests/managers/saltmanager.py
index b65c74f..4a83e12 100644
--- a/tcp_tests/managers/saltmanager.py
+++ b/tcp_tests/managers/saltmanager.py
@@ -27,8 +27,8 @@
class SaltManager(ExecuteCommandsMixin):
"""docstring for SaltManager"""
- _config = None
- _underlay = None
+ __config = None
+ __underlay = None
_map = {
'enforceState': 'enforce_state',
'enforceStates': 'enforce_states',
@@ -37,8 +37,8 @@
}
def __init__(self, config, underlay, host=None, port='6969'):
- self._config = config
- self._underlay = underlay
+ self.__config = config
+ self.__underlay = underlay
self._port = port
self._host = host
self._api = None
@@ -46,7 +46,7 @@
self._password = settings.SALT_PASSWORD
self._salt = self
- super(SaltManager, self).__init__()
+ super(SaltManager, self).__init__(config=config, underlay=underlay)
def install(self, commands):
if commands[0].get('do'):
@@ -55,23 +55,23 @@
self.install1(commands)
def install1(self, commands):
- if self._config.salt.salt_master_host == '0.0.0.0':
+ if self.__config.salt.salt_master_host == '0.0.0.0':
# Temporary workaround. Underlay should be extended with roles
- salt_nodes = self._underlay.node_names()
- self._config.salt.salt_master_host = \
- self._underlay.host_by_node_name(salt_nodes[0])
+ salt_nodes = self.__underlay.node_names()
+ self.__config.salt.salt_master_host = \
+ self.__underlay.host_by_node_name(salt_nodes[0])
- # self._underlay.execute_commands(commands=commands,
+ # self.__underlay.execute_commands(commands=commands,
# label="Install and configure salt")
self.execute_commands(commands=commands,
label="Install and configure salt")
def install2(self, commands):
- if self._config.salt.salt_master_host == '0.0.0.0':
+ if self.__config.salt.salt_master_host == '0.0.0.0':
# Temporary workaround. Underlay should be extended with roles
- salt_nodes = self._underlay.node_names()
- self._config.salt.salt_master_host = \
- self._underlay.host_by_node_name(salt_nodes[0])
+ salt_nodes = self.__underlay.node_names()
+ self.__config.salt.salt_master_host = \
+ self.__underlay.host_by_node_name(salt_nodes[0])
# self.run_commands(commands=commands,
# label="Install and configure salt")
@@ -86,13 +86,13 @@
def host(self):
if self._host:
return self._host
- elif self._config.salt.salt_master_host == '0.0.0.0':
+ elif self.__config.salt.salt_master_host == '0.0.0.0':
# Temporary workaround. Underlay should be extended with roles
- salt_nodes = self._underlay.node_names()
- self._config.salt.salt_master_host = \
- self._underlay.host_by_node_name(salt_nodes[0])
+ salt_nodes = self.__underlay.node_names()
+ self.__config.salt.salt_master_host = \
+ self.__underlay.host_by_node_name(salt_nodes[0])
- return self._config.salt.salt_master_host
+ return self.__config.salt.salt_master_host
@property
def api(self):
@@ -134,6 +134,8 @@
raise LookupError("Result is empty or absent")
result = r['return'][0]
+ if len(result) == 0:
+ raise LookupError("Result is empty or absent")
LOG.info("Job has result for %s nodes", result.keys())
fails = defaultdict(list)
for h in result: