Move test trigger from template to test
Change-Id: I292a19c5accb25ff6874d7b22af4759a579d4a74
Reviewed-on: https://review.gerrithub.io/377679
Reviewed-by: Tatyanka Leontovich <tleontovich@mirantis.com>
Tested-by: Tatyanka Leontovich <tleontovich@mirantis.com>
diff --git a/tcp_tests/managers/openstack_manager.py b/tcp_tests/managers/openstack_manager.py
index c67c3d5..5396cef 100644
--- a/tcp_tests/managers/openstack_manager.py
+++ b/tcp_tests/managers/openstack_manager.py
@@ -11,8 +11,12 @@
# 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 os
from tcp_tests.managers.execute_commands import ExecuteCommandsMixin
+from tcp_tests import logger
+
+LOG = logger.logger
class OpenstackManager(ExecuteCommandsMixin):
@@ -32,3 +36,46 @@
self.execute_commands(commands,
label='Install OpenStack services')
self.__config.openstack.openstack_installed = True
+
+ def run_tempest(
+ self,
+ image_name='rally-tempest:with_designate',
+ target='gtw01', pattern=None,
+ conf_name='lvm_mcp.conf',
+ registry='docker-sandbox.sandbox.mirantis.net/rally-tempest/'):
+ target_name = [node_name for node_name
+ in self.__underlay.node_names() if target in node_name]
+
+ if pattern:
+ cmd = ("docker run --rm --net=host "
+ "-e TEMPEST_CONF={0} "
+ "-e SKIP_LIST=mcp_skip.list "
+ "-e SOURCE_FILE=keystonercv3 "
+ "-e CUSTOM='--pattern {1}' "
+ "-v /root/:/home/rally {2}{3} "
+ "-v /etc/ssl/certs/:/etc/ssl/certs/ >> image.output".format(
+ conf_name, pattern, registry, image_name))
+ else:
+ cmd = ("docker run --rm --net=host "
+ "-e TEMPEST_CONF={0} "
+ "-e SKIP_LIST=mcp_skip.list "
+ "-e SOURCE_FILE=keystonercv3 "
+ "-v /root/:/home/rally {2}{3} "
+ "-v /etc/ssl/certs/:/etc/ssl/certs/ >> image.output".format(
+ conf_name, pattern, registry, image_name))
+ with self.__underlay.remote(node_name=target_name[0]) as node_remote:
+ result = node_remote.execute(cmd)
+ LOG.debug("Test execution result is {}".format(result))
+ return result
+
+ def download_tempest_report(self, file_fromat='xml', stored_node='gtw01'):
+ target_node_name = [node_name for node_name
+ in self.__underlay.node_names()
+ if stored_node in node_name]
+ with self.__underlay.remote(node_name=target_node_name[0]) as r:
+ result = r.execute('find /root -name "report_*.{}"'.format(
+ file_fromat))
+ LOG.debug("Find result {0}".format(result))
+ file_name = result['stdout'][0].rstrip()
+ LOG.debug("Founded files {0}".format(file_name))
+ r.download(destination=file_name, target=os.getcwd())
diff --git a/tcp_tests/settings.py b/tcp_tests/settings.py
index ea19a23..f4f7334 100644
--- a/tcp_tests/settings.py
+++ b/tcp_tests/settings.py
@@ -54,5 +54,5 @@
DOCKER_REGISTRY = os.environ.get('DOCKER_REGISTRY',
'docker-prod-virtual.docker.mirantis.net')
-PATTERN = os.environ.get('PATTERN', 'smoke')
-
+PATTERN = os.environ.get('PATTERN', None)
+RUN_TEMPEST = get_var_as_bool('RUN_TEMPEST', False)
diff --git a/tcp_tests/templates/virtual-mcp-ocata-dvr/openstack.yaml b/tcp_tests/templates/virtual-mcp-ocata-dvr/openstack.yaml
index 07bc3aa..3e0a4d3 100644
--- a/tcp_tests/templates/virtual-mcp-ocata-dvr/openstack.yaml
+++ b/tcp_tests/templates/virtual-mcp-ocata-dvr/openstack.yaml
@@ -384,30 +384,3 @@
node_name: {{ HOSTNAME_CFG01 }}
retry: {count: 1, delay: 30}
skip_fail: false
-
-- description: Run tests
- cmd: |
- if [[ {{ PATTERN }} == "false" ]]; then
- salt-call cmd.run 'docker run --rm --net=host -e TEMPEST_CONF=lvm_mcp.conf -e SKIP_LIST=mcp_skip.list -e SOURCE_FILE=keystonercv3 -v /root/:/home/rally docker-sandbox.sandbox.mirantis.net/rally-tempest/rally-tempest:with_designate >> image.output'
- else
- salt-call cmd.run "docker run --rm --net=host -e TEMPEST_CONF=lvm_mcp.conf -e SKIP_LIST=mcp_skip.list -e SOURCE_FILE=keystonercv3 -e CUSTOM='--pattern {{ PATTERN }}' -v /root/:/home/rally docker-sandbox.sandbox.mirantis.net/rally-tempest/rally-tempest:with_designate >> image.output"
- fi
- node_name: {{ HOSTNAME_GTW01 }}
- retry: {count: 1, delay: 5}
- skip_fail: false
-
-- description: Download xml results
- download:
- remote_path: /root
- remote_filename: "report_*.xml"
- local_path: {{ os_env('PWD') }}
- node_name: {{ HOSTNAME_GTW01 }}
- skip_fail: true
-
-- description: Download html results
- download:
- remote_path: /root
- remote_filename: "report_*.html"
- local_path: {{ os_env('PWD') }}
- node_name: {{ HOSTNAME_GTW01 }}
- skip_fail: true
diff --git a/tcp_tests/templates/virtual-mcp-ocata-ovs/openstack.yaml b/tcp_tests/templates/virtual-mcp-ocata-ovs/openstack.yaml
index 9d2f09f..0023f88 100644
--- a/tcp_tests/templates/virtual-mcp-ocata-ovs/openstack.yaml
+++ b/tcp_tests/templates/virtual-mcp-ocata-ovs/openstack.yaml
@@ -366,30 +366,3 @@
node_name: {{ HOSTNAME_CFG01 }}
retry: {count: 1, delay: 30}
skip_fail: false
-
-- description: Run tests
- cmd: |
- if [[ {{ PATTERN }} == "false" ]]; then
- salt-call cmd.run 'docker run --rm --net=host -e TEMPEST_CONF=lvm_mcp.conf -e SKIP_LIST=mcp_skip.list -e SOURCE_FILE=keystonercv3 -v /root/:/home/rally docker-sandbox.sandbox.mirantis.net/rally-tempest/rally-tempest:with_designate >> image.output'
- else
- salt-call cmd.run "docker run --rm --net=host -e TEMPEST_CONF=lvm_mcp.conf -e SKIP_LIST=mcp_skip.list -e SOURCE_FILE=keystonercv3 -e CUSTOM='--pattern {{ PATTERN }}' -v /root/:/home/rally docker-sandbox.sandbox.mirantis.net/rally-tempest/rally-tempest:with_designate >> image.output"
- fi
- node_name: {{ HOSTNAME_GTW01 }}
- retry: {count: 1, delay: 5}
- skip_fail: false
-
-- description: Download xml results
- download:
- remote_path: /root
- remote_filename: "report_*.xml"
- local_path: {{ os_env('PWD') }}
- node_name: {{ HOSTNAME_GTW01 }}
- skip_fail: true
-
-- description: Download html results
- download:
- remote_path: /root
- remote_filename: "report_*.html"
- local_path: {{ os_env('PWD') }}
- node_name: {{ HOSTNAME_GTW01 }}
- skip_fail: true
diff --git a/tcp_tests/templates/virtual-mcp11-dvr/openstack.yaml b/tcp_tests/templates/virtual-mcp11-dvr/openstack.yaml
index b971a5e..860a32e 100644
--- a/tcp_tests/templates/virtual-mcp11-dvr/openstack.yaml
+++ b/tcp_tests/templates/virtual-mcp11-dvr/openstack.yaml
@@ -350,26 +350,4 @@
cmd: scp /root/keystonercv3 gtw01:/root
node_name: {{ HOSTNAME_CFG01 }}
retry: {count: 1, delay: 30}
- skip_fail: false
-
-- description: Run tests
- cmd: salt-call cmd.run "docker run --rm --net=host -e TEMPEST_CONF=lvm_mcp.conf -e SKIP_LIST=mcp_skip.list -e SOURCE_FILE=keystonercv3 -v /root/:/home/rally docker-sandbox.sandbox.mirantis.net/rally-tempest/rally-tempest:mcp1.1_newton >> image.output"
- node_name: {{ HOSTNAME_GTW01 }}
- retry: {count: 1, delay: 30}
- skip_fail: false
-
-- description: Download xml results
- download:
- remote_path: /root
- remote_filename: "report_*.xml"
- local_path: {{ os_env('PWD') }}
- node_name: {{ HOSTNAME_GTW01 }}
- skip_fail: true
-
-- description: Download html results
- download:
- remote_path: /root
- remote_filename: "report_*.html"
- local_path: {{ os_env('PWD') }}
- node_name: {{ HOSTNAME_GTW01 }}
- skip_fail: true
+ skip_fail: false
\ No newline at end of file
diff --git a/tcp_tests/templates/virtual-mcp11-ovs/openstack.yaml b/tcp_tests/templates/virtual-mcp11-ovs/openstack.yaml
index 9bf4ab7..e00cf3c 100644
--- a/tcp_tests/templates/virtual-mcp11-ovs/openstack.yaml
+++ b/tcp_tests/templates/virtual-mcp11-ovs/openstack.yaml
@@ -350,26 +350,4 @@
cmd: scp /root/keystonercv3 gtw01:/root
node_name: {{ HOSTNAME_CFG01 }}
retry: {count: 1, delay: 30}
- skip_fail: false
-
-- description: Run tests
- cmd: salt-call cmd.run "docker run --rm --net=host -e TEMPEST_CONF=lvm_mcp.conf -e SKIP_LIST=mcp_skip.list -e SOURCE_FILE=keystonercv3 -v /root/:/home/rally docker-sandbox.sandbox.mirantis.net/rally-tempest/rally-tempest:mcp1.1_newton >> image.output"
- node_name: {{ HOSTNAME_GTW01 }}
- retry: {count: 1, delay: 30}
- skip_fail: false
-
-- description: Download xml results
- download:
- remote_path: /root
- remote_filename: "report_*.xml"
- local_path: {{ os_env('PWD') }}
- node_name: {{ HOSTNAME_GTW01 }}
- skip_fail: true
-
-- description: Download html results
- download:
- remote_path: /root
- remote_filename: "report_*.html"
- local_path: {{ os_env('PWD') }}
- node_name: {{ HOSTNAME_GTW01 }}
- skip_fail: true
+ skip_fail: false
\ No newline at end of file
diff --git a/tcp_tests/tests/system/test_install_mcp11_ovs_newton.py b/tcp_tests/tests/system/test_install_mcp11_ovs_newton.py
index 4b541bb..51a2826 100644
--- a/tcp_tests/tests/system/test_install_mcp11_ovs_newton.py
+++ b/tcp_tests/tests/system/test_install_mcp11_ovs_newton.py
@@ -24,12 +24,12 @@
@pytest.mark.deploy
-class Test_Mcp11_install(object):
+class TestMcp11Install(object):
"""Test class for testing mcp11 vxlan deploy"""
@pytest.mark.fail_snapshot
def test_mcp11_newton_ovs_install(self, underlay, openstack_deployed,
- show_step):
+ openstack_actions, show_step):
"""Test for deploying an mcp environment and check it
Scenario:
@@ -38,11 +38,15 @@
3. Setup compute nodes
"""
+ if settings.RUN_TEMPEST:
+ openstack_actions.run_tempest(pattern=settings.PATTERN)
+ openstack_actions.download_tempest_report()
+
LOG.info("*************** DONE **************")
@pytest.mark.fail_snapshot
def test_mcp11_newton_dvr_install(self, underlay, openstack_deployed,
- show_step):
+ openstack_actions, show_step):
"""Test for deploying an mcp environment and check it
Scenario:
@@ -51,4 +55,7 @@
3. Setup compute nodes
"""
+ if settings.RUN_TEMPEST:
+ openstack_actions.run_tempest(pattern=settings.PATTERN)
+ openstack_actions.download_tempest_report()
LOG.info("*************** DONE **************")
diff --git a/tcp_tests/tests/system/test_install_mcp11_ovs_ocata.py b/tcp_tests/tests/system/test_install_mcp11_ovs_ocata.py
index d46d33f..7c2f788 100644
--- a/tcp_tests/tests/system/test_install_mcp11_ovs_ocata.py
+++ b/tcp_tests/tests/system/test_install_mcp11_ovs_ocata.py
@@ -15,6 +15,7 @@
import pytest
from tcp_tests import logger
+from tcp_tests import settings
LOG = logger.logger
@@ -25,15 +26,20 @@
@pytest.mark.fail_snapshot
@pytest.mark.cz8119
- def test_mcp11_ocata_ovs_install(self, underlay, openstack_deployed,
- show_step):
+ def test_mcp11_ocata_ovs_install(self, underlay,
+ openstack_deployed,
+ sl_deployed, openstack_actions):
"""Test for deploying an mcp environment and check it
Scenario:
1. Prepare salt on hosts
2. Setup controller nodes
3. Setup compute nodes
+ 4. Run tempest
"""
+ if settings.RUN_TEMPEST:
+ openstack_actions.run_tempest(pattern=settings.PATTERN)
+ openstack_actions.download_tempest_report()
LOG.info("*************** DONE **************")
@pytest.mark.fail_snapshot
@@ -102,8 +108,10 @@
@pytest.mark.fail_snapshot
@pytest.mark.cz8120
- def test_mcp11_ocata_dvr_install(self, underlay, openstack_deployed,
- show_step):
+ def test_mcp11_ocata_dvr_install(self,
+ underlay,
+ openstack_deployed,
+ openstack_actions):
"""Test for deploying an mcp environment and check it
Scenario:
1. Prepare salt on hosts
@@ -111,6 +119,9 @@
3. Setup compute nodes
"""
+ if settings.RUN_TEMPEST:
+ openstack_actions.run_tempest(pattern=settings.PATTERN)
+ openstack_actions.download_tempest_report()
LOG.info("*************** DONE **************")
@pytest.mark.fail_snapshot