Skip to content

Commit 6c74428

Browse files
committed
fix: Include soaking, add result data in pytest
1 parent bef15c0 commit 6c74428

3 files changed

Lines changed: 41 additions & 34 deletions

File tree

aci-preupgrade-validation-script.py

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3000,21 +3000,22 @@ def apic_disk_space_faults_check(cversion, **kwargs):
30003000

30013001
dn_regex = node_regex + r'/.+p-\[(?P<mountpoint>.+)\]-f'
30023002
desc_regex = r'is (?P<usage>\d{2,3}%) full'
3003-
3003+
30043004
faultInsts = icurl('class',
30053005
'faultInst.json?query-target-filter=or(eq(faultInst.code,"F1527"),eq(faultInst.code,"F1528"),eq(faultInst.code,"F1529"))')
30063006
for faultInst in faultInsts:
30073007
lc = faultInst['faultInst']['attributes']['lc']
3008-
if lc == "raised":
3009-
fc = faultInst['faultInst']['attributes']['code']
3010-
dn = re.search(dn_regex, faultInst['faultInst']['attributes']['dn'])
3011-
desc = re.search(desc_regex, faultInst['faultInst']['attributes']['descr'])
3012-
if dn and desc:
3013-
data.append([fc, dn.group('pod'), dn.group('node'), dn.group('mountpoint'),
3014-
desc.group('usage'),
3015-
recommended_action.get(dn.group('mountpoint'), default_action)])
3016-
else:
3017-
unformatted_data.append([fc, faultInst['faultInst']['attributes']['dn'], default_action])
3008+
if lc not in ["raised", "soaking"]:
3009+
continue
3010+
fc = faultInst['faultInst']['attributes']['code']
3011+
dn = re.search(dn_regex, faultInst['faultInst']['attributes']['dn'])
3012+
desc = re.search(desc_regex, faultInst['faultInst']['attributes']['descr'])
3013+
if dn and desc:
3014+
data.append([fc, dn.group('pod'), dn.group('node'), dn.group('mountpoint'),
3015+
desc.group('usage'),
3016+
recommended_action.get(dn.group('mountpoint'), default_action)])
3017+
else:
3018+
unformatted_data.append([fc, faultInst['faultInst']['attributes']['dn'], default_action])
30183019
if not data and not unformatted_data:
30193020
result = PASS
30203021
return Result(

tests/checks/apic_disk_space_faults_check/Fault_exists_not_raised.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
"domain": "infra",
4646
"highestSeverity": "major",
4747
"lastTransition": "2026-01-12T06:44:26.382+00:00",
48-
"lc": "soaking",
48+
"lc": "soaking-clearing",
4949
"occur": "1",
5050
"origSeverity": "major",
5151
"prevSeverity": "major",

tests/checks/apic_disk_space_faults_check/test_apic_disk_space_faults_check.py

Lines changed: 28 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -16,65 +16,71 @@
1616

1717

1818
@pytest.mark.parametrize(
19-
"icurl_outputs, cversion, expected_result",
19+
"icurl_outputs, cversion, expected_result, expected_data",
2020
[
2121
# PASS - No raised faults
2222
(
2323
{faultInst: []},
2424
"4.2(1h)",
2525
script.PASS,
26+
[],
2627
),
2728
# FAIL - Raised faults with /firmware,/techsupport,/data/log mount points
2829
(
29-
{
30-
faultInst: read_data(dir, "Fault_raised.json")
31-
},
30+
{faultInst: read_data(dir, "Fault_raised.json")},
3231
"4.2(1h)",
3332
script.FAIL_UF,
33+
[
34+
["F1528", "1", "1", "/data/log", "89%", "Remove unneeded logs in var/log/dme/log"],
35+
["F1528", "1", "1", "/firmware", "89%", "Remove unneeded images"],
36+
["F1528", "1", "1", "/techsupport", "89%", "Remove unneeded techsupports/cores"],
37+
],
3438
),
35-
36-
# PASS - Faults exist but not raised (cleared)
39+
# PASS - Faults exist but not raised nor soaking (cleared)
3740
(
38-
{
39-
faultInst: read_data(dir, "Fault_exists_not_raised.json")
40-
},
41+
{faultInst: read_data(dir, "Fault_exists_not_raised.json")},
4142
"4.2(1h)",
4243
script.PASS,
44+
[],
4345
),
44-
4546
# FAIL - Raised faults with multiple status - Cleared and Active
4647
(
47-
{
48-
faultInst: read_data(dir, "Fault_combination.json")
49-
},
48+
{faultInst: read_data(dir, "Fault_combination.json")},
5049
"4.2(1h)",
5150
script.FAIL_UF,
51+
[
52+
["F1529", "1", "1", "/data/log", "94%", "Remove unneeded logs in var/log/dme/log"],
53+
["F1528", "1", "1", "/firmware", "89%", "Remove unneeded images"],
54+
],
5255
),
53-
5456
# FAIL - Raised faults with unknown mount point (unformatted data)
5557
(
56-
{
57-
faultInst: read_data(dir, "Fault_unformatted_data.json")
58-
},
58+
{faultInst: read_data(dir, "Fault_unformatted_data.json")},
5959
"4.2(1h)",
6060
script.FAIL_UF,
61+
[
62+
["F1528", "1", "1", "/unknown", "88%", "Contact Cisco TAC."],
63+
],
6164
),
6265
# FAIL - Raised faults with CSCvn13119 affected version
6366
(
64-
{
65-
faultInst: read_data(dir, "Fault_raised.json")
66-
},
67+
{faultInst: read_data(dir, "Fault_unformatted_data.json")},
6768
"4.0(1h)",
6869
script.FAIL_UF,
70+
[
71+
["F1528", "1", "1", "/unknown", "88%", "Contact Cisco TAC. A typical issue is CSCvn13119."],
72+
],
6973
),
7074
# PASS - No raised faults with CSCvn13119 affected version
7175
(
7276
{faultInst: []},
7377
"4.0(1h)",
7478
script.PASS,
79+
[],
7580
),
7681
],
7782
)
78-
def test_logic(run_check, mock_icurl, cversion, expected_result):
83+
def test_logic(run_check, mock_icurl, cversion, expected_result, expected_data):
7984
result = run_check(cversion=script.AciVersion(cversion))
80-
assert result.result == expected_result
85+
assert result.result == expected_result
86+
assert result.data == expected_data

0 commit comments

Comments
 (0)