Skip to content

Commit

Permalink
Add override testcase to verify removal (sonic-net#2288)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
wen587 authored and preetham-singh committed Nov 18, 2022
1 parent d4c8cf0 commit 30f1e13
Show file tree
Hide file tree
Showing 2 changed files with 106 additions and 0 deletions.
96 changes: 96 additions & 0 deletions tests/config_override_input/empty_table_removal.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
{
"running_config": {
"ACL_TABLE": {
"DATAACL": {
"policy_desc": "DATAACL",
"ports": [
"Ethernet4"
],
"stage": "ingress",
"type": "L3"
},
"NTP_ACL": {
"policy_desc": "NTP_ACL",
"services": [
"NTP"
],
"stage": "ingress",
"type": "CTRLPLANE"
}
},
"AUTO_TECHSUPPORT_FEATURE": {
"bgp": {
"rate_limit_interval": "600",
"state": "enabled"
},
"database": {
"rate_limit_interval": "600",
"state": "enabled"
}
},
"PORT": {
"Ethernet4": {
"admin_status": "up",
"alias": "fortyGigE0/4",
"description": "Servers0:eth0",
"index": "1",
"lanes": "29,30,31,32",
"mtu": "9100",
"pfc_asym": "off",
"speed": "40000",
"tpid": "0x8100"
},
"Ethernet8": {
"admin_status": "up",
"alias": "fortyGigE0/8",
"description": "Servers1:eth0",
"index": "2",
"lanes": "33,34,35,36",
"mtu": "9100",
"pfc_asym": "off",
"speed": "40000",
"tpid": "0x8100"
}
}
},
"golden_config": {
"ACL_TABLE": {
}
},
"expected_config": {
"AUTO_TECHSUPPORT_FEATURE": {
"bgp": {
"rate_limit_interval": "600",
"state": "enabled"
},
"database": {
"rate_limit_interval": "600",
"state": "enabled"
}
},
"PORT": {
"Ethernet4": {
"admin_status": "up",
"alias": "fortyGigE0/4",
"description": "Servers0:eth0",
"index": "1",
"lanes": "29,30,31,32",
"mtu": "9100",
"pfc_asym": "off",
"speed": "40000",
"tpid": "0x8100"
},
"Ethernet8": {
"admin_status": "up",
"alias": "fortyGigE0/8",
"description": "Servers1:eth0",
"index": "2",
"lanes": "33,34,35,36",
"mtu": "9100",
"pfc_asym": "off",
"speed": "40000",
"tpid": "0x8100"
}
}
}
}
10 changes: 10 additions & 0 deletions tests/config_override_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
NEW_FEATURE_CONFIG = os.path.join(DATA_DIR, "new_feature_config.json")
FULL_CONFIG_OVERRIDE = os.path.join(DATA_DIR, "full_config_override.json")
PORT_CONFIG_OVERRIDE = os.path.join(DATA_DIR, "port_config_override.json")
EMPTY_TABLE_REMOVAL = os.path.join(DATA_DIR, "empty_table_removal.json")

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

def test_golden_config_db_empty_table_removal(self):
"""Golden Config empty table does table removal"""
db = Db()
with open(EMPTY_TABLE_REMOVAL, "r") as f:
read_data = json.load(f)
self.check_override_config_table(
db, config, read_data['running_config'], read_data['golden_config'],
read_data['expected_config'])

def check_override_config_table(self, db, config, running_config,
golden_config, expected_config):
def read_json_file_side_effect(filename):
Expand Down

0 comments on commit 30f1e13

Please sign in to comment.