Set encoding utf-8 when opening file 10/72910/2
authorCédric Ollivier <cedric.ollivier@orange.com>
Sat, 11 Sep 2021 08:24:53 +0000 (10:24 +0200)
committerCédric Ollivier <cedric.ollivier@orange.com>
Sat, 11 Sep 2021 08:55:16 +0000 (10:55 +0200)
Change-Id: I4e756552173247499ba882bfee4fbe8738fbae3d
Signed-off-by: Cédric Ollivier <cedric.ollivier@orange.com>
(cherry picked from commit 5a565816e30dcb5aefb2feb33acce7ef7a457cc0)

functest_kubernetes/cnf_conformance/conformance.py
functest_kubernetes/ims/ims.py
functest_kubernetes/k8stest.py
functest_kubernetes/rally/rally_kubernetes.py
functest_kubernetes/security/security.py

index fa174f1..2cf4baa 100644 (file)
@@ -76,7 +76,8 @@ class CNFConformance(testcase.TestCase):
         lfiles = glob.glob(os.path.join(
             self.src_dir, 'results', 'cnf-testsuite-results-*.yml'))
         results = max(lfiles, key=os.path.getmtime)
-        with open(os.path.join(self.src_dir, 'results', results)) as yfile:
+        with open(os.path.join(
+                self.src_dir, 'results', results), encoding='utf-8') as yfile:
             self.details = yaml.safe_load(yfile)
             msg = prettytable.PrettyTable(
                 header_style='upper', padding_width=5,
index 18e8c0d..1feeafa 100644 (file)
@@ -220,7 +220,8 @@ class K8sVims(Vims):
         for deployment in self.deployment_list:
             with open(pkg_resources.resource_filename(
                     'functest_kubernetes',
-                    'ims/{}-depl.yaml'.format(deployment))) as yfile:
+                    'ims/{}-depl.yaml'.format(deployment)),
+                    encoding='utf-8') as yfile:
                 template = Template(yfile.read())
                 body = yaml.safe_load(template.render(
                     dockerhub_repo=os.getenv(
@@ -235,7 +236,8 @@ class K8sVims(Vims):
         for service in self.deployment_list:
             with open(pkg_resources.resource_filename(
                     'functest_kubernetes',
-                    'ims/{}-svc.yaml'.format(service))) as yfile:
+                    'ims/{}-svc.yaml'.format(service)),
+                    encoding='utf-8') as yfile:
                 body = yaml.safe_load(yfile)
                 resp = self.corev1.create_namespaced_service(
                     body=body, namespace=self.namespace)
index b450dac..34c8ab9 100644 (file)
@@ -78,7 +78,8 @@ class E2ETesting(testcase.TestCase):
                 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:
+        with open(os.path.join(
+                self.res_dir, 'e2e.log'), 'w', encoding='utf-8') as foutput:
             foutput.write(boutput)
         grp = re.search(
             r'^(FAIL|SUCCESS)!.* ([0-9]+) Passed \| ([0-9]+) Failed \|'
@@ -145,5 +146,6 @@ class E2ETesting(testcase.TestCase):
             "GcrReleaseRegistry":      "{}/gke-release".format(gcr_repo),
             "MicrosoftRegistry":       "mcr.microsoft.com",
         }
-        with open("{}/repositories.yml".format(self.res_dir), 'w') as file:
+        with open("{}/repositories.yml".format(
+                self.res_dir), 'w', encoding='utf-8') as file:
             yaml.dump(repo_list, file)
index 3543fa9..ef7949e 100644 (file)
@@ -65,7 +65,8 @@ class RallyKubernetes(testcase.TestCase):
                 result['existing@kubernetes']['message'])
             return
         with open(pkg_resources.resource_filename(
-                'functest_kubernetes', 'rally/all-in-one.yaml')) as file:
+                'functest_kubernetes', 'rally/all-in-one.yaml'),
+                encoding='utf-8') as file:
             template = Template(file.read())
         task = yaml.safe_load(template.render(
             concurrency=kwargs.get("concurrency", self.concurrency),
@@ -90,7 +91,7 @@ class RallyKubernetes(testcase.TestCase):
                 self.res_dir, "{}.html".format(self.case_name)))
         if "files" in result:
             for path in result["files"]:
-                with open(path, "w+") as output:
+                with open(path, "w+", encoding='utf-8') as output:
                     output.write(result["files"][path])
         result = rapi.task.export(
             [task_instance["uuid"]], "junit-xml",
@@ -98,6 +99,6 @@ class RallyKubernetes(testcase.TestCase):
                 self.res_dir, "{}.xml".format(self.case_name)))
         if "files" in result:
             for path in result["files"]:
-                with open(path, "w+") as output:
+                with open(path, "w+", encoding='utf-8') as output:
                     output.write(result["files"][path])
         self.stop_time = time.time()
index b6f19c7..3d36679 100644 (file)
@@ -66,7 +66,8 @@ 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))) as yfile:
+                "security/{}.yaml".format(self.job_name)),
+                encoding='utf-8') as yfile:
             template = Template(yfile.read())
             body = yaml.safe_load(template.render(
                 dockerhub_repo=os.getenv("DOCKERHUB_REPO",