From 285a392ba111384fc08b4348231a3bfe4c66220c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B8=A0=E7=A3=8A?= Date: Sat, 11 May 2024 15:30:19 +0800 Subject: [PATCH] Reduce not version in this scene and Unadapted by version SKIP log level, set the default value for comparison method to 0. --- common/scene.py | 2 +- handler/checker/result/verify.py | 55 ++++++++++++++++---------------- handler/gather/scenes/base.py | 2 +- 3 files changed, 30 insertions(+), 29 deletions(-) diff --git a/common/scene.py b/common/scene.py index 735d38b0..c9c4016c 100644 --- a/common/scene.py +++ b/common/scene.py @@ -53,7 +53,7 @@ def filter_by_version(scene, cluster, stdio=None): break steps_nu = steps_nu + 1 if steps_nu > len(steps) - 1: - stdio.warn("not version in this scene") + stdio.verbose("not version in this scene") return -1 return steps_nu except Exception as e: diff --git a/handler/checker/result/verify.py b/handler/checker/result/verify.py index d1d6531f..19f470d4 100644 --- a/handler/checker/result/verify.py +++ b/handler/checker/result/verify.py @@ -87,56 +87,57 @@ def _verify_base(self): def _verify_max(self): try: - if isinstance(self.env_dict[self.now_step_set_value_name], decimal.Decimal): - self.env_dict[self.now_step_set_value_name] = int(self.env_dict[self.now_step_set_value_name]) - if not isinstance(self.env_dict[self.now_step_set_value_name], (int, float, decimal.Decimal)): - raise Exception( - "{0} is {1} and the type is {2}, not int or float or decimal !".format(self.now_step_set_value_name, + the_num = self.env_dict[self.now_step_set_value_name] + if isinstance(the_num, decimal.Decimal): + the_num= int(self.env_dict[self.now_step_set_value_name]) + if not isinstance(the_num, (int, float, decimal.Decimal)): + self.stdio.warn( + "{0} is {1} and the type is {2}, not int or float or decimal ! set it to 0.".format(self.now_step_set_value_name, self.env_dict[ self.now_step_set_value_name], type(self.env_dict[ self.now_step_set_value_name]))) + the_num=0 range_str = self.expr - result = int(self.env_dict[self.now_step_set_value_name]) < int(range_str) - return result + return int(the_num) < int(range_str) except Exception as e: self.stdio.error("_verify_max error: {0} -> {1}".format(str(self.expr), e)) raise VerifyFalseException(e) def _verify_min(self): try: - if isinstance(self.env_dict[self.now_step_set_value_name], decimal.Decimal): - self.env_dict[self.now_step_set_value_name] = int(self.env_dict[self.now_step_set_value_name]) - if not isinstance(self.env_dict[self.now_step_set_value_name], (int, float, decimal.Decimal)): - raise Exception( - "{0} is {1} and the type is {2}, not int or float ordecimal !".format(self.now_step_set_value_name, - self.env_dict[ - self.now_step_set_value_name], - type(self.env_dict[ - self.now_step_set_value_name]))) + the_num = self.env_dict[self.now_step_set_value_name] + if isinstance(the_num, decimal.Decimal): + the_num= int(self.env_dict[self.now_step_set_value_name]) + if not isinstance(the_num, (int, float, decimal.Decimal)): + self.stdio.warn( + "{0} is {1} and the type is {2}, not int or float or decimal ! set it to 0.".format(self.now_step_set_value_name, + self.env_dict[ + self.now_step_set_value_name], + type(self.env_dict[ + self.now_step_set_value_name]))) + the_num=0 range_str = self.expr - result = int(self.env_dict[self.now_step_set_value_name]) > int(range_str) - return result + return int(the_num) > int(range_str) except Exception as e: self.stdio.error("_verify_min error: {0} -> {1}".format(str(self.expr), e)) raise VerifyFalseException(e) def _verify_equal(self): try: - if isinstance(self.env_dict[self.now_step_set_value_name], decimal.Decimal): - self.env_dict[self.now_step_set_value_name] = int(self.env_dict[self.now_step_set_value_name]) - if not isinstance(self.env_dict[self.now_step_set_value_name], (int, float, decimal.Decimal)): - raise Exception( - "{0} is {1} and the type is {2}, not int or float or decimal !".format(self.now_step_set_value_name, + the_num = self.env_dict[self.now_step_set_value_name] + if isinstance(the_num, decimal.Decimal): + the_num= int(self.env_dict[self.now_step_set_value_name]) + if not isinstance(the_num, (int, float, decimal.Decimal)): + self.stdio.warn( + "{0} is {1} and the type is {2}, not int or float or decimal ! set it to 0.".format(self.now_step_set_value_name, self.env_dict[ self.now_step_set_value_name], type(self.env_dict[ self.now_step_set_value_name]))) - result = False + the_num=0 range_str = self.expr - if int(self.env_dict[self.now_step_set_value_name]) == int(range_str): - result = True + return int(self.env_dict[self.now_step_set_value_name]) == int(range_str) except Exception as e: self.stdio.error("_verify_equal error: {0} -> {1}".format(str(self.expr), e)) raise VerifyFailException(e) - return result diff --git a/handler/gather/scenes/base.py b/handler/gather/scenes/base.py index 286d6302..11bc4de5 100644 --- a/handler/gather/scenes/base.py +++ b/handler/gather/scenes/base.py @@ -59,7 +59,7 @@ def execute(self): def __execute_yaml_mode(self, nodes): steps_nu = filter_by_version(self.scene, self.cluster, self.stdio) if steps_nu < 0: - self.stdio.warn("Unadapted by version. SKIP") + self.stdio.verbose("Unadapted by version. SKIP") return "Unadapted by version.SKIP" self.stdio.verbose("filter_by_version is return {0}".format(steps_nu)) if len(nodes)==0: