Add swarm-run-test job

- add swarm-run-test job to run pytest tests
- workaround for timesync
- common groovy script for k8s and openstack deployments

Change-Id: Icfe13371fbed231bb4f5fd794d0a43edf347c06a
diff --git a/tcp_tests/fixtures/stacklight_fixtures.py b/tcp_tests/fixtures/stacklight_fixtures.py
index 2c30530..df0d516 100644
--- a/tcp_tests/fixtures/stacklight_fixtures.py
+++ b/tcp_tests/fixtures/stacklight_fixtures.py
@@ -52,7 +52,7 @@
     :rtype: SLManager
     """
     # Deploy SL services
-    if not config.stack_light.sl_installed:
+    if not config.stack_light.stacklight_installed:
         steps_path = config.sl_deploy.sl_steps_path
         commands = underlay.read_template(steps_path)
         sl_actions.install(commands)
diff --git a/tcp_tests/managers/sl_manager.py b/tcp_tests/managers/sl_manager.py
index ba45e16..0f81596 100644
--- a/tcp_tests/managers/sl_manager.py
+++ b/tcp_tests/managers/sl_manager.py
@@ -39,7 +39,7 @@
 
     def install(self, commands, label='Install SL services'):
         self.execute_commands(commands, label=label)
-        self.__config.stack_light.sl_installed = True
+        self.__config.stack_light.stacklight_installed = True
         self.__config.stack_light.sl_vip_host = self.get_sl_vip()
 
     def get_sl_vip(self):
diff --git a/tcp_tests/settings_oslo.py b/tcp_tests/settings_oslo.py
index 8da0fae..ba3fb64 100644
--- a/tcp_tests/settings_oslo.py
+++ b/tcp_tests/settings_oslo.py
@@ -270,7 +270,7 @@
 ]
 
 sl_opts = [
-    ct.Cfg('sl_installed', ct.Boolean(),
+    ct.Cfg('stacklight_installed', ct.Boolean(),
            help="", default=False),
     ct.Cfg('sl_version', ct.String(),
            help="StackLight version. Could be 1 or 2", default=''),
diff --git a/tcp_tests/templates/cookied-cicd-k8s-calico-sl/deploy-and-test.groovy b/tcp_tests/templates/cookied-cicd-k8s-calico-sl/deploy-and-test.groovy
deleted file mode 100644
index d0f69b7..0000000
--- a/tcp_tests/templates/cookied-cicd-k8s-calico-sl/deploy-and-test.groovy
+++ /dev/null
@@ -1,72 +0,0 @@
-@Library('tcp-qa')_
-
-common = new com.mirantis.mk.Common()
-shared = new com.mirantis.system_qa.SharedPipeline()
-
-node ("${NODE_NAME}") {
-  try {
-
-    stage("Clean the environment and clone tcp-qa") {
-        shared.prepare_working_dir()
-    }
-
-    stage("Create environment, generate mode, bootstrap the salt-cluster") {
-        shared.swarm_bootstrap_salt_cluster_devops()
-    }
-
-    // Install core and cicd
-    stage("Run Jenkins job on salt-master [deploy_openstack:core]") {
-        shared.run_job_on_day01_node("core")
-    }
-
-    stage("Run Jenkins job on salt-master [deploy_openstack:cicd]") {
-        shared.run_job_on_day01_node("cicd")
-    }
-
-    // Install the cluster
-    for (stack in "${PLATFORM_STACK_INSTALL}".split(",")) {
-        stage("Run Jenkins job on CICD [deploy_openstack:${stack}]") {
-            shared.run_job_on_cicd_nodes(stack)
-        }
-    }
-
-    stage("Run tests") {
-        shared.run_cmd("""\
-            export ENV_NAME=${ENV_NAME}
-            . ./tcp_tests/utils/env_salt
-            . ./tcp_tests/utils/env_k8s
-
-            # Initialize variables used in tcp-qa tests
-            export CURRENT_SNAPSHOT=stacklight_deployed  # provide the snapshot name required by the test
-            export TESTS_CONFIGS=\$(pwd)/${ENV_NAME}_salt_deployed.ini  # some SSH data may be filled separatelly
-
-            export MANAGER=empty  # skip 'hardware' fixture, disable snapshot/revert features
-            # export SSH='{...}'  # non-empty SSH required to skip 'underlay' fixture. It is filled from TESTS_CONFIGS now
-            export salt_master_host=\$SALT_MASTER_IP  # skip salt_deployed fixture
-            export salt_master_port=6969
-            export SALT_USER=\$SALTAPI_USER
-            export SALT_PASSWORD=\$SALTAPI_PASS
-            export CORE_INSTALLED=true  # skip core_deployed fixture
-            export K8S_INSTALLED=true              # skip k8s_deployed fixture
-            export sl_installed=true              # skip stacklight_deployed fixture
-
-            py.test -vvv -s -p no:django -p no:ipdb --junit-xml=nosetests.xml -m k8s_calico_sl
-
-            #dos.py suspend ${ENV_NAME}
-            #dos.py snapshot ${ENV_NAME} test_completed
-            #dos.py resume ${ENV_NAME}
-            #dos.py time-sync ${ENV_NAME}
-            """)
-    }
-
-  } catch (e) {
-      common.printMsg("Job failed", "red")
-      throw e
-  } finally {
-    // TODO(ddmitriev): analyze the "def currentResult = currentBuild.result ?: 'SUCCESS'"
-    // and report appropriate data to TestRail
-    shared.run_cmd("""\
-        dos.py destroy ${ENV_NAME}
-    """)
-  }
-}
\ No newline at end of file
diff --git a/tcp_tests/templates/cookied-cicd-k8s-calico/deploy-and-test.groovy b/tcp_tests/templates/cookied-cicd-k8s-calico/deploy-and-test.groovy
deleted file mode 100644
index 83335a9..0000000
--- a/tcp_tests/templates/cookied-cicd-k8s-calico/deploy-and-test.groovy
+++ /dev/null
@@ -1,67 +0,0 @@
-@Library('tcp-qa')_
-
-common = new com.mirantis.mk.Common()
-shared = new com.mirantis.system_qa.SharedPipeline()
-
-node ("${NODE_NAME}") {
-  try {
-
-    stage("Clean the environment and clone tcp-qa") {
-        shared.prepare_working_dir()
-    }
-
-    stage("Create environment, generate mode, bootstrap the salt-cluster") {
-        shared.swarm_bootstrap_salt_cluster_devops()
-    }
-
-    // Install core and cicd
-    stage("Run Jenkins job on salt-master [deploy_openstack:core]") {
-        shared.run_job_on_day01_node("core")
-    }
-
-    stage("Run Jenkins job on salt-master [deploy_openstack:cicd]") {
-        shared.run_job_on_day01_node("cicd")
-    }
-
-    // Install the cluster
-    for (stack in "${PLATFORM_STACK_INSTALL}".split(",")) {
-        stage("Run Jenkins job on CICD [deploy_openstack:${stack}]") {
-            shared.run_job_on_cicd_nodes(stack)
-        }
-    }
-
-    stage("Run tests") {
-        shared.run_cmd("""\
-            export ENV_NAME=${ENV_NAME}
-            . ./tcp_tests/utils/env_salt
-            . ./tcp_tests/utils/env_k8s
-
-            # Initialize variables used in tcp-qa tests
-            export CURRENT_SNAPSHOT=k8s_deployed  # provide the snapshot name required by the test
-            export TESTS_CONFIGS=\$(pwd)/${ENV_NAME}_salt_deployed.ini  # some SSH data may be filled separatelly
-
-            export MANAGER=empty  # skip 'hardware' fixture, disable snapshot/revert features
-            # export SSH='{...}'  # non-empty SSH required to skip 'underlay' fixture. It is filled from TESTS_CONFIGS now
-            export salt_master_host=\$SALT_MASTER_IP  # skip salt_deployed fixture
-            export salt_master_port=6969
-            export SALT_USER=\$SALTAPI_USER
-            export SALT_PASSWORD=\$SALTAPI_PASS
-            export CORE_INSTALLED=true  # skip core_deployed fixture
-            export K8S_INSTALLED=true              # skip k8s_deployed fixture
-
-            py.test -vvv -s -p no:django -p no:ipdb --junit-xml=nosetests.xml -m k8s_calico
-            """)
-    }
-
-  } catch (e) {
-      common.printMsg("Job failed", "red")
-      throw e
-  } finally {
-    // TODO(ddmitriev): analyze the "def currentResult = currentBuild.result ?: 'SUCCESS'"
-    // and report appropriate data to TestRail
-    shared.run_cmd("""\
-        dos.py destroy ${ENV_NAME}
-    """)
-  }
-
-}
\ No newline at end of file
diff --git a/tcp_tests/tests/environment/test_bootstrap_salt.py b/tcp_tests/tests/environment/test_bootstrap_underlay.py
similarity index 96%
rename from tcp_tests/tests/environment/test_bootstrap_salt.py
rename to tcp_tests/tests/environment/test_bootstrap_underlay.py
index f852ffa..9458c5b 100644
--- a/tcp_tests/tests/environment/test_bootstrap_salt.py
+++ b/tcp_tests/tests/environment/test_bootstrap_underlay.py
@@ -19,7 +19,7 @@
 LOG = logger.logger
 
 
-class TestBootstrapCore(object):
+class TestBootstrapUnderlay(object):
     """Test class for deploy local dns_vm"""
 
     def test_create_environment(self, config, hardware):