Fixing unit tests

We had several failures in unit tests. Fixing
them.

Change-Id: I87d69d347298d88e8af587fb95483561f3e48a44
This commit is contained in:
jpike
2025-05-01 09:35:02 -04:00
parent 042bcd76c5
commit 1535e568d9
4 changed files with 20 additions and 46 deletions

View File

@@ -36,5 +36,5 @@
"subcloud1": "config/lab/files/template_subcloud1.json5",
"subcloud2": "config/lab/files/template_subcloud2.json5"
},
"secondary_system_controller": "config/lab/files/secondary_system_controller.json5",
"secondary_system_controller": "config/lab/files/template_secondary_system_controller.json5",
}

View File

@@ -58,34 +58,26 @@ class CatPtpCguParser:
- (.*): Captures any characters (phase offset).
Returns:
PtpCguComponentObject - the PtpCguComponentObject.
PtpCguComponentObject: the PtpCguComponentObject.
Raise:
KeywordException - if output is unable to be parsed.
KeywordException: if output is unable to be parsed.
"""
cgu: PtpCguComponentObject = None
match = re.match(r"(Found (\S+) CGU|Password: Found (\S+) CGU)", self.cat_ptp_cgu_output[0]) # Ask about this
match = re.match(r"Found (\S+) CGU", self.cat_ptp_cgu_output[0]) # Ask about this
if match:
chip_model = match.group(1)
config_version_match = re.search(
r"DPLL Config ver: (.*)", self.cat_ptp_cgu_output[1]
)
fw_version_match = re.search(
r"DPLL FW ver: (.*)", self.cat_ptp_cgu_output[2]
)
config_version_match = re.search(r"DPLL Config ver: (.*)", self.cat_ptp_cgu_output[1])
fw_version_match = re.search(r"DPLL FW ver: (.*)", self.cat_ptp_cgu_output[2])
if config_version_match and fw_version_match:
config_version = config_version_match.group(1)
fw_version = fw_version_match.group(1)
cgu = PtpCguComponentObject(config_version, fw_version, chip_model)
else:
raise KeywordException(
f"Unable to parse output. Got : {self.cat_ptp_cgu_output}"
)
raise KeywordException(f"Unable to parse output. Got : {self.cat_ptp_cgu_output}")
else:
raise KeywordException(
f"Unexpected format: could not parse. Got: {self.cat_ptp_cgu_output}"
)
raise KeywordException(f"Unexpected format: could not parse. Got: {self.cat_ptp_cgu_output}")
for i, line in enumerate(self.cat_ptp_cgu_output):
# CGU Input Status
@@ -95,40 +87,22 @@ class CatPtpCguParser:
)
if match and cgu:
input_name, idx, state, eec, pps, esync_fail = match.groups()
cgu.append_cgu_input(
PtpCguInputObject(
input_name, int(idx), state, int(eec), int(pps), esync_fail
)
)
cgu.append_cgu_input(PtpCguInputObject(input_name, int(idx), state, int(eec), int(pps), esync_fail))
# EEC DPLL
match = re.match(r"EEC DPLL:", line)
if match and cgu:
current_ref_match = re.search(
r"Current reference:\s*(.*)", self.cat_ptp_cgu_output[i + 1]
)
status_match = re.search(
r"Status:\s*(.*)", self.cat_ptp_cgu_output[i + 2]
)
current_ref_match = re.search(r"Current reference:\s*(.*)", self.cat_ptp_cgu_output[i + 1])
status_match = re.search(r"Status:\s*(.*)", self.cat_ptp_cgu_output[i + 2])
if current_ref_match and status_match:
cgu.set_eec_dpll(
PtpCguEecDpllObject(
current_ref_match.group(1), status_match.group(1)
)
)
cgu.set_eec_dpll(PtpCguEecDpllObject(current_ref_match.group(1), status_match.group(1)))
# PPS DPLL
match = re.match(r"PPS DPLL:", line)
if match and cgu:
current_ref_match = re.search(
r"Current reference:\s*(.*)", self.cat_ptp_cgu_output[i + 1]
)
status_match = re.search(
r"Status:\s*(.*)", self.cat_ptp_cgu_output[i + 2]
)
phase_offset_match = re.search(
r"Phase offset \[ps]:\s*(.*)", self.cat_ptp_cgu_output[i + 3]
)
current_ref_match = re.search(r"Current reference:\s*(.*)", self.cat_ptp_cgu_output[i + 1])
status_match = re.search(r"Status:\s*(.*)", self.cat_ptp_cgu_output[i + 2])
phase_offset_match = re.search(r"Phase offset \[ps]:\s*(.*)", self.cat_ptp_cgu_output[i + 3])
if current_ref_match and status_match and phase_offset_match:
cgu.set_pps_dpll(

View File

@@ -164,7 +164,7 @@ def test_cat_ptp_config_output():
assert default_data_set_object.get_socket_priority() == 0
assert default_data_set_object.get_priority1() == 128
assert default_data_set_object.get_priority2() == 128
assert default_data_set_object.get_domain_number() == "0"
assert default_data_set_object.get_domain_number() == 0
assert default_data_set_object.get_utc_offset() == 37
assert default_data_set_object.get_clock_class() == 248
assert default_data_set_object.get_clock_accuracy() == "0xFE"
@@ -283,7 +283,7 @@ def test_cat_ptp_output_format_with_associated_interfaces():
assert default_data_set_object.get_clock_servo() == "linreg"
assert default_data_set_object.get_dataset_comparison() == "G.8275.x"
assert default_data_set_object.get_delay_mechanism() == "E2E"
assert default_data_set_object.get_domain_number() == "24"
assert default_data_set_object.get_domain_number() == 24
assert default_data_set_object.get_message_tag() == "ptp1"
assert default_data_set_object.get_network_transport() == "L2"
assert default_data_set_object.get_priority2() == 100

View File

@@ -20,7 +20,7 @@ pmc_output = [
" offsetScaledLogVariance 0xffff\n",
" priority2 128\n",
" clockIdentity 507c6f.fffe.0b5a4d\n",
" domainNumber 0.\n",
" domainNumber 0\n",
"sysadmin@controller-0:~$\n",
]
@@ -125,7 +125,7 @@ def test_pmc_get_default_data_set_table_parser():
assert output_dict["offsetScaledLogVariance"] == "0xffff"
assert output_dict["priority2"] == "128"
assert output_dict["clockIdentity"] == "507c6f.fffe.0b5a4d"
assert output_dict["domainNumber"] == "0."
assert output_dict["domainNumber"] == 0
def test_pmc_get_default_data_set_output():
@@ -145,7 +145,7 @@ def test_pmc_get_default_data_set_output():
assert pmc_get_default_data_set_object.get_offset_scaled_log_variance() == "0xffff"
assert pmc_get_default_data_set_object.get_priority2() == 128
assert pmc_get_default_data_set_object.get_clock_identity() == "507c6f.fffe.0b5a4d"
assert pmc_get_default_data_set_object.get_domain_number() == "0."
assert pmc_get_default_data_set_object.get_domain_number() == 0
def test_pmc_get_parent_data_set_table_parser():