Add junitOutput flag to virtlet tests

- Also get JUnit output for it

Change-Id: I29ad71b317743754520acdce9895faebc1bd6af4
diff --git a/tcp_tests/fixtures/k8s_fixtures.py b/tcp_tests/fixtures/k8s_fixtures.py
index fe744ec..6cc2721 100644
--- a/tcp_tests/fixtures/k8s_fixtures.py
+++ b/tcp_tests/fixtures/k8s_fixtures.py
@@ -93,7 +93,8 @@
         if hasattr(request.node, 'rep_call') and \
                 (request.node.rep_call.passed or request.node.rep_call.failed)\
                 and grab_virtlet_result:
-            artifact_name = utils.extract_name_from_mark(grab_virtlet_result) \
+            files = utils.extract_name_from_mark(grab_virtlet_result) \
                             or "{}".format(func_name)
-            k8s_deployed.download_virtlet_conformance_log(artifact_name)
+            k8s_deployed.extract_file_to_node()
+            k8s_deployed.download_virtlet_conformance_log(files)
     request.addfinalizer(test_fin)
diff --git a/tcp_tests/managers/k8smanager.py b/tcp_tests/managers/k8smanager.py
index 1126011..5e8ea21 100644
--- a/tcp_tests/managers/k8smanager.py
+++ b/tcp_tests/managers/k8smanager.py
@@ -505,8 +505,8 @@
                        "xenial-server-cloudimg-amd64-disk1.img"
             cmd = ("set -o pipefail; "
                    "docker run --net=host {0} /virtlet-e2e-tests "
-                   "-include-cloud-init-tests -image {2} "
-                   "-sshuser ubuntu -memoryLimit 1024 "
+                   "-include-cloud-init-tests -junitOutput report.xml "
+                   "-image {2} -sshuser ubuntu -memoryLimit 1024 "
                    "-alsologtostderr -cluster-url http://127.0.0.1:8080 "
                    "-ginkgo.focus '\[Conformance\]' "
                    "| tee {1}".format(
@@ -515,6 +515,7 @@
         else:
             cmd = ("set -o pipefail; "
                    "docker run --net=host {0} /virtlet-e2e-tests "
+                   "-junitOutput report.xml "
                    "-alsologtostderr -cluster-url http://127.0.0.1:8080 "
                    "-ginkgo.focus '\[Conformance\]' "
                    "| tee {1}".format(
@@ -530,11 +531,37 @@
             LOG.info("Test results stderr: {}".format(stderr))
         return result
 
-    def download_virtlet_conformance_log(self,
-                                         log_file='virtlet_conformance.log'):
+    def extract_file_to_node(self, container='virtlet',
+                             file_path='report.xml'):
+        """
+        Download file from docker container to node
+
+        :param container: Full name of part of name
+        :param file_path: File path in container
+        :return:
+        """
+        with self.__underlay.remote(
+                node_name=self.ctl_host) as remote:
+            cmd = ("docker ps --all | grep {0} |"
+                   " awk '{{print $1}}'".format(container))
+            result = remote.check_call(cmd)
+            container_id = result['stdout'][0].strip()
+            cmd = "docker start {}".format(container_id)
+            remote.check_call(cmd)
+            cmd = "docker cp {0}:/{1} .".format(container_id, file_path)
+            remote.check_call(cmd)
+
+    def download_virtlet_conformance_log(self, files):
+        """
+        Download JUnit report and conformance logs from cluster
+        :param files:
+        :return:
+        """
         master_host = self.__config.salt.salt_master_host
         with self.__underlay.remote(host=master_host) as r:
-            cmd = "rsync {0}:/root/{1} /root/".format(self.ctl_host, log_file)
-            r.check_call(cmd, raise_on_err=False)
-            LOG.info("Downloading the artifact {0}".format(log_file))
-            r.download(destination=log_file, target=os.getcwd())
+            for log_file in files:
+                cmd = "rsync {0}:/root/{1} /root/".format(self.ctl_host,
+                                                          log_file)
+                r.check_call(cmd, raise_on_err=False)
+                LOG.info("Downloading the artifact {0}".format(log_file))
+                r.download(destination=log_file, target=os.getcwd())
diff --git a/tcp_tests/tests/system/test_virtlet_actions.py b/tcp_tests/tests/system/test_virtlet_actions.py
index e0e8011..7fd593e 100644
--- a/tcp_tests/tests/system/test_virtlet_actions.py
+++ b/tcp_tests/tests/system/test_virtlet_actions.py
@@ -90,7 +90,8 @@
         k8s_deployed.delete_vm(target_yaml)
 
     @pytest.mark.grab_versions
-    @pytest.mark.grab_virtlet_results(name='virtlet_conformance.log')
+    @pytest.mark.grab_virtlet_results(name=['virtlet_conformance.log',
+                                            'report.xml'])
     @pytest.mark.fail_snapshot
     def test_virtlet_conformance(self, show_step, config, k8s_deployed,
                                  virtlet_logs):