aboutsummaryrefslogtreecommitdiffstats
path: root/functest_kubernetes
diff options
context:
space:
mode:
Diffstat (limited to 'functest_kubernetes')
-rw-r--r--functest_kubernetes/ims/ims.py18
-rw-r--r--functest_kubernetes/k8stest.py42
-rw-r--r--functest_kubernetes/rally/rally_kubernetes.py4
-rw-r--r--functest_kubernetes/security/security.py6
4 files changed, 33 insertions, 37 deletions
diff --git a/functest_kubernetes/ims/ims.py b/functest_kubernetes/ims/ims.py
index 1feeafab..9a7c6485 100644
--- a/functest_kubernetes/ims/ims.py
+++ b/functest_kubernetes/ims/ims.py
@@ -71,7 +71,7 @@ class Vims(testcase.TestCase): # pylint: disable=too-many-instance-attributes
generate_name=self.ns_generate_name)))
self.namespace = api_response.metadata.name
self.__logger.debug("create_namespace: %s", api_response)
- self.zone = '{}.svc.cluster.local'.format(self.namespace)
+ self.zone = f'{self.namespace}.svc.cluster.local'
metadata = client.V1ObjectMeta(
name=self.metadata_name, namespace=self.namespace)
body = client.V1ConfigMap(
@@ -127,9 +127,9 @@ class Vims(testcase.TestCase): # pylint: disable=too-many-instance-attributes
assert self.zone
container = client.V1Container(
name=self.test_container_name, image=self.test_image_name,
- command=["rake", "test[{}]".format(self.zone),
- "PROXY=bono.{}".format(self.zone),
- "ELLIS=ellis.{}".format(self.zone),
+ command=["rake", f"test[{self.zone}]",
+ f"PROXY=bono.{self.zone}",
+ f"ELLIS=ellis.{self.zone}",
"SIGNUP_CODE=secret", "--trace"])
spec = client.V1PodSpec(containers=[container], restart_policy="Never")
metadata = client.V1ObjectMeta(name=self.test_container_name)
@@ -141,8 +141,7 @@ class Vims(testcase.TestCase): # pylint: disable=too-many-instance-attributes
namespace=self.namespace, timeout_seconds=self.watch_timeout):
self.__logger.debug(event)
if event["object"].metadata.name == self.test_container_name:
- if (event["object"].status.phase == 'Succeeded'
- or event["object"].status.phase == 'Failed'):
+ if event["object"].status.phase in ('Succeeded', 'Failed'):
watch_deployment.stop()
api_response = self.corev1.read_namespaced_pod_log(
name=self.test_container_name, namespace=self.namespace)
@@ -220,7 +219,7 @@ class K8sVims(Vims):
for deployment in self.deployment_list:
with open(pkg_resources.resource_filename(
'functest_kubernetes',
- 'ims/{}-depl.yaml'.format(deployment)),
+ f'ims/{deployment}-depl.yaml'),
encoding='utf-8') as yfile:
template = Template(yfile.read())
body = yaml.safe_load(template.render(
@@ -235,8 +234,7 @@ class K8sVims(Vims):
"create_namespaced_deployment: %s", resp)
for service in self.deployment_list:
with open(pkg_resources.resource_filename(
- 'functest_kubernetes',
- 'ims/{}-svc.yaml'.format(service)),
+ 'functest_kubernetes', f'ims/{service}-svc.yaml'),
encoding='utf-8') as yfile:
body = yaml.safe_load(yfile)
resp = self.corev1.create_namespaced_service(
@@ -284,7 +282,7 @@ class HelmVims(Vims):
quay_repo = os.getenv("QUAY_REPO", self.quay_repo)
cmd = [
"helm", "install", "clearwater", "--set",
- "repo.dockerHub={},repo.quay={}".format(dockerhub_repo, quay_repo),
+ f"repo.dockerHub={dockerhub_repo},repo.quay={quay_repo}",
pkg_resources.resource_filename("functest_kubernetes", "ims/helm"),
"-n", self.namespace]
output = subprocess.check_output(cmd, stderr=subprocess.STDOUT)
diff --git a/functest_kubernetes/k8stest.py b/functest_kubernetes/k8stest.py
index bbfc5376..b4843e73 100644
--- a/functest_kubernetes/k8stest.py
+++ b/functest_kubernetes/k8stest.py
@@ -57,16 +57,16 @@ class E2ETesting(testcase.TestCase):
def run_kubetest(self, **kwargs): # pylint: disable=too-many-branches
"""Run the test suites"""
cmd_line = [
- 'ginkgo', '--nodes={}'.format(kwargs.get("nodes", 1)),
+ 'ginkgo', f'--nodes={kwargs.get("nodes", 1)}',
'--noColor', '/usr/local/bin/e2e.test', '--',
'-kubeconfig', self.config,
'-provider', kwargs.get('provider', 'local'),
'-report-dir', self.res_dir]
for arg in kwargs.get("ginkgo", {}):
- cmd_line.extend(['-ginkgo.{}'.format(arg), kwargs["ginkgo"][arg]])
+ cmd_line.extend([f'-ginkgo.{arg}', kwargs["ginkgo"][arg]])
for key, value in self.convert_ini_to_dict(
os.environ.get("E2E_TEST_OPTS", "")).items():
- cmd_line.extend(['-{}'.format(key), value])
+ cmd_line.extend([f'-{key}', value])
if "NON_BLOCKING_TAINTS" in os.environ:
cmd_line.extend(
['-non-blocking-taints', os.environ["NON_BLOCKING_TAINTS"]])
@@ -74,7 +74,7 @@ class E2ETesting(testcase.TestCase):
self._generate_repo_list_file()
self.__logger.info("Starting k8s test: '%s'.", cmd_line)
env = os.environ.copy()
- env["KUBE_TEST_REPO_LIST"] = "{}/repositories.yml".format(self.res_dir)
+ env["KUBE_TEST_REPO_LIST"] = f"{self.res_dir}/repositories.yml"
with subprocess.Popen(
cmd_line, stdout=subprocess.PIPE,
stderr=subprocess.STDOUT, env=env) as process:
@@ -130,23 +130,21 @@ class E2ETesting(testcase.TestCase):
gcr_repo = os.getenv("GCR_REPO", self.gcr_repo)
k8s_gcr_repo = os.getenv("K8S_GCR_REPO", self.k8s_gcr_repo)
repo_list = {
- "GcAuthenticatedRegistry": "{}/authenticated-image-pulling".format(
- gcr_repo),
- "E2eRegistry": "{}/kubernetes-e2e-test-images".format(
- gcr_repo),
- "PromoterE2eRegistry": "{}/e2e-test-images".format(
- k8s_gcr_repo),
- "BuildImageRegistry": "{}/build-image".format(k8s_gcr_repo),
- "InvalidRegistry": "invalid.com/invalid",
- "GcEtcdRegistry": "{}".format(k8s_gcr_repo),
- "GcRegistry": "{}".format(k8s_gcr_repo),
- "SigStorageRegistry": "{}/sig-storage".format(k8s_gcr_repo),
- "PrivateRegistry": "{}/k8s-authenticated-test".format(
- gcr_repo),
- "SampleRegistry": "{}/google-samples".format(gcr_repo),
- "GcrReleaseRegistry": "{}/gke-release".format(gcr_repo),
- "MicrosoftRegistry": "mcr.microsoft.com",
+ "GcAuthenticatedRegistry":
+ f"{gcr_repo}/authenticated-image-pulling",
+ "E2eRegistry": f"{gcr_repo}/kubernetes-e2e-test-images",
+ "PromoterE2eRegistry": f"{k8s_gcr_repo}/e2e-test-images",
+ "BuildImageRegistry": f"{k8s_gcr_repo}/build-image",
+ "InvalidRegistry": "invalid.com/invalid",
+ "GcEtcdRegistry": k8s_gcr_repo,
+ "GcRegistry": k8s_gcr_repo,
+ "SigStorageRegistry": f"{k8s_gcr_repo}/sig-storage",
+ "PrivateRegistry": f"{gcr_repo}/k8s-authenticated-test",
+ "SampleRegistry": f"{gcr_repo}/google-samples",
+ "GcrReleaseRegistry": f"{gcr_repo}/gke-release",
+ "MicrosoftRegistry": "mcr.microsoft.com"
}
- with open("{}/repositories.yml".format(
- self.res_dir), 'w', encoding='utf-8') as file:
+ with open(
+ f"{self.res_dir}/repositories.yml", 'w',
+ encoding='utf-8') as file:
yaml.dump(repo_list, file)
diff --git a/functest_kubernetes/rally/rally_kubernetes.py b/functest_kubernetes/rally/rally_kubernetes.py
index ef7949ef..ece7aa89 100644
--- a/functest_kubernetes/rally/rally_kubernetes.py
+++ b/functest_kubernetes/rally/rally_kubernetes.py
@@ -88,7 +88,7 @@ class RallyKubernetes(testcase.TestCase):
result = rapi.task.export(
[task_instance["uuid"]], "html",
output_dest=os.path.join(
- self.res_dir, "{}.html".format(self.case_name)))
+ self.res_dir, f"{self.case_name}.html"))
if "files" in result:
for path in result["files"]:
with open(path, "w+", encoding='utf-8') as output:
@@ -96,7 +96,7 @@ class RallyKubernetes(testcase.TestCase):
result = rapi.task.export(
[task_instance["uuid"]], "junit-xml",
output_dest=os.path.join(
- self.res_dir, "{}.xml".format(self.case_name)))
+ self.res_dir, f"{self.case_name}.xml"))
if "files" in result:
for path in result["files"]:
with open(path, "w+", encoding='utf-8') as output:
diff --git a/functest_kubernetes/security/security.py b/functest_kubernetes/security/security.py
index 3d36679f..751fd29b 100644
--- a/functest_kubernetes/security/security.py
+++ b/functest_kubernetes/security/security.py
@@ -66,7 +66,7 @@ class SecurityTesting(testcase.TestCase):
self.__logger.debug("create_namespace: %s", api_response)
with open(pkg_resources.resource_filename(
"functest_kubernetes",
- "security/{}.yaml".format(self.job_name)),
+ f"security/{self.job_name}.yaml"),
encoding='utf-8') as yfile:
template = Template(yfile.read())
body = yaml.safe_load(template.render(
@@ -87,7 +87,7 @@ class SecurityTesting(testcase.TestCase):
time.time()-self.start_time)
watch_job.stop()
pods = self.corev1.list_namespaced_pod(
- self.namespace, label_selector='job-name={}'.format(self.job_name))
+ self.namespace, label_selector=f'job-name={self.job_name}')
self.pod = pods.items[0].metadata.name
self.pod_log = self.corev1.read_namespaced_pod_log(
name=self.pod, namespace=self.namespace)
@@ -207,7 +207,7 @@ class KubeBench(SecurityTesting):
self.ns_generate_name = "kube-bench-"
def run(self, **kwargs):
- self.job_name = "kube-bench-{}".format(kwargs.get("target", "node"))
+ self.job_name = f'kube-bench-{kwargs.get("target", "node")}'
super().run(**kwargs)
self.details["report"] = ast.literal_eval(self.pod_log)
msg = prettytable.PrettyTable(