Revert "Add tests to run cvp-func and cvp-sanity jobs"
This reverts commit 0cad12cceb06419f6b91422195550969f44980e1.
Change-Id: I7b87d7d92be49c8fcb0194e073ad9507a5b50507
diff --git a/tcp_tests/managers/saltmanager.py b/tcp_tests/managers/saltmanager.py
index 3782c63..a468b02 100644
--- a/tcp_tests/managers/saltmanager.py
+++ b/tcp_tests/managers/saltmanager.py
@@ -167,24 +167,6 @@
result = self.local(tgt=tgt, fun='pillar.get', args=pillar)
return result['return']
- def get_single_pillar(self, tgt, pillar):
- """Get a scalar value from a single node
-
- :return: pillar value
- """
-
- result = self.get_pillar(tgt, pillar)
- nodes = result[0].keys()
-
- if not nodes:
- raise LookupError("No minions selected "
- "for the target '{0}'".format(tgt))
- if len(nodes) > 1:
- raise LookupError("Too many minions selected "
- "for the target '{0}' , expected one: {1}"
- .format(tgt, nodes))
- return result[0][nodes[0]]
-
def get_grains(self, tgt, grains):
result = self.local(tgt=tgt, fun='grains.get', args=grains)
return result['return']
diff --git a/tcp_tests/tests/system/test_cvp_pipelines.py b/tcp_tests/tests/system/test_cvp_pipelines.py
deleted file mode 100644
index 5d2e060..0000000
--- a/tcp_tests/tests/system/test_cvp_pipelines.py
+++ /dev/null
@@ -1,149 +0,0 @@
-# Copyright 2016 Mirantis, Inc.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-import pytest
-
-from tcp_tests import logger
-from tcp_tests import settings
-from tcp_tests.utils import run_jenkins_job
-from tcp_tests.utils import get_jenkins_job_stages
-
-LOG = logger.logger
-
-
-class TestCvpPipelines(object):
- """Test class for running Cloud Validation Pipelines
-
- Requires environment variables:
- ENV_NAME
- LAB_CONFIG_NAME
- TESTS_CONFIGS
- """
-
- @pytest.mark.grab_versions
- @pytest.mark.parametrize("_", [settings.ENV_NAME])
- @pytest.mark.run_cvp_func_smoke
- def test_run_cvp_func_smoke(self, salt_actions, show_step, _):
- """Runner for Pipeline CVP - Functional tests
-
- Scenario:
- 1. Get CICD Jenkins access credentials from salt
- 2. Run job cvp-func
- 3. Get passed stages from cvp-func
- """
- salt = salt_actions
- show_step(1)
-
- tgt = 'I@docker:client:stack:jenkins and cid01*'
- jenkins_host = salt.get_single_pillar(
- tgt=tgt, pillar="jenkins:client:master:host")
- jenkins_port = salt.get_single_pillar(
- tgt=tgt, pillar="jenkins:client:master:port")
- jenkins_url = 'http://{0}:{1}'.format(jenkins_host, jenkins_port)
- jenkins_user = salt.get_single_pillar(
- tgt=tgt, pillar="jenkins:client:master:username")
- jenkins_pass = salt.get_single_pillar(
- tgt=tgt, pillar="jenkins:client:master:password")
- jenkins_start_timeout = 60
- jenkins_build_timeout = 1800
-
- job_name = 'cvp-func'
- job_parameters = {
- 'TARGET_NODE': 'gtw01*',
- 'TEMPEST_ENDPOINT_TYPE': 'internalURL',
- 'TEMPEST_TEST_PATTERN': 'set=smoke',
- }
- show_step(2)
- cvp_func_smoke_result = run_jenkins_job.run_job(
- host=jenkins_url,
- username=jenkins_user,
- password=jenkins_pass,
- start_timeout=jenkins_start_timeout,
- build_timeout=jenkins_build_timeout,
- verbose=True,
- job_name=job_name,
- job_parameters=job_parameters,
- job_output_prefix='[ cvp-func/{build_number}:platform {time} ] ')
-
- show_step(3)
- (description, stages) = get_jenkins_job_stages.get_deployment_result(
- host=jenkins_url,
- username=jenkins_user,
- password=jenkins_pass,
- job_name=job_name,
- build_number='lastBuild')
-
- LOG.info(description)
- LOG.info('\n'.join(stages))
-
- assert cvp_func_smoke_result == 'SUCCESS', "{0}\n{1}".format(
- description, '\n'.join(stages))
-
- @pytest.mark.grab_versions
- @pytest.mark.parametrize("_", [settings.ENV_NAME])
- @pytest.mark.run_cvp_func_sanity
- def test_run_cvp_func_sanity(self, salt_actions, show_step, _):
- """Runner for Pipeline CVP - Functional tests
-
- Scenario:
- 1. Get CICD Jenkins access credentials from salt
- 2. Run job cvp-sanity
- 3. Get passed stages from cvp-sanity
- """
- salt = salt_actions
- show_step(1)
-
- tgt = 'I@docker:client:stack:jenkins and cid01*'
- jenkins_host = salt.get_single_pillar(
- tgt=tgt, pillar="jenkins:client:master:host")
- jenkins_port = salt.get_single_pillar(
- tgt=tgt, pillar="jenkins:client:master:port")
- jenkins_url = 'http://{0}:{1}'.format(jenkins_host, jenkins_port)
- jenkins_user = salt.get_single_pillar(
- tgt=tgt, pillar="jenkins:client:master:username")
- jenkins_pass = salt.get_single_pillar(
- tgt=tgt, pillar="jenkins:client:master:password")
- jenkins_start_timeout = 60
- jenkins_build_timeout = 1800
-
- job_name = 'cvp-sanity'
- job_parameters = {
- 'TEST_SET': '/var/lib/cvp-sanity/cvp_checks/tests/',
- }
-
- show_step(2)
- cvp_func_sanity_result = run_jenkins_job.run_job(
- host=jenkins_url,
- username=jenkins_user,
- password=jenkins_pass,
- start_timeout=jenkins_start_timeout,
- build_timeout=jenkins_build_timeout,
- verbose=True,
- job_name=job_name,
- job_parameters=job_parameters,
- job_output_prefix='[ cvp-func/{build_number}:platform {time} ] ')
-
- show_step(3)
- (description, stages) = get_jenkins_job_stages.get_deployment_result(
- host=jenkins_url,
- username=jenkins_user,
- password=jenkins_pass,
- job_name=job_name,
- build_number='lastBuild')
-
- LOG.info(description)
- LOG.info('\n'.join(stages))
-
- assert cvp_func_sanity_result == 'SUCCESS', "{0}\n{1}".format(
- description, '\n'.join(stages))
diff --git a/tcp_tests/utils/get_jenkins_job_stages.py b/tcp_tests/utils/get_jenkins_job_stages.py
index b28e1d2..883494f 100755
--- a/tcp_tests/utils/get_jenkins_job_stages.py
+++ b/tcp_tests/utils/get_jenkins_job_stages.py
@@ -69,15 +69,15 @@
return parser
-def get_deployment_result(host, username, password, job_name, build_number):
+def get_deployment_result(opts):
"""Get the pipeline job result from Jenkins
Get all the stages resutls from the specified job,
show error message if present.
"""
- jenkins = client.JenkinsClient(host=host,
- username=username,
- password=password)
+ jenkins = client.JenkinsClient(host=opts.host,
+ username=opts.username,
+ password=opts.password)
def get_stages(nodes, indent=0, show_status=True):
res = []
@@ -90,15 +90,15 @@
res.append(msg)
if node['status'] != 'SUCCESS':
- wf = jenkins.get_workflow(job_name, build_number,
+ wf = jenkins.get_workflow(opts.job_name, opts.build_number,
int(node['id']))
if wf is not None:
if 'stageFlowNodes' in wf:
res += get_stages(wf['stageFlowNodes'], indent + 2,
show_status=False)
elif '_links' in wf and 'log' in wf['_links']:
- log = jenkins.get_workflow(job_name,
- build_number,
+ log = jenkins.get_workflow(opts.job_name,
+ opts.build_number,
int(node['id']),
mode='log')
if "text" in log:
@@ -109,8 +109,8 @@
return res
for _ in range(3):
- wf = jenkins.get_workflow(job_name, build_number)
- info = jenkins.build_info(job_name, int(wf['id']))
+ wf = jenkins.get_workflow(opts.job_name, opts.build_number)
+ info = jenkins.build_info(opts.job_name, int(wf['id']))
if info.get('result'):
break
time.sleep(3)
@@ -120,7 +120,7 @@
stages = get_stages(wf['stages'], 0)
if not stages:
msg = wf['status'] + ":\n\n"
- stages = [msg + jenkins.get_build_output(job_name, int(wf['id']))]
+ stages = [msg + jenkins.get_build_output(opts.job_name, int(wf['id']))]
return (build_description, stages)
@@ -133,12 +133,7 @@
parser.print_help()
return 10
else:
- (build_description, stages) = get_deployment_result(
- opts.host,
- opts.username,
- opts.password,
- opts.job_name,
- opts.build_number)
+ (build_description, stages) = get_deployment_result(opts)
print(build_description)
print('\n'.join(stages))
diff --git a/tcp_tests/utils/run_jenkins_job.py b/tcp_tests/utils/run_jenkins_job.py
index 86a3703..acc2e9f 100755
--- a/tcp_tests/utils/run_jenkins_job.py
+++ b/tcp_tests/utils/run_jenkins_job.py
@@ -97,10 +97,10 @@
return parser
-def print_build_header(build, job_params, build_timeout):
+def print_build_header(build, job_params, opts):
print('\n#############################################################')
print('##### Building job [{0}] #{1} (timeout={2}) with the following '
- 'parameters:'.format(build[0], build[1], build_timeout))
+ 'parameters:'.format(build[0], build[1], opts.build_timeout))
print('##### ' + '\n##### '.join(
[str(key) + ": " + str(val) for key, val in job_params.iteritems()]
))
@@ -114,44 +114,41 @@
print('#############################################################\n')
-def run_job(host, username, password,
- job_name, job_parameters=None, job_output_prefix='',
- start_timeout=1800, build_timeout=3600 * 4, verbose=False):
+def run_job(opts):
jenkins = JenkinsClient(
- host=host,
- username=username,
- password=password)
+ host=opts.host,
+ username=opts.username,
+ password=opts.password)
- job_params = jenkins.make_defults_params(job_name)
- if job_parameters is not None: # job_parameters = {}
- job_params.update(job_parameters)
+ job_params = jenkins.make_defults_params(opts.job_name)
+ job_params.update(opts.job_parameters)
- build = jenkins.run_build(job_name,
+ build = jenkins.run_build(opts.job_name,
job_params,
- verbose=verbose,
- timeout=start_timeout)
- if verbose:
- print_build_header(build, job_params, build_timeout)
+ verbose=opts.verbose,
+ timeout=opts.start_timeout)
+ if opts.verbose:
+ print_build_header(build, job_params, opts)
try:
jenkins.wait_end_of_build(
name=build[0],
build_id=build[1],
- timeout=build_timeout,
+ timeout=opts.build_timeout,
interval=1,
- verbose=verbose,
- job_output_prefix=job_output_prefix)
+ verbose=opts.verbose,
+ job_output_prefix=opts.job_output_prefix)
except Exception as e:
print(str(e))
raise
result = jenkins.build_info(name=build[0],
build_id=build[1])['result']
- if verbose:
- print_build_footer(build, result, host)
+ if opts.verbose:
+ print_build_footer(build, result, opts.host)
- return result
+ return EXIT_CODES.get(result, 2)
def main(args=None):
@@ -163,8 +160,8 @@
parser.print_help()
return 10
else:
- result = run_job(opts)
- return EXIT_CODES.get(result, 2)
+ exit_code = run_job(opts)
+ return exit_code
if __name__ == "__main__":