Skip to content

Commit 3ddd729

Browse files
committed
logic + pytest cleanup
1 parent bc70cfe commit 3ddd729

7 files changed

Lines changed: 101 additions & 211 deletions

aci-preupgrade-validation-script.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5297,6 +5297,36 @@ def apic_database_size_check(cversion, **kwargs):
52975297
result = FAIL_UF
52985298
return Result(result=result, headers=headers, data=data, recommended_action=recommended_action, doc_url=doc_url)
52995299

5300+
5301+
@check_wrapper(check_title='configpushShardCont headTx')
5302+
def configpush_shard_check(tversion, **kwargs):
5303+
result = NA
5304+
headers = ["dn", "headTx", "tailTx"]
5305+
data = []
5306+
recommended_action = 'Contact Cisco TAC for Support before upgrade'
5307+
doc_url = 'https://datacenter.github.io/ACI-Pre-Upgrade-Validation-Script/validations/#policydist-configpushshardcont-defect'
5308+
5309+
if not tversion:
5310+
return Result(result=MANUAL, msg=TVER_MISSING)
5311+
5312+
if tversion.older_than("6.1(4a)"):
5313+
result = PASS
5314+
configpushShardCont_api = 'configpushShardCont.json'
5315+
configpushShardCont_api += '?query-target-filter=or(ne(configpushShardCont.tailTx,"0"),ne(configpushShardCont.headTx,"0"))'
5316+
configpush_sh_cont = icurl('class', configpushShardCont_api)
5317+
if configpush_sh_cont:
5318+
for sh_cont in configpush_sh_cont:
5319+
headtx = sh_cont['configpushShardCont']['attributes']['headTx']
5320+
tailtx = sh_cont['configpushShardCont']['attributes']['tailTx']
5321+
if ((headtx != '0' and tailtx == '0') or (tailtx != '0' and headtx == '0')):
5322+
sh_cont_dn = sh_cont['configpushShardCont']['attributes']['dn']
5323+
data.append([sh_cont_dn, headtx, tailtx])
5324+
5325+
if data:
5326+
result = FAIL_O
5327+
5328+
return Result(result=result, headers=headers, data=data, recommended_action=recommended_action, doc_url=doc_url)
5329+
53005330
# ---- Script Execution ----
53015331

53025332
def parse_args(args):
@@ -5452,6 +5482,7 @@ def get_checks(api_only, debug_function):
54525482
standby_sup_sync_check,
54535483
stale_pcons_ra_mo_check,
54545484
isis_database_byte_check,
5485+
configpush_shard_check,
54555486

54565487
]
54575488
conn_checks = [

tests/configpuh_shard_cont_check/na-configpushShardCont.json

Lines changed: 0 additions & 1 deletion
This file was deleted.

tests/configpuh_shard_cont_check/neg-configpushShardCont.json

Lines changed: 0 additions & 58 deletions
This file was deleted.

tests/configpuh_shard_cont_check/posTail-configpushShardCont.json

Lines changed: 0 additions & 58 deletions
This file was deleted.

tests/configpuh_shard_cont_check/test_configpush_shard_cont_check.py

Lines changed: 0 additions & 80 deletions
This file was deleted.

tests/configpuh_shard_cont_check/posHead-configpushShardCont.json renamed to tests/configpush_shard_check/configpushShardCont_pos.json

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33
"configpushShardCont": {
44
"attributes": {
55
"childAction": "",
6-
"dn": "configpush/sh-20",
7-
"headTx": "0",
6+
"dn": "configpush/sh-22",
7+
"headTx": "576460752318322171",
88
"lcOwn": "local",
9-
"modTs": "2025-07-01T16:54:36.155+00:00",
10-
"shard": "20",
9+
"modTs": "2025-06-28T21:32:58.754+00:00",
10+
"shard": "2",
1111
"status": "",
1212
"tailTx": "0"
1313
}
@@ -17,11 +17,11 @@
1717
"configpushShardCont": {
1818
"attributes": {
1919
"childAction": "",
20-
"dn": "configpush/sh-2",
21-
"headTx": "576460752318322171",
20+
"dn": "configpush/sh-31",
21+
"headTx": "516460756318314171",
2222
"lcOwn": "local",
23-
"modTs": "2025-06-28T21:32:58.754+00:00",
24-
"shard": "2",
23+
"modTs": "2025-06-23T18:12:06.867+00:00",
24+
"shard": "3",
2525
"status": "",
2626
"tailTx": "0"
2727
}
@@ -31,13 +31,13 @@
3131
"configpushShardCont": {
3232
"attributes": {
3333
"childAction": "",
34-
"dn": "configpush/sh-17",
34+
"dn": "configpush/sh-2",
3535
"headTx": "0",
3636
"lcOwn": "local",
37-
"modTs": "2025-06-28T00:12:53.523+00:00",
38-
"shard": "17",
37+
"modTs": "2025-06-28T21:32:58.754+00:00",
38+
"shard": "2",
3939
"status": "",
40-
"tailTx": "0"
40+
"tailTx": "576460752318322171"
4141
}
4242
}
4343
},
@@ -46,12 +46,12 @@
4646
"attributes": {
4747
"childAction": "",
4848
"dn": "configpush/sh-3",
49-
"headTx": "516460756318314171",
49+
"headTx": "0",
5050
"lcOwn": "local",
5151
"modTs": "2025-06-23T18:12:06.867+00:00",
5252
"shard": "3",
5353
"status": "",
54-
"tailTx": "0"
54+
"tailTx": "516460756318314171"
5555
}
5656
}
5757
}
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
import os
2+
import pytest
3+
import logging
4+
import importlib
5+
from helpers.utils import read_data
6+
7+
script = importlib.import_module("aci-preupgrade-validation-script")
8+
9+
log = logging.getLogger(__name__)
10+
dir = os.path.dirname(os.path.abspath(__file__))
11+
12+
# icurl queries
13+
configpushShardCont_api = 'configpushShardCont.json'
14+
configpushShardCont_api += '?query-target-filter=or(ne(configpushShardCont.tailTx,"0"),ne(configpushShardCont.headTx,"0"))'
15+
16+
@pytest.mark.parametrize(
17+
"icurl_outputs, tversion, expected_result",
18+
[
19+
# tversion not given
20+
(
21+
{configpushShardCont_api: []},
22+
None,
23+
script.MANUAL,
24+
),
25+
# Non-fixed Versions
26+
(
27+
# affected tversion, configpushShardCont_api has non-zero headTx / tailTx
28+
{configpushShardCont_api: read_data(dir, "configpushShardCont_pos.json")},
29+
"6.0(3a)",
30+
script.FAIL_O,
31+
),
32+
(
33+
# affected tversion, all configpushShardCont_api tx are 0
34+
{configpushShardCont_api: []},
35+
"5.2(6a)",
36+
script.PASS,
37+
),
38+
# Fixed Versions
39+
(
40+
# non-affected tversion, configpushShardCont_api has non-zero headTx / tailTx
41+
{configpushShardCont_api: read_data(dir, "configpushShardCont_pos.json")},
42+
"6.1(6b)",
43+
script.NA,
44+
),
45+
(
46+
# non-affected tversion, all configpushShardCont_api tx are 0
47+
{configpushShardCont_api: []},
48+
"6.1(4b)",
49+
script.NA,
50+
),
51+
],
52+
)
53+
def test_logic(mock_icurl, tversion, expected_result):
54+
tversion = script.AciVersion(tversion) if tversion else None
55+
result = script.configpush_shard_check(1, 1, tversion)
56+
assert result == expected_result

0 commit comments

Comments
 (0)