Tech dept: fix comments from previous commit with new tests

Change-Id: Iba1c3885063860f8442aae759805db8bf8ec4083
This commit is contained in:
Anastasia Kuznetsova 2016-08-29 14:47:15 +03:00
parent b3fe456381
commit fd00e5d286
3 changed files with 24 additions and 22 deletions

View File

@ -31,7 +31,7 @@ import muranoclient.common.exceptions as exceptions
import clients
ARTIFACTS_DIR = os.environ.get('ARTIFACTS_DIR', 'logs')
ARTIFACTS_DIR = os.environ.get('ARTIFACTS_DIR', 'artifacts')
LOG = logging.getLogger(__name__)
LOG.setLevel(logging.DEBUG)
@ -60,6 +60,8 @@ def str2bool(name, default):
value = os.environ.get(name, '')
return _boolean_states.get(value.lower(), default)
TIMEOUT_DELAY = 30
class MuranoTestsBase(testtools.TestCase, clients.ClientsBase):
@ -273,7 +275,6 @@ class MuranoTestsBase(testtools.TestCase, clients.ClientsBase):
fips = self.get_services_fips(environment)
logs_dir = "{0}/{1}".format(ARTIFACTS_DIR, environment.name)
os.makedirs(logs_dir)
self.files.append(logs_dir)
for service, fip in fips.iteritems():
try:
ssh = paramiko.SSHClient()
@ -312,7 +313,7 @@ class MuranoTestsBase(testtools.TestCase, clients.ClientsBase):
'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))
return self.get_env(env).manager.get(env.id)
@ -526,7 +527,7 @@ class MuranoTestsBase(testtools.TestCase, clients.ClientsBase):
return patch['number']
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_host=gerrit_host,
project=project,
@ -536,7 +537,7 @@ class MuranoTestsBase(testtools.TestCase, clients.ClientsBase):
cmd = (
'gerrit review --project {project} --verified +2 '
'--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)
@ -568,37 +569,41 @@ class MuranoTestsBase(testtools.TestCase, clients.ClientsBase):
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):
LOG.debug(debug_msg)
start_time = time.time()
current = func(**kwargs)
def check(exp, cur):
if isinstance(cur, list) or isinstance(cur, str):
return exp not in cur
else:
return exp != cur
LOG.debug(debug_msg)
start_time = time.time()
current = func(**kwargs)
while check(expected, current):
current = func(**kwargs)
if time.time() - start_time > timeout:
self.fail("Time is out. {0}".format(fail_msg))
time.sleep(30)
time.sleep(TIMEOUT_DELAY)
LOG.debug('Expected result has been achieved.')
def get_last_build_number(self, ip, user, password, job_name, build_type):
server = jenkins.Jenkins(
@staticmethod
def _connect_jenkins_server(ip, user=None, password=None):
return jenkins.Jenkins(
'http://{0}:8080'.format(ip),
username=user,
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
# it is not possible to get number, in this case this function returns
# None too and it means that there are no builds yet

View File

@ -210,7 +210,7 @@ class MuranoCiCdFlowTest(base.MuranoTestsBase):
new_job
)
# Making commit to project-config
# Make commit to project-config
self.make_commit(
repo=project_config_location,

View File

@ -22,12 +22,9 @@ distribute = false
commands = {posargs:}
[testenv:deploy_cicd_apps]
# FIXME!
commands = python -m unittest tests.test_cicd_apps.MuranoCiCdTest.test_deploy_cicd
#commands = python setup.py testr --testr-args='{posargs}'
[testenv:run_cicd_flow]
# FIXME!
commands = python -m unittest tests.test_cicd_apps_flow.MuranoCiCdFlowTest.test_run_cicd_flow
[testenv:hacking]