diff options
Diffstat (limited to 'functest_kubernetes')
-rw-r--r-- | functest_kubernetes/cnf_conformance/conformance.py | 2 | ||||
-rw-r--r-- | functest_kubernetes/ims/ims.py | 11 | ||||
-rw-r--r-- | functest_kubernetes/k8stest.py | 9 | ||||
-rw-r--r-- | functest_kubernetes/netperf/netperf.py | 2 | ||||
-rw-r--r-- | functest_kubernetes/rally/rally_kubernetes.py | 2 | ||||
-rw-r--r-- | functest_kubernetes/security/security.py | 11 |
6 files changed, 19 insertions, 18 deletions
diff --git a/functest_kubernetes/cnf_conformance/conformance.py b/functest_kubernetes/cnf_conformance/conformance.py index 13268e24..8956598a 100644 --- a/functest_kubernetes/cnf_conformance/conformance.py +++ b/functest_kubernetes/cnf_conformance/conformance.py @@ -43,7 +43,7 @@ class CNFConformance(testcase.TestCase): __logger = logging.getLogger(__name__) def __init__(self, **kwargs): - super(CNFConformance, self).__init__(**kwargs) + super().__init__(**kwargs) self.output_log_name = 'functest-kubernetes.log' self.output_debug_log_name = 'functest-kubernetes.debug.log' diff --git a/functest_kubernetes/ims/ims.py b/functest_kubernetes/ims/ims.py index 49a66370..18e8c0de 100644 --- a/functest_kubernetes/ims/ims.py +++ b/functest_kubernetes/ims/ims.py @@ -14,9 +14,9 @@ from __future__ import division import abc import logging import os -import time -import subprocess import re +import subprocess +import time import yaml from jinja2 import Template @@ -24,7 +24,6 @@ from kubernetes import client from kubernetes import config from kubernetes import watch import pkg_resources - from xtesting.core import testcase @@ -51,7 +50,7 @@ class Vims(testcase.TestCase): # pylint: disable=too-many-instance-attributes "homestead", "homestead-prov", "ralf", "sprout"] def __init__(self, **kwargs): - super(Vims, self).__init__(**kwargs) + super().__init__(**kwargs) config.load_kube_config() self.corev1 = client.CoreV1Api() self.appsv1 = client.AppsV1Api() @@ -260,7 +259,7 @@ class K8sVims(Vims): "delete_namespaced_service: %s", api_response) except client.rest.ApiException: pass - super(K8sVims, self).clean() + super().clean() class HelmVims(Vims): @@ -293,4 +292,4 @@ class HelmVims(Vims): cmd = ["helm", "uninstall", "clearwater", "-n", self.namespace] output = subprocess.check_output(cmd, stderr=subprocess.STDOUT) self.__logger.debug(output.decode("utf-8")) - super(HelmVims, self).clean() + super().clean() diff --git a/functest_kubernetes/k8stest.py b/functest_kubernetes/k8stest.py index 2d17a27d..b450dac4 100644 --- a/functest_kubernetes/k8stest.py +++ b/functest_kubernetes/k8stest.py @@ -35,7 +35,7 @@ class E2ETesting(testcase.TestCase): k8s_gcr_repo = os.getenv("MIRROR_REPO", "k8s.gcr.io") def __init__(self, **kwargs): - super(E2ETesting, self).__init__(**kwargs) + super().__init__(**kwargs) self.cmd = [] self.dir_results = "/home/opnfv/functest/results" self.res_dir = os.path.join(self.dir_results, self.case_name) @@ -74,9 +74,10 @@ class E2ETesting(testcase.TestCase): self.__logger.info("Starting k8s test: '%s'.", cmd_line) env = os.environ.copy() env["KUBE_TEST_REPO_LIST"] = "{}/repositories.yml".format(self.res_dir) - process = subprocess.Popen(cmd_line, stdout=subprocess.PIPE, - stderr=subprocess.STDOUT, env=env) - boutput = process.stdout.read() + with subprocess.Popen( + cmd_line, stdout=subprocess.PIPE, + stderr=subprocess.STDOUT, env=env) as process: + boutput = process.stdout.read() with open(os.path.join(self.res_dir, 'e2e.log'), 'wb') as foutput: foutput.write(boutput) grp = re.search( diff --git a/functest_kubernetes/netperf/netperf.py b/functest_kubernetes/netperf/netperf.py index 3135a6c5..2bd1e1be 100644 --- a/functest_kubernetes/netperf/netperf.py +++ b/functest_kubernetes/netperf/netperf.py @@ -27,7 +27,7 @@ class Netperf(testcase.TestCase): __logger = logging.getLogger(__name__) def __init__(self, **kwargs): - super(Netperf, self).__init__(**kwargs) + super().__init__(**kwargs) self.output_log_name = 'functest-kubernetes.log' self.output_debug_log_name = 'functest-kubernetes.debug.log' diff --git a/functest_kubernetes/rally/rally_kubernetes.py b/functest_kubernetes/rally/rally_kubernetes.py index f5d7e955..3543fa99 100644 --- a/functest_kubernetes/rally/rally_kubernetes.py +++ b/functest_kubernetes/rally/rally_kubernetes.py @@ -36,7 +36,7 @@ class RallyKubernetes(testcase.TestCase): k8s_gcr_repo = os.getenv("MIRROR_REPO", "k8s.gcr.io") def __init__(self, **kwargs): - super(RallyKubernetes, self).__init__(**kwargs) + super().__init__(**kwargs) self.dir_results = "/home/opnfv/functest/results" self.res_dir = os.path.join(self.dir_results, self.case_name) self.output_log_name = 'functest-kubernetes.log' diff --git a/functest_kubernetes/security/security.py b/functest_kubernetes/security/security.py index 052c0ad4..b6f19c75 100644 --- a/functest_kubernetes/security/security.py +++ b/functest_kubernetes/security/security.py @@ -27,6 +27,7 @@ from kubernetes import config from kubernetes import watch import pkg_resources import prettytable + from xtesting.core import testcase @@ -39,7 +40,7 @@ class SecurityTesting(testcase.TestCase): __logger = logging.getLogger(__name__) def __init__(self, **kwargs): - super(SecurityTesting, self).__init__(**kwargs) + super().__init__(**kwargs) config.load_kube_config() self.corev1 = client.CoreV1Api() self.batchv1 = client.BatchV1Api() @@ -133,7 +134,7 @@ class KubeHunter(SecurityTesting): __logger = logging.getLogger(__name__) def __init__(self, **kwargs): - super(KubeHunter, self).__init__(**kwargs) + super().__init__(**kwargs) self.job_name = "kube-hunter" self.ns_generate_name = "kube-hunter-" @@ -181,7 +182,7 @@ class KubeHunter(SecurityTesting): self.__logger.info("\n\n%s\n", msg.get_string()) def run(self, **kwargs): - super(KubeHunter, self).run(**kwargs) + super().run(**kwargs) try: self.process_results(**kwargs) except Exception: # pylint: disable=broad-except @@ -200,13 +201,13 @@ class KubeBench(SecurityTesting): __logger = logging.getLogger(__name__) def __init__(self, **kwargs): - super(KubeBench, self).__init__(**kwargs) + super().__init__(**kwargs) self.job_name = "kube-bench" self.ns_generate_name = "kube-bench-" def run(self, **kwargs): self.job_name = "kube-bench-{}".format(kwargs.get("target", "node")) - super(KubeBench, self).run(**kwargs) + super().run(**kwargs) self.details["report"] = ast.literal_eval(self.pod_log) msg = prettytable.PrettyTable( header_style='upper', padding_width=5, |