Add tests to run cvp-func and cvp-sanity jobs
New pytest marks:
- run_cvp_func_smoke
- run_cvp_func_sanity
New SaltManager method:
- get_single_pillar() , to get a single value from
a single minion
Minor changes to get_jenkins_job_stages.py and
run_jenkins_job.py, to call them with required
parameters.
Closes-Bug: PROD-21659
Change-Id: Ie8beec0297f1c2625440f01d781c17779977b818
diff --git a/tcp_tests/tests/system/test_cvp_pipelines.py b/tcp_tests/tests/system/test_cvp_pipelines.py
new file mode 100644
index 0000000..5d2e060
--- /dev/null
+++ b/tcp_tests/tests/system/test_cvp_pipelines.py
@@ -0,0 +1,149 @@
+# 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))