Skip to content

Commit

Permalink
Fix path to junit file
Browse files Browse the repository at this point in the history
Signed-off-by: Toni Finger <[email protected]>
  • Loading branch information
tonifinger committed Sep 20, 2024
1 parent 9747f3c commit a42542d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 13 deletions.
22 changes: 9 additions & 13 deletions Tests/kaas/plugin/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ class KubernetesClusterPlugin(ABC):
cluster_name = None
k8s_api_client = None
working_directory = None
plugin_result_directory = "plugins/e2e/results/global"

@final
def __init__(self, config=None):
Expand Down Expand Up @@ -103,30 +102,28 @@ def _cleanup_sonobuoy_resources(self):
os.system(f"sonobuoy delete --wait --kubeconfig='{self.kubeconfig_path}'")

@final
def _retrieve_result(self, result_file_name):
def _retrieve_result(self, result_dir_name):
"""
This method invokes sonobouy to store the results in a subdirectory of
the working directory. The Junit results file contained in it is then
analyzed in order to interpret the relevant information it containes
:param: result_file_name:
:return: None
"""
logger.debug(f"retrieving results to {result_file_name}")
result_directory = self.working_directory + "/" + result_file_name
if os.path.exists(result_directory):
os.system(f"rm -rf {result_directory}/*")
logger.debug(f"retrieving results to {result_dir_name}")
result_dir = self.working_directory + "/" + result_dir_name
if os.path.exists(result_dir):
os.system(f"rm -rf {result_dir}/*")
else:
os.mkdir(result_directory)
os.chdir(result_directory)
os.mkdir(result_dir)
os.system(
f"sonobuoy retrieve -x --filename='{result_file_name}' --kubeconfig='{self.kubeconfig_path}'"
f"sonobuoy retrieve {result_dir} -x --filename='{result_dir_name}' --kubeconfig='{self.kubeconfig_path}'"
)

logger.debug(
f"parsing JUnit result from {result_directory + '/' + self.plugin_result_directory + '/junit_01.xml' } "
f"parsing JUnit result from {result_dir + '/plugins/e2e/results/global/junit_01.xml' } "
)
xml = JUnitXml.fromfile(
result_directory + "/" + self.plugin_result_directory + "/junit_01.xml"
result_dir + "/plugins/e2e/results/global/junit_01.xml"
)
failed_test_cases = 0
passed_test_cases = 0
Expand All @@ -143,7 +140,6 @@ def _retrieve_result(self, result_file_name):
logger.info(
f" {passed_test_cases} passed, {failed_test_cases} failed of which {skipped_test_cases} were skipped"
)
os.chdir(self.working_directory)

@abstractmethod
def _create_cluster(self, cluster_name) -> (str, int):
Expand Down
2 changes: 2 additions & 0 deletions Tests/kaas/plugin/plugin_kind.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from interface import KubernetesClusterPlugin
from pytest_kind import KindCluster
import time


class PluginKind(KubernetesClusterPlugin):
Expand All @@ -12,6 +13,7 @@ def _create_cluster(self):
self.cluster_name = "scs-cluster"
self.cluster = KindCluster(self.cluster_name)
self.cluster.create()
time.sleep(30)
self.kubeconfig_path = str(self.cluster.kubeconfig_path.resolve())

def _delete_cluster(self):
Expand Down

0 comments on commit a42542d

Please sign in to comment.