Use runtest formula for running tempest tests

Change-Id: I852a9c8c6199d365784306f8cf96ba66059a1ca3
diff --git a/tcp_tests/templates/runtest.yml b/tcp_tests/templates/runtest.yml
new file mode 100644
index 0000000..f969118
--- /dev/null
+++ b/tcp_tests/templates/runtest.yml
@@ -0,0 +1,71 @@
+classes:
+- service.runtest.tempest
+parameters:
+  _param:
+    runtest_tempest_cfg_dir: /root/test/
+    runtest_tempest_cfg_name: tempest.conf
+    runtest_tempest_public_net: net04_ext
+    tempest_test_target: gtw01*
+  neutron:
+    client:
+      enabled: true
+  runtest:
+    enabled: True
+    keystonerc_node: ctl01*
+    tempest:
+      enabled: True
+      cfg_dir: ${_param:runtest_tempest_cfg_dir}
+      cfg_name: ${_param:runtest_tempest_cfg_name}
+      convert_to_uuid:
+        network:
+          public_network_id: ${_param:runtest_tempest_public_net}
+      network:
+          floating_network_name: ${_param:runtest_tempest_public_net}
+      DEFAULT:
+        log_file: tempest.log
+      compute:
+        build_timeout: 600
+        min_microversion: 2.1
+        max_microversion: 2.53
+        min_compute_nodes: 2
+        volume_device_name: 'vdc'
+      orchestration:
+        max_template_size: 5440000
+        max_resources_per_stack: 20000
+      dns_feature_enabled:
+        # Switch this to designate_admin_api_enabled once [1] is promoted to stable packages
+        # [1] https://gerrit.mcp.mirantis.net/gitweb?p=salt-formulas/designate.git;a=commit;h=96a3f43f6cf1149559e54a00b5548bdf46333749
+        api_admin: false
+        api_v1: false
+        api_v2: true
+        api_v2_quotas: true
+        api_v2_root_recordsets: true
+        bug_1573141_fixed: true
+      volume-feature-enabled:
+        backup: false
+      volume:
+        storage_protocol: iSCSI
+        build_timeout: 300
+      share:
+        min_api_microversion: 2.0
+        max_api_microversion: 2.40
+        backend_names: lvm
+        default_share_type_name: default
+        capability_create_share_from_snapshot_support: True
+        run_mount_snapshot_tests: True
+        run_migration_with_preserve_snapshots_tests: False
+        run_driver_assisted_migration_tests: False
+        run_host_assisted_migration_tests: True
+        run_replication_tests: False
+        run_manage_unmanage_snapshot_tests: False
+        run_manage_unmanage_tests: False
+        run_share_group_tests: False
+        run_revert_to_snapshot_tests: True
+        run_snapshot_tests: True
+        run_shrink_tests: False
+        run_quota_tests: True
+        capability_snapshot_support: True
+        enable_user_rules_for_protocols: cifs
+        enable_ip_rules_for_protocols: nfs
+        suppress_errors_in_cleanup: True
+        share_creation_retry_number: 2
\ No newline at end of file
diff --git a/tcp_tests/templates/shared-salt.yaml b/tcp_tests/templates/shared-salt.yaml
index f2feef4..4992858 100644
--- a/tcp_tests/templates/shared-salt.yaml
+++ b/tcp_tests/templates/shared-salt.yaml
@@ -1029,3 +1029,68 @@
   skip_fail: false
 
 {%- endmacro %}
+
+{%- macro RUN_NEW_TEMPEST() %}
+{###################################}
+
+- description: Upload tempest template
+  upload:
+    local_path: {{ config.salt_deploy.templates_dir }}
+    local_filename: runtest.yml
+    remote_path: /srv/salt/reclass/classes/cluster/{{ CLUSTER_NAME }}/infra/
+  node_name: {{ HOSTNAME_CFG01 }}
+  skip_fail: False
+
+- description: Include class with tempest template into cfg node
+  cmd: |
+    sed -i 's/classes\:/classes\:\n- cluster.{{ CLUSTER_NAME }}.infra.runtest/g' /srv/salt/reclass/nodes/_generated/cfg01.{{ DOMAIN_NAME }}.yml;
+    salt 'cfg01*' saltutil.refresh_pillar;
+    salt 'cfg01*' saltutil.sync_all;
+  node_name: {{ HOSTNAME_CFG01 }}
+  retry: {count: 1, delay: 10}
+  skip_fail: false
+
+- description: Create flavors for tests
+  cmd: |
+    salt 'cfg01*' state.sls nova.client;
+  node_name: {{ HOSTNAME_CFG01 }}
+  retry: {count: 1, delay: 5}
+  skip_fail: false
+
+- description: Create networks for tests
+  cmd: |
+    salt 'cfg01*' state.sls neutron.client;
+  node_name: {{ HOSTNAME_CFG01 }}
+  retry: {count: 1, delay: 5}
+  skip_fail: false
+
+- description: Upload cirros image
+  cmd: |
+    salt 'cfg01*' state.sls glance.client;
+  node_name: {{ HOSTNAME_CFG01 }}
+  retry: {count: 1, delay: 5}
+  skip_fail: false
+
+- description: Generate tempest config
+  cmd: |
+    salt 'cfg01*' state.sls runtest;
+  node_name: {{ HOSTNAME_CFG01 }}
+  retry: {count: 1, delay: 5}
+  skip_fail: false
+
+- description: Run tempest from new docker image
+  cmd: |
+    docker run -e ARGS="-w 4" -v /root/test/tempest.conf:/etc/tempest/tempest.conf -v /tmp/:/tmp/ -v /root/test:/root/tempest -v /etc/ssl/certs/:/etc/ssl/certs/ --rm docker-prod-virtual.docker.mirantis.net/mirantis/cicd/ci-tempest /bin/bash -c "run-tempest"
+  node_name: {{ HOSTNAME_GTW01 }}
+  retry: {count: 1, delay: 30}
+  skip_fail: true
+
+- description: Download xml results
+  download:
+    remote_path: /root/test/
+    remote_filename: "report_*.xml"
+    local_path: {{ os_env('PWD') }}
+  node_name: {{ HOSTNAME_GTW01 }}
+  skip_fail: true
+
+{%- endmacro %}
diff --git a/tcp_tests/templates/virtual-mcp-pike-ovs/openstack.yaml b/tcp_tests/templates/virtual-mcp-pike-ovs/openstack.yaml
index 6636bd7..791991f 100644
--- a/tcp_tests/templates/virtual-mcp-pike-ovs/openstack.yaml
+++ b/tcp_tests/templates/virtual-mcp-pike-ovs/openstack.yaml
@@ -5,7 +5,10 @@
 {% from 'virtual-mcp-pike-ovs/underlay.yaml' import HOSTNAME_GTW01 with context %}
 {% from 'shared-salt.yaml' import IPV4_NET_EXTERNAL_PREFIX with context %}
 {% from 'shared-salt.yaml' import IPV4_NET_TENANT_PREFIX with context %}
+{% from 'virtual-mcp-pike-ovs/underlay.yaml' import LAB_CONFIG_NAME with context %}
+{% from 'virtual-mcp-pike-ovs/underlay.yaml' import DOMAIN_NAME with context %}
 
+{% import 'shared-salt.yaml' as SHARED with context %}
 # Install OpenStack control services
 
 - description: Install glance on all controllers
@@ -236,23 +239,6 @@
   retry: {count: 10, delay: 30}
   skip_fail: false
 
-
-  # Upload cirros image
-
-- description: Upload cirros image on ctl01
-  cmd: salt --hard-crash --state-output=mixed --state-verbose=False 'ctl01*' cmd.run
-    'wget http://download.cirros-cloud.net/0.3.4/cirros-0.3.4-i386-disk.img'
-  node_name: {{ HOSTNAME_CFG01 }}
-  retry: {count: 2, delay: 30}
-  skip_fail: false
-
-- description: Register image in glance
-  cmd: salt --hard-crash --state-output=mixed --state-verbose=False 'ctl01*' cmd.run
-    '. /root/keystonercv3; glance --timeout 120 image-create --name cirros --visibility public --disk-format qcow2 --container-format bare --progress < /root/cirros-0.3.4-i386-disk.img'
-  node_name: {{ HOSTNAME_CFG01 }}
-  retry: {count: 1, delay: 30}
-  skip_fail: false
-
 - description: Create net04_external
   cmd: salt --hard-crash --state-output=mixed --state-verbose=False 'ctl01*' cmd.run
     '. /root/keystonercv3; neutron net-create net04_ext --router:external True --provider:physical_network physnet1 --provider:network_type flat'
@@ -485,3 +471,5 @@
   node_name: {{ HOSTNAME_CFG01 }}
   retry: {count: 1, delay: 5}
   skip_fail: false
+
+{{ SHARED.RUN_NEW_TEMPEST() }}