Skip to content

Commit e9ab523

Browse files
authored
Add override testcase to verify removal (#2288)
What I did Add one override-config-table testcase to verify empty table removal. How I did it Add the testcase to verify the removal. How to verify it Unit test.
1 parent c6794b5 commit e9ab523

File tree

2 files changed

+106
-0
lines changed

2 files changed

+106
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
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+
"admin_status": "up",
34+
"alias": "fortyGigE0/4",
35+
"description": "Servers0:eth0",
36+
"index": "1",
37+
"lanes": "29,30,31,32",
38+
"mtu": "9100",
39+
"pfc_asym": "off",
40+
"speed": "40000",
41+
"tpid": "0x8100"
42+
},
43+
"Ethernet8": {
44+
"admin_status": "up",
45+
"alias": "fortyGigE0/8",
46+
"description": "Servers1:eth0",
47+
"index": "2",
48+
"lanes": "33,34,35,36",
49+
"mtu": "9100",
50+
"pfc_asym": "off",
51+
"speed": "40000",
52+
"tpid": "0x8100"
53+
}
54+
}
55+
},
56+
"golden_config": {
57+
"ACL_TABLE": {
58+
}
59+
},
60+
"expected_config": {
61+
"AUTO_TECHSUPPORT_FEATURE": {
62+
"bgp": {
63+
"rate_limit_interval": "600",
64+
"state": "enabled"
65+
},
66+
"database": {
67+
"rate_limit_interval": "600",
68+
"state": "enabled"
69+
}
70+
},
71+
"PORT": {
72+
"Ethernet4": {
73+
"admin_status": "up",
74+
"alias": "fortyGigE0/4",
75+
"description": "Servers0:eth0",
76+
"index": "1",
77+
"lanes": "29,30,31,32",
78+
"mtu": "9100",
79+
"pfc_asym": "off",
80+
"speed": "40000",
81+
"tpid": "0x8100"
82+
},
83+
"Ethernet8": {
84+
"admin_status": "up",
85+
"alias": "fortyGigE0/8",
86+
"description": "Servers1:eth0",
87+
"index": "2",
88+
"lanes": "33,34,35,36",
89+
"mtu": "9100",
90+
"pfc_asym": "off",
91+
"speed": "40000",
92+
"tpid": "0x8100"
93+
}
94+
}
95+
}
96+
}

tests/config_override_test.py

+10
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
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")
1818
PORT_CONFIG_OVERRIDE = os.path.join(DATA_DIR, "port_config_override.json")
19+
EMPTY_TABLE_REMOVAL = os.path.join(DATA_DIR, "empty_table_removal.json")
1920

2021
# Load sonic-cfggen from source since /usr/local/bin/sonic-cfggen does not have .py extension.
2122
sonic_cfggen = load_module_from_source('sonic_cfggen', '/usr/local/bin/sonic-cfggen')
@@ -137,6 +138,15 @@ def test_golden_config_db_port_config(self):
137138
db, config, read_data['running_config'], read_data['golden_config'],
138139
read_data['expected_config'])
139140

141+
def test_golden_config_db_empty_table_removal(self):
142+
"""Golden Config empty table does table removal"""
143+
db = Db()
144+
with open(EMPTY_TABLE_REMOVAL, "r") as f:
145+
read_data = json.load(f)
146+
self.check_override_config_table(
147+
db, config, read_data['running_config'], read_data['golden_config'],
148+
read_data['expected_config'])
149+
140150
def check_override_config_table(self, db, config, running_config,
141151
golden_config, expected_config):
142152
def read_json_file_side_effect(filename):

0 commit comments

Comments
 (0)