Skip to content

Commit ac89489

Browse files
authored
Modify override testcase to cover PORT admin_status (sonic-net#2165)
What I did Modify the override-config-table testcase to cover PORT admin_status scenario. How I did it add the testcase to cover PORT admin_status change. How to verify it Run unit test.
1 parent d7953d2 commit ac89489

File tree

2 files changed

+144
-0
lines changed

2 files changed

+144
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
{
2+
"running_config": {
3+
"ACL_TABLE": {
4+
"DATAACL": {
5+
"policy_desc": "DATAACL",
6+
"ports": [
7+
"Ethernet4"
8+
],
9+
"stage": "ingress",
10+
"type": "L3"
11+
},
12+
"NTP_ACL": {
13+
"policy_desc": "NTP_ACL",
14+
"services": [
15+
"NTP"
16+
],
17+
"stage": "ingress",
18+
"type": "CTRLPLANE"
19+
}
20+
},
21+
"AUTO_TECHSUPPORT_FEATURE": {
22+
"bgp": {
23+
"rate_limit_interval": "600",
24+
"state": "enabled"
25+
},
26+
"database": {
27+
"rate_limit_interval": "600",
28+
"state": "enabled"
29+
}
30+
},
31+
"PORT": {
32+
"Ethernet4": {
33+
"alias": "fortyGigE0/4",
34+
"description": "Servers0:eth0",
35+
"index": "1",
36+
"lanes": "29,30,31,32",
37+
"mtu": "9100",
38+
"pfc_asym": "off",
39+
"speed": "40000",
40+
"tpid": "0x8100"
41+
},
42+
"Ethernet8": {
43+
"alias": "fortyGigE0/8",
44+
"description": "Servers1:eth0",
45+
"index": "2",
46+
"lanes": "33,34,35,36",
47+
"mtu": "9100",
48+
"pfc_asym": "off",
49+
"speed": "40000",
50+
"tpid": "0x8100"
51+
}
52+
}
53+
},
54+
"golden_config": {
55+
"PORT": {
56+
"Ethernet4": {
57+
"admin_status": "up",
58+
"alias": "fortyGigE0/4",
59+
"description": "Servers0:eth0",
60+
"index": "1",
61+
"lanes": "29,30,31,32",
62+
"mtu": "9100",
63+
"pfc_asym": "off",
64+
"speed": "40000",
65+
"tpid": "0x8100"
66+
},
67+
"Ethernet8": {
68+
"admin_status": "down",
69+
"alias": "fortyGigE0/8",
70+
"description": "Servers1:eth0",
71+
"index": "2",
72+
"lanes": "33,34,35,36",
73+
"mtu": "9100",
74+
"pfc_asym": "off",
75+
"speed": "40000",
76+
"tpid": "0x8100"
77+
}
78+
}
79+
},
80+
"expected_config": {
81+
"ACL_TABLE": {
82+
"DATAACL": {
83+
"policy_desc": "DATAACL",
84+
"ports": [
85+
"Ethernet4"
86+
],
87+
"stage": "ingress",
88+
"type": "L3"
89+
},
90+
"NTP_ACL": {
91+
"policy_desc": "NTP_ACL",
92+
"services": [
93+
"NTP"
94+
],
95+
"stage": "ingress",
96+
"type": "CTRLPLANE"
97+
}
98+
},
99+
"AUTO_TECHSUPPORT_FEATURE": {
100+
"bgp": {
101+
"rate_limit_interval": "600",
102+
"state": "enabled"
103+
},
104+
"database": {
105+
"rate_limit_interval": "600",
106+
"state": "enabled"
107+
}
108+
},
109+
"PORT": {
110+
"Ethernet4": {
111+
"admin_status": "up",
112+
"alias": "fortyGigE0/4",
113+
"description": "Servers0:eth0",
114+
"index": "1",
115+
"lanes": "29,30,31,32",
116+
"mtu": "9100",
117+
"pfc_asym": "off",
118+
"speed": "40000",
119+
"tpid": "0x8100"
120+
},
121+
"Ethernet8": {
122+
"admin_status": "down",
123+
"alias": "fortyGigE0/8",
124+
"description": "Servers1:eth0",
125+
"index": "2",
126+
"lanes": "33,34,35,36",
127+
"mtu": "9100",
128+
"pfc_asym": "off",
129+
"speed": "40000",
130+
"tpid": "0x8100"
131+
}
132+
}
133+
}
134+
}

tests/config_override_test.py

+10
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
PARTIAL_CONFIG_OVERRIDE = os.path.join(DATA_DIR, "partial_config_override.json")
1616
NEW_FEATURE_CONFIG = os.path.join(DATA_DIR, "new_feature_config.json")
1717
FULL_CONFIG_OVERRIDE = os.path.join(DATA_DIR, "full_config_override.json")
18+
PORT_CONFIG_OVERRIDE = os.path.join(DATA_DIR, "port_config_override.json")
1819

1920
# Load sonic-cfggen from source since /usr/local/bin/sonic-cfggen does not have .py extension.
2021
sonic_cfggen = load_module_from_source('sonic_cfggen', '/usr/local/bin/sonic-cfggen')
@@ -127,6 +128,15 @@ def test_golden_config_db_full(self):
127128
db, config, read_data['running_config'], read_data['golden_config'],
128129
read_data['expected_config'])
129130

131+
def test_golden_config_db_port_config(self):
132+
"""Golden Config makes change to PORT admin_status"""
133+
db = Db()
134+
with open(PORT_CONFIG_OVERRIDE, "r") as f:
135+
read_data = json.load(f)
136+
self.check_override_config_table(
137+
db, config, read_data['running_config'], read_data['golden_config'],
138+
read_data['expected_config'])
139+
130140
def check_override_config_table(self, db, config, running_config,
131141
golden_config, expected_config):
132142
def read_json_file_side_effect(filename):

0 commit comments

Comments
 (0)