Tech dept: fix comments from previous commit with new tests
Change-Id: Iba1c3885063860f8442aae759805db8bf8ec4083
This commit is contained in:
parent
b3fe456381
commit
fd00e5d286
@ -31,7 +31,7 @@ import muranoclient.common.exceptions as exceptions
|
|||||||
|
|
||||||
import clients
|
import clients
|
||||||
|
|
||||||
ARTIFACTS_DIR = os.environ.get('ARTIFACTS_DIR', 'logs')
|
ARTIFACTS_DIR = os.environ.get('ARTIFACTS_DIR', 'artifacts')
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
LOG.setLevel(logging.DEBUG)
|
LOG.setLevel(logging.DEBUG)
|
||||||
@ -60,6 +60,8 @@ def str2bool(name, default):
|
|||||||
value = os.environ.get(name, '')
|
value = os.environ.get(name, '')
|
||||||
return _boolean_states.get(value.lower(), default)
|
return _boolean_states.get(value.lower(), default)
|
||||||
|
|
||||||
|
TIMEOUT_DELAY = 30
|
||||||
|
|
||||||
|
|
||||||
class MuranoTestsBase(testtools.TestCase, clients.ClientsBase):
|
class MuranoTestsBase(testtools.TestCase, clients.ClientsBase):
|
||||||
|
|
||||||
@ -273,7 +275,6 @@ class MuranoTestsBase(testtools.TestCase, clients.ClientsBase):
|
|||||||
fips = self.get_services_fips(environment)
|
fips = self.get_services_fips(environment)
|
||||||
logs_dir = "{0}/{1}".format(ARTIFACTS_DIR, environment.name)
|
logs_dir = "{0}/{1}".format(ARTIFACTS_DIR, environment.name)
|
||||||
os.makedirs(logs_dir)
|
os.makedirs(logs_dir)
|
||||||
self.files.append(logs_dir)
|
|
||||||
for service, fip in fips.iteritems():
|
for service, fip in fips.iteritems():
|
||||||
try:
|
try:
|
||||||
ssh = paramiko.SSHClient()
|
ssh = paramiko.SSHClient()
|
||||||
@ -312,7 +313,7 @@ class MuranoTestsBase(testtools.TestCase, clients.ClientsBase):
|
|||||||
'Environment has incorrect status "{0}"'.format(status)
|
'Environment has incorrect status "{0}"'.format(status)
|
||||||
)
|
)
|
||||||
|
|
||||||
time.sleep(30)
|
time.sleep(TIMEOUT_DELAY)
|
||||||
LOG.debug('Environment "{0}" is ready'.format(self.get_env(env).name))
|
LOG.debug('Environment "{0}" is ready'.format(self.get_env(env).name))
|
||||||
return self.get_env(env).manager.get(env.id)
|
return self.get_env(env).manager.get(env.id)
|
||||||
|
|
||||||
@ -526,7 +527,7 @@ class MuranoTestsBase(testtools.TestCase, clients.ClientsBase):
|
|||||||
return patch['number']
|
return patch['number']
|
||||||
|
|
||||||
def merge_commit(self, gerrit_ip, gerrit_host, project, commit_msg):
|
def merge_commit(self, gerrit_ip, gerrit_host, project, commit_msg):
|
||||||
changeid = self.get_last_open_patch(
|
patch_num = self.get_last_open_patch(
|
||||||
gerrit_ip=gerrit_ip,
|
gerrit_ip=gerrit_ip,
|
||||||
gerrit_host=gerrit_host,
|
gerrit_host=gerrit_host,
|
||||||
project=project,
|
project=project,
|
||||||
@ -536,7 +537,7 @@ class MuranoTestsBase(testtools.TestCase, clients.ClientsBase):
|
|||||||
cmd = (
|
cmd = (
|
||||||
'gerrit review --project {project} --verified +2 '
|
'gerrit review --project {project} --verified +2 '
|
||||||
'--code-review +2 --label Workflow=+1 '
|
'--code-review +2 --label Workflow=+1 '
|
||||||
'--submit {id},1'.format(project=project, id=changeid)
|
'--submit {id},1'.format(project=project, id=patch_num)
|
||||||
)
|
)
|
||||||
cmd = self._gerrit_cmd(gerrit_host, cmd)
|
cmd = self._gerrit_cmd(gerrit_host, cmd)
|
||||||
|
|
||||||
@ -568,37 +569,41 @@ class MuranoTestsBase(testtools.TestCase, clients.ClientsBase):
|
|||||||
cmd=cmd
|
cmd=cmd
|
||||||
)
|
)
|
||||||
|
|
||||||
def get_jenkins_jobs(self, ip):
|
|
||||||
server = jenkins.Jenkins('http://{0}:8080'.format(ip))
|
|
||||||
|
|
||||||
return [job['name'] for job in server.get_all_jobs()]
|
|
||||||
|
|
||||||
def wait_for(self, func, expected, debug_msg, fail_msg, timeout, **kwargs):
|
def wait_for(self, func, expected, debug_msg, fail_msg, timeout, **kwargs):
|
||||||
LOG.debug(debug_msg)
|
|
||||||
start_time = time.time()
|
|
||||||
|
|
||||||
current = func(**kwargs)
|
|
||||||
|
|
||||||
def check(exp, cur):
|
def check(exp, cur):
|
||||||
if isinstance(cur, list) or isinstance(cur, str):
|
if isinstance(cur, list) or isinstance(cur, str):
|
||||||
return exp not in cur
|
return exp not in cur
|
||||||
else:
|
else:
|
||||||
return exp != cur
|
return exp != cur
|
||||||
|
|
||||||
|
LOG.debug(debug_msg)
|
||||||
|
start_time = time.time()
|
||||||
|
|
||||||
|
current = func(**kwargs)
|
||||||
|
|
||||||
while check(expected, current):
|
while check(expected, current):
|
||||||
current = func(**kwargs)
|
current = func(**kwargs)
|
||||||
|
|
||||||
if time.time() - start_time > timeout:
|
if time.time() - start_time > timeout:
|
||||||
self.fail("Time is out. {0}".format(fail_msg))
|
self.fail("Time is out. {0}".format(fail_msg))
|
||||||
time.sleep(30)
|
time.sleep(TIMEOUT_DELAY)
|
||||||
LOG.debug('Expected result has been achieved.')
|
LOG.debug('Expected result has been achieved.')
|
||||||
|
|
||||||
def get_last_build_number(self, ip, user, password, job_name, build_type):
|
@staticmethod
|
||||||
server = jenkins.Jenkins(
|
def _connect_jenkins_server(ip, user=None, password=None):
|
||||||
|
return jenkins.Jenkins(
|
||||||
'http://{0}:8080'.format(ip),
|
'http://{0}:8080'.format(ip),
|
||||||
username=user,
|
username=user,
|
||||||
password=password
|
password=password
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def get_jenkins_jobs(self, ip):
|
||||||
|
server = self._connect_jenkins_server(ip)
|
||||||
|
|
||||||
|
return [job['name'] for job in server.get_all_jobs()]
|
||||||
|
|
||||||
|
def get_last_build_number(self, ip, user, password, job_name, build_type):
|
||||||
|
server = self._connect_jenkins_server(ip, user, password)
|
||||||
# If there are no builds of desired type get_job_info returns None and
|
# If there are no builds of desired type get_job_info returns None and
|
||||||
# it is not possible to get number, in this case this function returns
|
# it is not possible to get number, in this case this function returns
|
||||||
# None too and it means that there are no builds yet
|
# None too and it means that there are no builds yet
|
||||||
|
@ -210,7 +210,7 @@ class MuranoCiCdFlowTest(base.MuranoTestsBase):
|
|||||||
new_job
|
new_job
|
||||||
)
|
)
|
||||||
|
|
||||||
# Making commit to project-config
|
# Make commit to project-config
|
||||||
|
|
||||||
self.make_commit(
|
self.make_commit(
|
||||||
repo=project_config_location,
|
repo=project_config_location,
|
||||||
|
3
tox.ini
3
tox.ini
@ -22,12 +22,9 @@ distribute = false
|
|||||||
commands = {posargs:}
|
commands = {posargs:}
|
||||||
|
|
||||||
[testenv:deploy_cicd_apps]
|
[testenv:deploy_cicd_apps]
|
||||||
# FIXME!
|
|
||||||
commands = python -m unittest tests.test_cicd_apps.MuranoCiCdTest.test_deploy_cicd
|
commands = python -m unittest tests.test_cicd_apps.MuranoCiCdTest.test_deploy_cicd
|
||||||
#commands = python setup.py testr --testr-args='{posargs}'
|
|
||||||
|
|
||||||
[testenv:run_cicd_flow]
|
[testenv:run_cicd_flow]
|
||||||
# FIXME!
|
|
||||||
commands = python -m unittest tests.test_cicd_apps_flow.MuranoCiCdFlowTest.test_run_cicd_flow
|
commands = python -m unittest tests.test_cicd_apps_flow.MuranoCiCdFlowTest.test_run_cicd_flow
|
||||||
|
|
||||||
[testenv:hacking]
|
[testenv:hacking]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user