diff options
author | mrichomme <morgan.richomme@orange.com> | 2020-09-10 14:18:12 +0200 |
---|---|---|
committer | mrichomme <morgan.richomme@orange.com> | 2020-09-10 14:18:12 +0200 |
commit | 26dab8f15662e0985a17568c9e81a249ac12b297 (patch) | |
tree | abb7ecee68ced53704f1d101f14c257f47df520f /infra-healthcheck | |
parent | 5918f6086eddca222b197592f985d06eb9e8f139 (diff) |
Prevent parsing error due to format change for onap-helm
Note the success criteria part shall be refactored
For the moment I keep as it is but it is too complex
As we plan to refactor onap-helm to include more detail
I do not do it here
Issue-ID: INT-1718
Signed-off-by: mrichomme <morgan.richomme@orange.com>
Change-Id: Ib93e0afca6b31571607bc0bd548b71a194f44c44
Diffstat (limited to 'infra-healthcheck')
-rw-r--r-- | infra-healthcheck/infra_healthcheck/k8stest.py | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/infra-healthcheck/infra_healthcheck/k8stest.py b/infra-healthcheck/infra_healthcheck/k8stest.py index 1ea2aca..deab627 100644 --- a/infra-healthcheck/infra_healthcheck/k8stest.py +++ b/infra-healthcheck/infra_healthcheck/k8stest.py @@ -50,8 +50,7 @@ class K8sTesting(testcase.TestCase): # create a log file result_folder = "/var/lib/xtesting/results/" + self.case_name + "/" file_name = result_folder + self.case_name + ".log" - if not os.path.exists(result_folder): - os.makedirs(result_folder) + os.makedirs(result_folder, exist_ok=True) log_file = open(file_name, "w") log_file.write(output) log_file.close() @@ -74,14 +73,21 @@ class K8sTesting(testcase.TestCase): # 2 possible Results # * numeric nb pods, failed, duration # * list of pods, charts,... - if '[' in remark: + # split and replace can be hazardous, depending + # on result format change.. + try: + if '[' in remark: # it is a list - str1 = remark.split(":", 1)[1].strip().replace( - ']', '').replace('[', '') - details[remark.split(":", 1)[0].strip()] = str1.split(",") - else: - details[remark.split(":", 1)[0].strip()] = int( - remark.split(":", 1)[1].strip()) + str1 = remark.split( + ":", 1)[1].strip().replace( + ']', '').replace('[', '') + details[remark.split( + ":", 1)[0].strip()] = str1.split(",") + else: + details[remark.split(":", 1)[0].strip()] = int( + remark.split(":", 1)[1].strip()) + except: + pass # if 1 pod/helm chart if Failed, the testcase is failed if int(details[self.criteria_string]) < 1: |