Move run k8s conformance tests to k8s manager.

* Moved step with run k8s conformance tests from template
to k8s manager.
* Added possibility to change k8s conformance image.
* Bumped k8s image version from 1.6.2 to 1.6.4.
* Bumped k8s conformance image version from 1.6.2 to 1.6.4.
* Added possibility to skip conformance tests.

Change-Id: I6e4a3019f8fa6453005fc62614588209114cb02b
Reviewed-on: https://review.gerrithub.io/366656
Reviewed-by: Dennis Dmitriev <dis.xcom@gmail.com>
Reviewed-by: <apanchenko@mirantis.com>
Tested-by: Dennis Dmitriev <dis.xcom@gmail.com>
diff --git a/tcp_tests/managers/k8smanager.py b/tcp_tests/managers/k8smanager.py
index f16be6e..45cb078 100644
--- a/tcp_tests/managers/k8smanager.py
+++ b/tcp_tests/managers/k8smanager.py
@@ -280,3 +280,13 @@
         pods = [pod.status.container_statuses[0].restart_count
                 for pod in self.get_running_pods(pod_name, namespace)]
         return sum(pods)
+
+    def run_conformance(self, timeout=60 * 60):
+        with self.__underlay.remote(
+                host=self.__config.k8s.kube_host) as remote:
+            result = remote.check_call(
+                "docker run --rm --net=host -e API_SERVER="
+                "'http://127.0.0.1:8080' {}".format(
+                    self.__config.k8s.k8s_conformance_image),
+                timeout=timeout)['stdout']
+            return result
diff --git a/tcp_tests/settings_oslo.py b/tcp_tests/settings_oslo.py
index 77ed1b0..b475357 100644
--- a/tcp_tests/settings_oslo.py
+++ b/tcp_tests/settings_oslo.py
@@ -183,7 +183,7 @@
            default='sbPfel23ZigJF3Bm'),
     ct.Cfg('kubernetes_docker_package', ct.String(), default=''),
     ct.Cfg('kubernetes_hyperkube_image', ct.String(),
-           default='{}/mirantis/kubernetes/hyperkube-amd64:v1.6.2-2'.format(
+           default='{}/mirantis/kubernetes/hyperkube-amd64:v1.6.4-3'.format(
                settings.DOCKER_REGISTRY)),
     ct.Cfg('kubernetes_calico_image', ct.String(),
            default='{}/mirantis/projectcalico/calico/node:latest'.format(
@@ -209,6 +209,11 @@
            help="", default='0.0.0.0'),
     ct.Cfg('kube_apiserver_port', ct.Integer(),
            help="", default=443),
+    ct.Cfg("k8s_conformance_run", ct.Boolean(),
+           default=False),
+    ct.Cfg('k8s_conformance_image', ct.String(),
+           default='docker-dev-virtual.docker.mirantis.net/mirantis/'
+                   'kubernetes/k8s-conformance:v1.6.4-3_1495550936267')
 ]
 
 _group_opts = [
diff --git a/tcp_tests/templates/virtual-mcp11-k8s-calico/k8s.yaml b/tcp_tests/templates/virtual-mcp11-k8s-calico/k8s.yaml
index cd287e6..4bbb22a 100644
--- a/tcp_tests/templates/virtual-mcp11-k8s-calico/k8s.yaml
+++ b/tcp_tests/templates/virtual-mcp11-k8s-calico/k8s.yaml
@@ -56,10 +56,3 @@
   node_name: {{ HOSTNAME_CFG01 }}
   retry: {count: 1, delay: 5}
   skip_fail: false
-
-# Run conformance tests
-- description: Run tests
-  cmd: salt --hard-crash --state-output=mixed --state-verbose=False 'ctl01*' cmd.run "docker run --rm --net=host -e API_SERVER='http://127.0.0.1:8080' docker-dev-virtual.docker.mirantis.net/mirantis/kubernetes/k8s-conformance:v1.6.2-2_1493800192393 >> e2e.output"
-  node_name: {{ HOSTNAME_CFG01 }}
-  retry: {count: 1, delay: 5}
-  skip_fail: false
diff --git a/tcp_tests/templates/virtual-mcp11-k8s-contrail/k8s.yaml b/tcp_tests/templates/virtual-mcp11-k8s-contrail/k8s.yaml
index 9813f32..17ad771 100644
--- a/tcp_tests/templates/virtual-mcp11-k8s-contrail/k8s.yaml
+++ b/tcp_tests/templates/virtual-mcp11-k8s-contrail/k8s.yaml
@@ -189,10 +189,3 @@
   node_name: {{ HOSTNAME_CFG01 }}
   retry: {count: 1, delay: 5}
   skip_fail: false
-
-# Run conformance tests
-- description: Run tests
-  cmd: salt --hard-crash --state-output=mixed --state-verbose=False 'ctl01*' cmd.run "docker run --rm --net=host -e API_SERVER='http://127.0.0.1:8080' docker-dev-virtual.docker.mirantis.net/mirantis/kubernetes/k8s-conformance:v1.6.1-1_1491395924598 >> e2e.output"
-  node_name: {{ HOSTNAME_CFG01 }}
-  retry: {count: 1, delay: 5}
-  skip_fail: false
\ No newline at end of file
diff --git a/tcp_tests/tests/system/test_install_k8s.py b/tcp_tests/tests/system/test_install_k8s.py
index 36f42b8..43980a3 100644
--- a/tcp_tests/tests/system/test_install_k8s.py
+++ b/tcp_tests/tests/system/test_install_k8s.py
@@ -24,7 +24,7 @@
     """Test class for testing Kubernetes deploy"""
 
     @pytest.mark.fail_snapshot
-    def test_k8s_install(self, sl_deployed, k8s_deployed):
+    def test_k8s_install(self, config, sl_deployed, k8s_deployed, k8s_actions):
         """Test for deploying MCP environment with k8s+stacklight and check it
 
         Scenario:
@@ -33,12 +33,15 @@
             3. Setup compute nodes
             4. Setup stack light nodes
             5. Setup Kubernetes cluster
+            6. Run conformance if need
 
         """
+        if config.k8s_conformance_run:
+            k8s_actions.run_conformance()
         LOG.info("*************** DONE **************")
 
     @pytest.mark.fail_snapshot
-    def test_only_k8s_install(self, k8s_deployed):
+    def test_only_k8s_install(self, config, k8s_deployed, k8s_actions):
         """Test for deploying MCP environment with k8s and check it
 
         Scenario:
@@ -46,6 +49,9 @@
             2. Setup controller nodes
             3. Setup compute nodes
             4. Setup Kubernetes cluster
+            5. Run conformance if need
 
         """
+        if config.k8s_conformance_run:
+            k8s_actions.run_conformance()
         LOG.info("*************** DONE **************")
\ No newline at end of file