[sonic-cfggen]: Update UT to add port lanes (#10362)

Why I did it
Need to run yang validation for sonic-cfggen unit test, and many unit test does not provide lanes for port table.

How I did it
Update port config file.

How to verify it
Run sonic-cfggen unit test,
Use below PR to verify
#10228

Signed-off-by: Gang Lv ganglv@microsoft.com
This commit is contained in:
ganglv 2022-04-04 12:55:33 +08:00 committed by Judy Joseph
parent d224315292
commit c3e1e2dce3
6 changed files with 156 additions and 97 deletions

View File

@ -0,0 +1,34 @@
# name lanes alias index asic_port_name role
Ethernet0 33,34,35,36 Ethernet1/1 0 Eth0-ASIC0 Ext
Ethernet4 29,30,31,32 Ethernet1/2 1 Eth1-ASIC0 Ext
Ethernet8 41,42,43,44 Ethernet1/3 2 Eth2-ASIC0 Ext
Ethernet12 37,38,39,40 Ethernet1/4 3 Eth3-ASIC0 Ext
Ethernet-BP0 13,14,15,16 Eth4-ASIC0 4 Eth4-ASIC0 Int
Ethernet-BP4 17,18,19,20 Eth5-ASIC0 5 Eth5-ASIC0 Int
Ethernet-BP8 21,22,23,24 Eth6-ASIC0 6 Eth6-ASIC0 Int
Ethernet-BP12 25,26,27,28 Eth7-ASIC0 7 Eth7-ASIC0 Int
Ethernet16 33,34,35,36 Ethernet1/5 8 Eth0-ASIC1 Ext
Ethernet20 29,30,31,32 Ethernet1/6 9 Eth1-ASIC1 Ext
Ethernet24 41,42,43,44 Ethernet1/7 10 Eth2-ASIC1 Ext
Ethernet28 37,38,39,40 Ethernet1/8 11 Eth3-ASIC1 Ext
Ethernet-BP16 13,14,15,16 Eth4-ASIC1 12 Eth4-ASIC1 Int
Ethernet-BP20 17,18,19,20 Eth5-ASIC1 13 Eth5-ASIC1 Int
Ethernet-BP24 21,22,23,24 Eth6-ASIC1 14 Eth6-ASIC1 Int
Ethernet-BP28 25,26,27,28 Eth7-ASIC1 15 Eth7-ASIC1 Int
Ethernet-BP256 61,62,63,64 Eth0-ASIC2 16 Eth0-ASIC2 Int
Ethernet-BP260 57,58,59,60 Eth1-ASIC2 17 Eth1-ASIC2 Int
Ethernet-BP264 53,54,55,56 Eth2-ASIC2 18 Eth2-ASIC2 Int
Ethernet-BP268 49,50,51,52 Eth3-ASIC2 19 Eth3-ASIC2 Int
Ethernet-BP272 45,46,47,48 Eth4-ASIC2 20 Eth4-ASIC2 Int
Ethernet-BP276 41,42,43,44 Eth5-ASIC2 21 Eth5-ASIC2 Int
Ethernet-BP280 37,38,39,40 Eth6-ASIC2 22 Eth6-ASIC2 Int
Ethernet-BP284 33,34,35,36 Eth7-ASIC2 23 Eth7-ASIC2 Int
Ethernet-BP384 29,30,31,32 Eth0-ASIC3 24 Eth0-ASIC3 Int
Ethernet-BP388 25,26,27,28 Eth1-ASIC3 25 Eth1-ASIC3 Int
Ethernet-BP392 21,22,23,24 Eth2-ASIC3 26 Eth2-ASIC3 Int
Ethernet-BP396 17,18,19,20 Eth3-ASIC3 27 Eth3-ASIC3 Int
Ethernet-BP400 13,14,15,16 Eth4-ASIC3 28 Eth4-ASIC3 Int
Ethernet-BP404 9,10,11,12 Eth5-ASIC3 29 Eth5-ASIC3 Int
Ethernet-BP408 5,6,7,8 Eth6-ASIC3 30 Eth6-ASIC3 Int
Ethernet-BP412 1,2,3,4 Eth7-ASIC3 31 Eth7-ASIC3 Int

View File

@ -83,44 +83,46 @@ class TestCfgGen(TestCase):
self.assertEqual(output.strip(), "('eth0', '10.0.1.5/28')")
def test_minigraph_hostname(self):
argument = '-v "DEVICE_METADATA[\'localhost\'][\'hostname\']" -m "' + self.sample_graph + '"'
argument = '-v "DEVICE_METADATA[\'localhost\'][\'hostname\']" -m "' + self.sample_graph + '" -p "' + self.port_config + '"'
output = self.run_script(argument)
self.assertEqual(output.strip(), 'OCPSCH01040DDLF')
def test_minigraph_sku(self):
argument = '-v "DEVICE_METADATA[\'localhost\'][\'hwsku\']" -m "' + self.sample_graph + '"'
argument = '-v "DEVICE_METADATA[\'localhost\'][\'hwsku\']" -m "' + self.sample_graph + '" -p "' + self.port_config + '"'
output = self.run_script(argument)
self.assertEqual(output.strip(), 'Force10-Z9100')
def test_minigraph_region(self):
argument = '-v "DEVICE_METADATA[\'localhost\'][\'region\']" -m "' + self.sample_graph_metadata + '"'
argument = '-v "DEVICE_METADATA[\'localhost\'][\'region\']" -m "' + self.sample_graph_metadata + '" -p "' + self.port_config + '"'
output = self.run_script(argument)
self.assertEqual(output.strip(), 'usfoo')
def test_minigraph_cloudtype(self):
argument = '-v "DEVICE_METADATA[\'localhost\'][\'cloudtype\']" -m "' + self.sample_graph_metadata + '"'
argument = '-v "DEVICE_METADATA[\'localhost\'][\'cloudtype\']" -m "' + self.sample_graph_metadata + '" -p "' + self.port_config + '"'
output = self.run_script(argument)
self.assertEqual(output.strip(), 'Public')
def test_minigraph_resourcetype(self):
argument = '-v "DEVICE_METADATA[\'localhost\'][\'resource_type\']" -m "' + self.sample_graph_metadata + '"'
argument = '-v "DEVICE_METADATA[\'localhost\'][\'resource_type\']" -m "' + self.sample_graph_metadata + '" -p "' + self.port_config + '"'
output = self.run_script(argument)
self.assertEqual(output.strip(), 'resource_type_x')
def test_minigraph_downstream_subrole(self):
argument = '-v "DEVICE_METADATA[\'localhost\'][\'downstream_subrole\']" -m "' + self.sample_graph_metadata + '"'
argument = '-v "DEVICE_METADATA[\'localhost\'][\'downstream_subrole\']" -m "' + self.sample_graph_metadata + '" -p "' + self.port_config + '"'
output = self.run_script(argument)
self.assertEqual(output.strip(), 'downstream_subrole_y')
def test_print_data(self):
argument = '-m "' + self.sample_graph + '" --print-data'
argument = '-m "' + self.sample_graph + '" -p "' + self.port_config + '" --print-data'
output = self.run_script(argument)
self.assertTrue(len(output.strip()) > 0)
def test_jinja_expression(self, graph=None, expected_router_type='LeafRouter'):
def test_jinja_expression(self, graph=None, port_config=None, expected_router_type='LeafRouter'):
if graph is None:
graph = self.sample_graph
argument = '-m "' + graph + '" -v "DEVICE_METADATA[\'localhost\'][\'type\']"'
if port_config is None:
port_config = self.port_config
argument = '-m "' + graph + '" -p "' + port_config + '" -v "DEVICE_METADATA[\'localhost\'][\'type\']"'
output = self.run_script(argument)
self.assertEqual(output.strip(), expected_router_type)
@ -563,44 +565,44 @@ class TestCfgGen(TestCase):
def test_minigraph_neighbor_interfaces_config_db(self):
# test to check if PORT table is retrieved from config_db
argument = '-m "' + self.sample_graph_simple_case + '" -v "PORT"'
argument = '-m "' + self.sample_graph_simple_case + '" -p "' + self.port_config + '" -v "PORT"'
output = self.run_script(argument)
self.assertEqual(
utils.to_dict(output.strip()),
utils.to_dict(
"{'Ethernet0': {'lanes': '29,30,31,32', 'description': 'config_db:switch-01t1:port1', 'pfc_asym': 'off', 'mtu': '9100', 'tpid': '0x8100', 'alias': 'fortyGigE0/0', 'admin_status': 'up', 'speed': '10000', 'autoneg': 'on'}, "
"'Ethernet4': {'lanes': '25,26,27,28', 'description': 'config_db:server1:port1', 'pfc_asym': 'off', 'mtu': '9100', 'tpid': '0x8100', 'alias': 'fortyGigE0/4', 'admin_status': 'up', 'speed': '25000', 'autoneg': 'on', 'mux_cable': 'true'}, "
"{'Ethernet0': {'lanes': '29,30,31,32', 'description': 'switch-01t1:port1', 'pfc_asym': 'off', 'mtu': '9100', 'tpid': '0x8100', 'alias': 'fortyGigE0/0', 'admin_status': 'up', 'speed': '10000', 'autoneg': 'on'}, "
"'Ethernet4': {'lanes': '25,26,27,28', 'description': 'server1:port1', 'pfc_asym': 'off', 'mtu': '9100', 'tpid': '0x8100', 'alias': 'fortyGigE0/4', 'admin_status': 'up', 'speed': '25000', 'autoneg': 'on', 'mux_cable': 'true'}, "
"'Ethernet8': {'lanes': '37,38,39,40', 'description': 'Interface description', 'pfc_asym': 'off', 'mtu': '9100', 'tpid': '0x8100', 'alias': 'fortyGigE0/8', 'admin_status': 'up', 'speed': '40000', 'autoneg': 'on', 'mux_cable': 'true'}, "
"'Ethernet12': {'lanes': '33,34,35,36', 'description': 'Interface description', 'pfc_asym': 'off', 'mtu': '9100', 'tpid': '0x8100', 'alias': 'fortyGigE0/12', 'admin_status': 'up', 'speed': '10000', 'autoneg': 'on'}, "
"'Ethernet16': {'alias': 'fortyGigE0/16', 'pfc_asym': 'off', 'lanes': '41,42,43,44', 'description': 'config_db:fortyGigE0/16', 'mtu': '9100', 'tpid': '0x8100'}, "
"'Ethernet20': {'alias': 'fortyGigE0/20', 'pfc_asym': 'off', 'lanes': '45,46,47,48', 'description': 'config_db:fortyGigE0/20', 'mtu': '9100', 'tpid': '0x8100'}, "
"'Ethernet24': {'alias': 'fortyGigE0/24', 'pfc_asym': 'off', 'lanes': '5,6,7,8', 'description': 'config_db:fortyGigE0/24', 'mtu': '9100', 'tpid': '0x8100'}, "
"'Ethernet28': {'alias': 'fortyGigE0/28', 'pfc_asym': 'off', 'lanes': '1,2,3,4', 'description': 'config_db:fortyGigE0/28', 'mtu': '9100', 'tpid': '0x8100'}, "
"'Ethernet32': {'alias': 'fortyGigE0/32', 'pfc_asym': 'off', 'lanes': '9,10,11,12', 'description': 'config_db:fortyGigE0/32', 'mtu': '9100', 'tpid': '0x8100'}, "
"'Ethernet36': {'alias': 'fortyGigE0/36', 'pfc_asym': 'off', 'lanes': '13,14,15,16', 'description': 'config_db:fortyGigE0/36', 'mtu': '9100', 'tpid': '0x8100'}, "
"'Ethernet40': {'alias': 'fortyGigE0/40', 'pfc_asym': 'off', 'lanes': '21,22,23,24', 'description': 'config_db:fortyGigE0/40', 'mtu': '9100', 'tpid': '0x8100'}, "
"'Ethernet44': {'alias': 'fortyGigE0/44', 'pfc_asym': 'off', 'lanes': '17,18,19,20', 'description': 'config_db:fortyGigE0/44', 'mtu': '9100', 'tpid': '0x8100'}, "
"'Ethernet48': {'alias': 'fortyGigE0/48', 'pfc_asym': 'off', 'lanes': '49,50,51,52', 'description': 'config_db:fortyGigE0/48', 'mtu': '9100', 'tpid': '0x8100'}, "
"'Ethernet52': {'alias': 'fortyGigE0/52', 'pfc_asym': 'off', 'lanes': '53,54,55,56', 'description': 'config_db:fortyGigE0/52', 'mtu': '9100', 'tpid': '0x8100'}, "
"'Ethernet56': {'alias': 'fortyGigE0/56', 'pfc_asym': 'off', 'lanes': '61,62,63,64', 'description': 'config_db:fortyGigE0/56', 'mtu': '9100', 'tpid': '0x8100'}, "
"'Ethernet60': {'alias': 'fortyGigE0/60', 'pfc_asym': 'off', 'lanes': '57,58,59,60', 'description': 'config_db:fortyGigE0/60', 'mtu': '9100', 'tpid': '0x8100'}, "
"'Ethernet64': {'alias': 'fortyGigE0/64', 'pfc_asym': 'off', 'lanes': '65,66,67,68', 'description': 'config_db:fortyGigE0/64', 'mtu': '9100', 'tpid': '0x8100'}, "
"'Ethernet68': {'alias': 'fortyGigE0/68', 'pfc_asym': 'off', 'lanes': '69,70,71,72', 'description': 'config_db:fortyGigE0/68', 'mtu': '9100', 'tpid': '0x8100'}, "
"'Ethernet72': {'alias': 'fortyGigE0/72', 'pfc_asym': 'off', 'lanes': '77,78,79,80', 'description': 'config_db:fortyGigE0/72', 'mtu': '9100', 'tpid': '0x8100'}, "
"'Ethernet76': {'alias': 'fortyGigE0/76', 'pfc_asym': 'off', 'lanes': '73,74,75,76', 'description': 'config_db:fortyGigE0/76', 'mtu': '9100', 'tpid': '0x8100'}, "
"'Ethernet80': {'alias': 'fortyGigE0/80', 'pfc_asym': 'off', 'lanes': '105,106,107,108', 'description': 'config_db:fortyGigE0/80', 'mtu': '9100', 'tpid': '0x8100'}, "
"'Ethernet84': {'alias': 'fortyGigE0/84', 'pfc_asym': 'off', 'lanes': '109,110,111,112', 'description': 'config_db:fortyGigE0/84', 'mtu': '9100', 'tpid': '0x8100'}, "
"'Ethernet88': {'alias': 'fortyGigE0/88', 'pfc_asym': 'off', 'lanes': '117,118,119,120', 'description': 'config_db:fortyGigE0/88', 'mtu': '9100', 'tpid': '0x8100'}, "
"'Ethernet92': {'alias': 'fortyGigE0/92', 'pfc_asym': 'off', 'lanes': '113,114,115,116', 'description': 'config_db:fortyGigE0/92', 'mtu': '9100', 'tpid': '0x8100'}, "
"'Ethernet96': {'alias': 'fortyGigE0/96', 'pfc_asym': 'off', 'lanes': '121,122,123,124', 'description': 'config_db:fortyGigE0/96', 'mtu': '9100', 'tpid': '0x8100'}, "
"'Ethernet100': {'alias': 'fortyGigE0/100', 'pfc_asym': 'off', 'lanes': '125,126,127,128', 'description': 'config_db:fortyGigE0/100', 'mtu': '9100', 'tpid': '0x8100'}, "
"'Ethernet104': {'alias': 'fortyGigE0/104', 'pfc_asym': 'off', 'lanes': '85,86,87,88', 'description': 'config_db:fortyGigE0/104', 'mtu': '9100', 'tpid': '0x8100'}, "
"'Ethernet108': {'alias': 'fortyGigE0/108', 'pfc_asym': 'off', 'lanes': '81,82,83,84', 'description': 'config_db:fortyGigE0/108', 'mtu': '9100', 'tpid': '0x8100'}, "
"'Ethernet112': {'alias': 'fortyGigE0/112', 'pfc_asym': 'off', 'lanes': '89,90,91,92', 'description': 'config_db:fortyGigE0/112', 'mtu': '9100', 'tpid': '0x8100'}, "
"'Ethernet116': {'alias': 'fortyGigE0/116', 'pfc_asym': 'off', 'lanes': '93,94,95,96', 'description': 'config_db:fortyGigE0/116', 'mtu': '9100', 'tpid': '0x8100'}, "
"'Ethernet120': {'alias': 'fortyGigE0/120', 'pfc_asym': 'off', 'lanes': '97,98,99,100', 'description': 'config_db:fortyGigE0/120', 'mtu': '9100', 'tpid': '0x8100'}, "
"'Ethernet124': {'alias': 'fortyGigE0/124', 'pfc_asym': 'off', 'lanes': '101,102,103,104', 'description': 'config_db:fortyGigE0/124', 'mtu': '9100', 'tpid': '0x8100'}}"
"'Ethernet16': {'alias': 'fortyGigE0/16', 'pfc_asym': 'off', 'lanes': '41,42,43,44', 'description': 'fortyGigE0/16', 'mtu': '9100', 'tpid': '0x8100'}, "
"'Ethernet20': {'alias': 'fortyGigE0/20', 'pfc_asym': 'off', 'lanes': '45,46,47,48', 'description': 'fortyGigE0/20', 'mtu': '9100', 'tpid': '0x8100'}, "
"'Ethernet24': {'alias': 'fortyGigE0/24', 'pfc_asym': 'off', 'lanes': '5,6,7,8', 'description': 'fortyGigE0/24', 'mtu': '9100', 'tpid': '0x8100'}, "
"'Ethernet28': {'alias': 'fortyGigE0/28', 'pfc_asym': 'off', 'lanes': '1,2,3,4', 'description': 'fortyGigE0/28', 'mtu': '9100', 'tpid': '0x8100'}, "
"'Ethernet32': {'alias': 'fortyGigE0/32', 'pfc_asym': 'off', 'lanes': '9,10,11,12', 'description': 'fortyGigE0/32', 'mtu': '9100', 'tpid': '0x8100'}, "
"'Ethernet36': {'alias': 'fortyGigE0/36', 'pfc_asym': 'off', 'lanes': '13,14,15,16', 'description': 'fortyGigE0/36', 'mtu': '9100', 'tpid': '0x8100'}, "
"'Ethernet40': {'alias': 'fortyGigE0/40', 'pfc_asym': 'off', 'lanes': '21,22,23,24', 'description': 'fortyGigE0/40', 'mtu': '9100', 'tpid': '0x8100'}, "
"'Ethernet44': {'alias': 'fortyGigE0/44', 'pfc_asym': 'off', 'lanes': '17,18,19,20', 'description': 'fortyGigE0/44', 'mtu': '9100', 'tpid': '0x8100'}, "
"'Ethernet48': {'alias': 'fortyGigE0/48', 'pfc_asym': 'off', 'lanes': '49,50,51,52', 'description': 'fortyGigE0/48', 'mtu': '9100', 'tpid': '0x8100'}, "
"'Ethernet52': {'alias': 'fortyGigE0/52', 'pfc_asym': 'off', 'lanes': '53,54,55,56', 'description': 'fortyGigE0/52', 'mtu': '9100', 'tpid': '0x8100'}, "
"'Ethernet56': {'alias': 'fortyGigE0/56', 'pfc_asym': 'off', 'lanes': '61,62,63,64', 'description': 'fortyGigE0/56', 'mtu': '9100', 'tpid': '0x8100'}, "
"'Ethernet60': {'alias': 'fortyGigE0/60', 'pfc_asym': 'off', 'lanes': '57,58,59,60', 'description': 'fortyGigE0/60', 'mtu': '9100', 'tpid': '0x8100'}, "
"'Ethernet64': {'alias': 'fortyGigE0/64', 'pfc_asym': 'off', 'lanes': '65,66,67,68', 'description': 'fortyGigE0/64', 'mtu': '9100', 'tpid': '0x8100'}, "
"'Ethernet68': {'alias': 'fortyGigE0/68', 'pfc_asym': 'off', 'lanes': '69,70,71,72', 'description': 'fortyGigE0/68', 'mtu': '9100', 'tpid': '0x8100'}, "
"'Ethernet72': {'alias': 'fortyGigE0/72', 'pfc_asym': 'off', 'lanes': '77,78,79,80', 'description': 'fortyGigE0/72', 'mtu': '9100', 'tpid': '0x8100'}, "
"'Ethernet76': {'alias': 'fortyGigE0/76', 'pfc_asym': 'off', 'lanes': '73,74,75,76', 'description': 'fortyGigE0/76', 'mtu': '9100', 'tpid': '0x8100'}, "
"'Ethernet80': {'alias': 'fortyGigE0/80', 'pfc_asym': 'off', 'lanes': '105,106,107,108', 'description': 'fortyGigE0/80', 'mtu': '9100', 'tpid': '0x8100'}, "
"'Ethernet84': {'alias': 'fortyGigE0/84', 'pfc_asym': 'off', 'lanes': '109,110,111,112', 'description': 'fortyGigE0/84', 'mtu': '9100', 'tpid': '0x8100'}, "
"'Ethernet88': {'alias': 'fortyGigE0/88', 'pfc_asym': 'off', 'lanes': '117,118,119,120', 'description': 'fortyGigE0/88', 'mtu': '9100', 'tpid': '0x8100'}, "
"'Ethernet92': {'alias': 'fortyGigE0/92', 'pfc_asym': 'off', 'lanes': '113,114,115,116', 'description': 'fortyGigE0/92', 'mtu': '9100', 'tpid': '0x8100'}, "
"'Ethernet96': {'alias': 'fortyGigE0/96', 'pfc_asym': 'off', 'lanes': '121,122,123,124', 'description': 'fortyGigE0/96', 'mtu': '9100', 'tpid': '0x8100'}, "
"'Ethernet100': {'alias': 'fortyGigE0/100', 'pfc_asym': 'off', 'lanes': '125,126,127,128', 'description': 'fortyGigE0/100', 'mtu': '9100', 'tpid': '0x8100'}, "
"'Ethernet104': {'alias': 'fortyGigE0/104', 'pfc_asym': 'off', 'lanes': '85,86,87,88', 'description': 'fortyGigE0/104', 'mtu': '9100', 'tpid': '0x8100'}, "
"'Ethernet108': {'alias': 'fortyGigE0/108', 'pfc_asym': 'off', 'lanes': '81,82,83,84', 'description': 'fortyGigE0/108', 'mtu': '9100', 'tpid': '0x8100'}, "
"'Ethernet112': {'alias': 'fortyGigE0/112', 'pfc_asym': 'off', 'lanes': '89,90,91,92', 'description': 'fortyGigE0/112', 'mtu': '9100', 'tpid': '0x8100'}, "
"'Ethernet116': {'alias': 'fortyGigE0/116', 'pfc_asym': 'off', 'lanes': '93,94,95,96', 'description': 'fortyGigE0/116', 'mtu': '9100', 'tpid': '0x8100'}, "
"'Ethernet120': {'alias': 'fortyGigE0/120', 'pfc_asym': 'off', 'lanes': '97,98,99,100', 'description': 'fortyGigE0/120', 'mtu': '9100', 'tpid': '0x8100'}, "
"'Ethernet124': {'alias': 'fortyGigE0/124', 'pfc_asym': 'off', 'lanes': '101,102,103,104', 'description': 'fortyGigE0/124', 'mtu': '9100', 'tpid': '0x8100'}}"
)
)
@ -719,7 +721,7 @@ class TestCfgGen(TestCase):
else:
output = subprocess.check_output("sed -i \'s/%s/%s/g\' %s" % (LEAF_ROUTER, BACKEND_LEAF_ROUTER, self.sample_graph), shell=True)
self.test_jinja_expression(self.sample_graph, BACKEND_LEAF_ROUTER)
self.test_jinja_expression(self.sample_graph, self.port_config, BACKEND_LEAF_ROUTER)
self.verify_no_vlan_member()
finally:
print('\n Change device type back to %s' % (LEAF_ROUTER))
@ -728,7 +730,7 @@ class TestCfgGen(TestCase):
else:
output = subprocess.check_output("sed -i \'s/%s/%s/g\' %s" % (BACKEND_LEAF_ROUTER, LEAF_ROUTER, self.sample_graph), shell=True)
self.test_jinja_expression(self.sample_graph, LEAF_ROUTER)
self.test_jinja_expression(self.sample_graph, self.port_config, LEAF_ROUTER)
def verify_no_vlan_member(self):
argument = '-m "' + self.sample_graph + '" -p "' + self.port_config + '" -v "VLAN_MEMBER"'
@ -745,7 +747,7 @@ class TestCfgGen(TestCase):
else:
output = subprocess.check_output("sed -i \'s/%s/%s/g\' %s" % (TOR_ROUTER, BACKEND_TOR_ROUTER, graph_file), shell=True)
self.test_jinja_expression(graph_file, BACKEND_TOR_ROUTER)
self.test_jinja_expression(graph_file, self.port_config, BACKEND_TOR_ROUTER)
# INTERFACE table does not exist
@ -805,7 +807,7 @@ class TestCfgGen(TestCase):
else:
output = subprocess.check_output("sed -i \'s/%s/%s/g\' %s" % (BACKEND_TOR_ROUTER, TOR_ROUTER, graph_file), shell=True)
self.test_jinja_expression(graph_file, TOR_ROUTER)
self.test_jinja_expression(graph_file, self.port_config, TOR_ROUTER)
def test_show_run_acl(self):
argument = '-a \'{"key1":"value"}\' --var-json ACL_RULE'
@ -818,7 +820,7 @@ class TestCfgGen(TestCase):
self.assertEqual(output, '')
def test_minigraph_voq_metadata(self):
argument = "-m {} --var-json DEVICE_METADATA".format(self.sample_graph_voq)
argument = "-m {} -p {} --var-json DEVICE_METADATA".format(self.sample_graph_voq, self.voq_port_config)
output = json.loads(self.run_script(argument))
self.assertEqual(output['localhost']['asic_name'], 'Asic0')
self.assertEqual(output['localhost']['switch_id'], '0')
@ -826,7 +828,7 @@ class TestCfgGen(TestCase):
self.assertEqual(output['localhost']['max_cores'], '16')
def test_minigraph_voq_system_ports(self):
argument = "-m {} --var-json SYSTEM_PORT".format(self.sample_graph_voq)
argument = "-m {} -p {} --var-json SYSTEM_PORT".format(self.sample_graph_voq, self.voq_port_config)
self.assertDictEqual(
json.loads(self.run_script(argument)),
{
@ -845,7 +847,7 @@ class TestCfgGen(TestCase):
)
def test_minigraph_voq_inband_interface_vlan(self):
argument = "-m {} --var-json VOQ_INBAND_INTERFACE".format(self.sample_graph_voq)
argument = "-m {} -p {} --var-json VOQ_INBAND_INTERFACE".format(self.sample_graph_voq, self.voq_port_config)
output = self.run_script(argument)
output_dict = utils.to_dict(output.strip())
self.assertDictEqual(
@ -858,7 +860,7 @@ class TestCfgGen(TestCase):
)
def test_minigraph_voq_inband_interface_port(self):
argument = "-m {} --var-json VOQ_INBAND_INTERFACE".format(self.sample_graph_voq)
argument = "-m {} -p {} --var-json VOQ_INBAND_INTERFACE".format(self.sample_graph_voq, self.voq_port_config)
output = self.run_script(argument)
output_dict = utils.to_dict(output.strip())
self.assertDictEqual(

View File

@ -49,7 +49,7 @@ class TestCfgGenPlatformJson(TestCase):
self.assertEqual(output, '')
def test_print_data(self):
argument = '-m "' + self.platform_sample_graph + '" --print-data'
argument = '-m "' + self.platform_sample_graph + '" -p "' + self.platform_json + '" --print-data'
output = self.run_script(argument)
self.assertTrue(len(output.strip()) > 0)

View File

@ -43,11 +43,11 @@ class TestJ2Files(TestCase):
def test_interfaces(self):
interfaces_template = os.path.join(self.test_dir, '..', '..', '..', 'files', 'image_config', 'interfaces', 'interfaces.j2')
argument = '-m ' + self.t0_minigraph + ' -a \'{\"hwaddr\":\"e4:1d:2d:a5:f3:ad\"}\' -t ' + interfaces_template + ' > ' + self.output_file
argument = '-m ' + self.t0_minigraph + ' -p ' + self.t0_port_config + ' -a \'{\"hwaddr\":\"e4:1d:2d:a5:f3:ad\"}\' -t ' + interfaces_template + ' > ' + self.output_file
self.run_script(argument)
self.assertTrue(utils.cmp(os.path.join(self.test_dir, 'sample_output', utils.PYvX_DIR, 'interfaces'), self.output_file))
argument = '-m ' + self.t0_mvrf_minigraph + ' -a \'{\"hwaddr\":\"e4:1d:2d:a5:f3:ad\"}\' -t ' + interfaces_template + ' > ' + self.output_file
argument = '-m ' + self.t0_mvrf_minigraph + ' -p ' + self.t0_port_config + ' -a \'{\"hwaddr\":\"e4:1d:2d:a5:f3:ad\"}\' -t ' + interfaces_template + ' > ' + self.output_file
self.run_script(argument)
self.assertTrue(utils.cmp(os.path.join(self.test_dir, 'sample_output', utils.PYvX_DIR, 'mvrf_interfaces'), self.output_file))
@ -282,16 +282,18 @@ class TestJ2Files(TestCase):
test_list = {
"t1": {
"graph": self.t1_mlnx_minigraph,
"port_config": self.mlnx_port_config,
"output": "t1-switch.json"
},
"t0": {
"graph": self.t0_minigraph,
"port_config": self.t0_port_config,
"output": "t0-switch.json"
},
}
for _, v in test_list.items():
argument = " -m {} -y {} -t {} > {}".format(
v["graph"], constants_yml, switch_template, self.output_file
argument = " -m {} -p {} -y {} -t {} > {}".format(
v["graph"], v["port_config"], constants_yml, switch_template, self.output_file
)
sample_output_file = os.path.join(
self.test_dir, 'sample_output', v["output"]

View File

@ -44,27 +44,27 @@ class TestCfgGenCaseInsensitive(TestCase):
self.assertEqual(output, '')
def test_minigraph_sku(self):
argument = '-v "DEVICE_METADATA[\'localhost\'][\'hwsku\']" -m "' + self.sample_graph + '"'
argument = '-v "DEVICE_METADATA[\'localhost\'][\'hwsku\']" -m "' + self.sample_graph + '" -p "' + self.port_config + '"'
output = self.run_script(argument)
self.assertEqual(output.strip(), 'Force10-S6000')
def test_print_data(self):
argument = '-m "' + self.sample_graph + '" --print-data'
argument = '-m "' + self.sample_graph + '" -p "' + self.port_config + '" --print-data'
output = self.run_script(argument)
self.assertTrue(len(output.strip()) > 0)
def test_jinja_expression(self):
argument = '-m "' + self.sample_graph + '" -v "DEVICE_METADATA[\'localhost\'][\'type\']"'
argument = '-m "' + self.sample_graph + '" -p "' + self.port_config + '" -v "DEVICE_METADATA[\'localhost\'][\'type\']"'
output = self.run_script(argument)
self.assertEqual(output.strip(), 'ToRRouter')
def test_minigraph_subtype(self):
argument = '-m "' + self.sample_graph + '" -v "DEVICE_METADATA[\'localhost\'][\'subtype\']"'
argument = '-m "' + self.sample_graph + '" -p "' + self.port_config + '" -v "DEVICE_METADATA[\'localhost\'][\'subtype\']"'
output = self.run_script(argument)
self.assertEqual(output.strip(), 'DualToR')
def test_minigraph_peer_switch_hostname(self):
argument = '-m "' + self.sample_graph + '" -v "DEVICE_METADATA[\'localhost\'][\'peer_switch\']"'
argument = '-m "' + self.sample_graph + '" -p "' + self.port_config + '" -v "DEVICE_METADATA[\'localhost\'][\'peer_switch\']"'
output = self.run_script(argument)
self.assertEqual(output.strip(), 'switch2-t0')
@ -156,7 +156,7 @@ class TestCfgGenCaseInsensitive(TestCase):
)
def test_minigraph_console_mgmt_feature(self):
argument = '-m "' + self.sample_graph + '" -v CONSOLE_SWITCH'
argument = '-m "' + self.sample_graph + '" -p "' + self.port_config + '" -v CONSOLE_SWITCH'
output = self.run_script(argument)
self.assertEqual(
utils.to_dict(output.strip()),

View File

@ -25,6 +25,7 @@ class TestMultiNpuCfgGen(TestCase):
self.script_file = utils.PYTHON_INTERPRETTER + ' ' + os.path.join(self.test_dir, '..', 'sonic-cfggen')
self.sample_graph = os.path.join(self.test_data_dir, 'sample-minigraph.xml')
self.sample_graph1 = os.path.join(self.test_data_dir, 'sample-minigraph-noportchannel.xml')
self.sample_port_config = os.path.join(self.test_data_dir, 'sample_port_config.ini')
self.port_config = []
for asic in range(NUM_ASIC):
self.port_config.append(os.path.join(self.test_data_dir, "sample_port_config-{}.ini".format(asic)))
@ -80,19 +81,21 @@ class TestMultiNpuCfgGen(TestCase):
self.assertEqual(output, '')
def test_hwsku(self):
argument = "-v \"DEVICE_METADATA[\'localhost\'][\'hwsku\']\" -m \"{}\"".format(self.sample_graph)
argument = "-v \"DEVICE_METADATA[\'localhost\'][\'hwsku\']\" -m \"{}\" -p \"{}\"".format(self.sample_graph, self.sample_port_config)
output = self.run_script(argument)
self.assertEqual(output.strip(), SKU)
argument = "-v \"DEVICE_METADATA[\'localhost\'][\'hwsku\']\" -m \"{}\"".format(self.sample_graph)
for asic in range(NUM_ASIC):
output = self.run_script_for_asic(argument, asic)
output = self.run_script_for_asic(argument, asic, self.port_config[asic])
self.assertEqual(output.strip(), SKU)
def test_print_data(self):
argument = "-m \"{}\" --print-data".format(self.sample_graph)
argument = "-m \"{}\" -p \"{}\" --print-data".format(self.sample_graph, self.sample_port_config)
output = self.run_script(argument)
self.assertGreater(len(output.strip()) , 0)
argument = "-m \"{}\" --print-data".format(self.sample_graph)
for asic in range(NUM_ASIC):
output = self.run_script_for_asic(argument, asic)
output = self.run_script_for_asic(argument, asic, self.port_config[asic])
self.assertGreater(len(output.strip()) , 0)
def test_additional_json_data(self):
@ -100,7 +103,7 @@ class TestMultiNpuCfgGen(TestCase):
output = self.run_script(argument)
self.assertEqual(output.strip(), 'value1')
for asic in range(NUM_ASIC):
output = self.run_script_for_asic(argument, asic)
output = self.run_script_for_asic(argument, asic, self.port_config[asic])
self.assertEqual(output.strip(), 'value1')
def test_read_yaml(self):
@ -108,7 +111,7 @@ class TestMultiNpuCfgGen(TestCase):
output = yaml.load(self.run_script(argument))
self.assertListEqual(output, ['value1', 'value2'])
for asic in range(NUM_ASIC):
output = yaml.load(self.run_script_for_asic(argument, asic))
output = yaml.load(self.run_script_for_asic(argument, asic, self.port_config[asic]))
self.assertListEqual(output, ['value1', 'value2'])
def test_render_template(self):
@ -116,32 +119,35 @@ class TestMultiNpuCfgGen(TestCase):
output = self.run_script(argument)
self.assertEqual(output.strip(), 'value1\nvalue2')
for asic in range(NUM_ASIC):
output = self.run_script_for_asic(argument, asic)
output = self.run_script_for_asic(argument, asic, self.port_config[asic])
self.assertEqual(output.strip(), 'value1\nvalue2')
def test_metadata_tacacs(self):
argument = '-m "' + self.sample_graph + '" --var-json "TACPLUS_SERVER"'
argument = '-m "' + self.sample_graph + '" -p "' + self.sample_port_config + '" --var-json "TACPLUS_SERVER"'
output = json.loads(self.run_script(argument))
self.assertDictEqual(output, {'123.46.98.21': {'priority': '1', 'tcp_port': '49'}})
#TACPLUS_SERVER not present in the asic configuration.
argument = '-m "' + self.sample_graph + '" --var-json "TACPLUS_SERVER"'
for asic in range(NUM_ASIC):
output = json.loads(self.run_script_for_asic(argument, asic, self.port_config[asic]))
self.assertDictEqual(output, {})
def test_metadata_ntp(self):
argument = '-m "' + self.sample_graph + '" --var-json "NTP_SERVER"'
argument = '-m "' + self.sample_graph + '" -p "' + self.sample_port_config + '" --var-json "NTP_SERVER"'
output = json.loads(self.run_script(argument))
self.assertDictEqual(output, {'17.39.1.130': {}, '17.39.1.129': {}})
#NTP data is present only in the host config
argument = '-m "' + self.sample_graph + '" --var-json "NTP_SERVER"'
for asic in range(NUM_ASIC):
output = json.loads(self.run_script_for_asic(argument, asic, self.port_config[asic]))
print("Log:asic{} sku {}".format(asic,output))
self.assertDictEqual(output, {})
def test_mgmt_port(self):
argument = '-m "' + self.sample_graph + '" --var-json "MGMT_PORT"'
argument = '-m "' + self.sample_graph + '" -p "' + self.sample_port_config + '" --var-json "MGMT_PORT"'
output = json.loads(self.run_script(argument))
self.assertDictEqual(output, {'eth0': {'alias': 'eth0', 'admin_status': 'up'}})
argument = '-m "' + self.sample_graph + '" --var-json "MGMT_PORT"'
for asic in range(NUM_ASIC):
output = json.loads(self.run_script_for_asic(argument, asic, self.port_config[asic]))
self.assertDictEqual(output, {'eth0': {'alias': 'eth0', 'admin_status': 'up'}})
@ -215,17 +221,17 @@ class TestMultiNpuCfgGen(TestCase):
"Ethernet-BP12": { "admin_status": "up", "alias": "Eth7-ASIC0", "asic_port_name": "Eth7-ASIC0", "description": "ASIC3:Eth1-ASIC3", "index": "3", "lanes": "25,26,27,28", "mtu": "9100", "tpid": "0x8100", "pfc_asym": "off", "role": "Int", "speed": "40000" }})
def test_frontend_asic_ports_config_db(self):
argument = "-m {} -n asic0 --var-json \"PORT\"".format(self.sample_graph)
argument = "-m {} -p {} -n asic0 --var-json \"PORT\"".format(self.sample_graph, self.port_config[0])
output = json.loads(self.run_script(argument))
self.assertDictEqual(output,
{"Ethernet0": { "admin_status": "up", "alias": "Ethernet1/1", "asic_port_name": "Eth0-ASIC0", "description": "01T2:Ethernet1:config_db", "index": "0", "lanes": "33,34,35,36", "mtu": "9100", "tpid": "0x8100", "pfc_asym": "off", "role": "Ext", "speed": "40000", "autoneg": "on" },
"Ethernet4": { "admin_status": "up", "alias": "Ethernet1/2", "asic_port_name": "Eth1-ASIC0", "description": "01T2:Ethernet2:config_db", "index": "1", "lanes": "29,30,31,32", "mtu": "9100", "tpid": "0x8100", "pfc_asym": "off", "role": "Ext", "speed": "40000", "autoneg": "on" },
"Ethernet8": { "admin_status": "up", "alias": "Ethernet1/3", "asic_port_name": "Eth2-ASIC0", "description": "Ethernet1/3:config_db", "index": "2", "lanes": "41,42,43,44", "mtu": "9100", "tpid": "0x8100", "pfc_asym": "off", "role": "Ext", "speed": "40000" },
"Ethernet12": { "admin_status": "up", "alias": "Ethernet1/4", "asic_port_name": "Eth3-ASIC0", "description": "Ethernet1/4:config_db", "index": "3", "lanes": "37,38,39,40", "mtu": "9100", "tpid": "0x8100", "pfc_asym": "off", "role": "Ext", "speed": "40000" },
"Ethernet-BP0": { "admin_status": "up", "alias": "Eth4-ASIC0", "asic_port_name": "Eth4-ASIC0", "description": "ASIC2:Eth0-ASIC2:config_db", "index": "0", "lanes": "13,14,15,16", "mtu": "9100", "tpid": "0x8100", "pfc_asym": "off", "role": "Int", "speed": "40000" },
"Ethernet-BP4": { "admin_status": "up", "alias": "Eth5-ASIC0", "asic_port_name": "Eth5-ASIC0", "description": "ASIC2:Eth1-ASIC2:config_db", "index": "1", "lanes": "17,18,19,20", "mtu": "9100", "tpid": "0x8100", "pfc_asym": "off", "role": "Int", "speed": "40000" },
"Ethernet-BP8": { "admin_status": "up", "alias": "Eth6-ASIC0", "asic_port_name": "Eth6-ASIC0", "description": "ASIC3:Eth0-ASIC3:config_db", "index": "2", "lanes": "21,22,23,24", "mtu": "9100", "tpid": "0x8100", "pfc_asym": "off", "role": "Int", "speed": "40000" },
"Ethernet-BP12": { "admin_status": "up", "alias": "Eth7-ASIC0", "asic_port_name": "Eth7-ASIC0", "description": "ASIC3:Eth1-ASIC3:config_db", "index": "3", "lanes": "25,26,27,28", "mtu": "9100", "tpid": "0x8100", "pfc_asym": "off", "role": "Int", "speed": "40000" }})
{"Ethernet0": { "admin_status": "up", "alias": "Ethernet1/1", "asic_port_name": "Eth0-ASIC0", "description": "01T2:Ethernet1", "index": "0", "lanes": "33,34,35,36", "mtu": "9100", "tpid": "0x8100", "pfc_asym": "off", "role": "Ext", "speed": "40000", "autoneg": "on" },
"Ethernet4": { "admin_status": "up", "alias": "Ethernet1/2", "asic_port_name": "Eth1-ASIC0", "description": "01T2:Ethernet2", "index": "1", "lanes": "29,30,31,32", "mtu": "9100", "tpid": "0x8100", "pfc_asym": "off", "role": "Ext", "speed": "40000", "autoneg": "on" },
"Ethernet8": { "alias": "Ethernet1/3", "asic_port_name": "Eth2-ASIC0", "description": "Ethernet1/3", "index": "2", "lanes": "41,42,43,44", "mtu": "9100", "tpid": "0x8100", "pfc_asym": "off", "role": "Ext", "speed": "40000" },
"Ethernet12": { "alias": "Ethernet1/4", "asic_port_name": "Eth3-ASIC0", "description": "Ethernet1/4", "index": "3", "lanes": "37,38,39,40", "mtu": "9100", "tpid": "0x8100", "pfc_asym": "off", "role": "Ext", "speed": "40000" },
"Ethernet-BP0": { "admin_status": "up", "alias": "Eth4-ASIC0", "asic_port_name": "Eth4-ASIC0", "description": "ASIC2:Eth0-ASIC2", "index": "0", "lanes": "13,14,15,16", "mtu": "9100", "tpid": "0x8100", "pfc_asym": "off", "role": "Int", "speed": "40000" },
"Ethernet-BP4": { "admin_status": "up", "alias": "Eth5-ASIC0", "asic_port_name": "Eth5-ASIC0", "description": "ASIC2:Eth1-ASIC2", "index": "1", "lanes": "17,18,19,20", "mtu": "9100", "tpid": "0x8100", "pfc_asym": "off", "role": "Int", "speed": "40000" },
"Ethernet-BP8": { "admin_status": "up", "alias": "Eth6-ASIC0", "asic_port_name": "Eth6-ASIC0", "description": "ASIC3:Eth0-ASIC3", "index": "2", "lanes": "21,22,23,24", "mtu": "9100", "tpid": "0x8100", "pfc_asym": "off", "role": "Int", "speed": "40000" },
"Ethernet-BP12": { "admin_status": "up", "alias": "Eth7-ASIC0", "asic_port_name": "Eth7-ASIC0", "description": "ASIC3:Eth1-ASIC3", "index": "3", "lanes": "25,26,27,28", "mtu": "9100", "tpid": "0x8100", "pfc_asym": "off", "role": "Int", "speed": "40000" }})
def test_frontend_asic_device_neigh(self):
argument = "-m {} -p {} -n asic0 --var-json \"DEVICE_NEIGHBOR\"".format(self.sample_graph, self.port_config[0])
@ -270,7 +276,7 @@ class TestMultiNpuCfgGen(TestCase):
'fc00::2': {'rrclient': 0, 'name': '01T2', 'local_addr': 'fc00::1', 'nhopself': 0, 'holdtime': '10', 'asn': '65200', 'keepalive': '3'}})
def test_frontend_asic_bgp_neighbor(self):
argument = "-m {} -p {} -n asic0 --var-json \"BGP_INTERNAL_NEIGHBOR\"".format(self.sample_graph, self.port_config[3])
argument = "-m {} -p {} -n asic0 --var-json \"BGP_INTERNAL_NEIGHBOR\"".format(self.sample_graph, self.port_config[0])
output = json.loads(self.run_script(argument))
self.assertDictEqual(output, \
{'10.1.0.0': {'rrclient': 0, 'name': 'ASIC2', 'local_addr': '10.1.0.1', 'nhopself': 0, 'admin_status': 'up', 'holdtime': '0', 'asn': '65100', 'keepalive': '0'},
@ -297,23 +303,38 @@ class TestMultiNpuCfgGen(TestCase):
self.assertEqual(output['localhost']['sub_role'], 'BackEnd')
def test_global_asic_acl(self):
argument = "-m {} --var-json \"ACL_TABLE\"".format(self.sample_graph)
argument = "-m {} -p {} --var-json \"ACL_TABLE\"".format(self.sample_graph, self.sample_port_config)
output = json.loads(self.run_script(argument))
self.assertDictEqual(output, {\
'DATAACL': {'policy_desc': 'DATAACL', 'ports': ['PortChannel0002','PortChannel0008'], 'stage': 'ingress', 'type': 'L3'},
'EVERFLOW': {'policy_desc': 'EVERFLOW', 'ports': ['PortChannel0002','PortChannel0008'], 'stage': 'ingress', 'type': 'MIRROR'},
'EVERFLOWV6':{'policy_desc': 'EVERFLOWV6', 'ports': ['PortChannel0002','PortChannel0008'], 'stage': 'ingress', 'type': 'MIRRORV6'},
'SNMP_ACL': {'policy_desc': 'SNMP_ACL', 'services': ['SNMP'], 'stage': 'ingress', 'type': 'CTRLPLANE'},
'SSH_ONLY': {'policy_desc': 'SSH_ONLY', 'services': ['SSH'], 'stage': 'ingress', 'type': 'CTRLPLANE'}})
def test_global_asic_acl1(self):
argument = "-m {} --var-json \"ACL_TABLE\"".format(self.sample_graph1)
output = json.loads(self.run_script(argument))
self.assertDictEqual(output, {\
'EVERFLOW': {'policy_desc': 'EVERFLOW', 'ports': [], 'stage': 'ingress', 'type': 'MIRROR'},
'EVERFLOWV6':{'policy_desc': 'EVERFLOWV6', 'ports': [], 'stage': 'ingress', 'type': 'MIRRORV6'},
'SNMP_ACL': {'policy_desc': 'SNMP_ACL', 'services': ['SNMP'], 'stage': 'ingress', 'type': 'CTRLPLANE'},
'SSH_ONLY': {'policy_desc': 'SSH_ONLY', 'services': ['SSH'], 'stage': 'ingress', 'type': 'CTRLPLANE'}})
exp = {\
'SNMP_ACL': {'policy_desc': 'SNMP_ACL', 'type': 'CTRLPLANE', 'stage': 'ingress', 'services': ['SNMP']},
'EVERFLOW': {'policy_desc': 'EVERFLOW', 'stage': 'ingress', 'ports': ['PortChannel0002', 'PortChannel0008', 'Ethernet8', 'Ethernet12', 'Ethernet24', 'Ethernet28'], 'type': 'MIRROR'},
'EVERFLOWV6': {'policy_desc': 'EVERFLOWV6', 'stage': 'ingress', 'ports': ['PortChannel0002', 'PortChannel0008', 'Ethernet8', 'Ethernet12', 'Ethernet24', 'Ethernet28'], 'type': 'MIRRORV6'},
'SSH_ONLY': {'policy_desc': 'SSH_ONLY', 'type': 'CTRLPLANE', 'stage': 'ingress', 'services': ['SSH']},
'DATAACL': {'policy_desc': 'DATAACL', 'stage': 'ingress', 'ports': ['PortChannel0002', 'PortChannel0008'], 'type': 'L3'}}
for k, v in output.items():
if 'ports' in v:
v['ports'].sort()
for k, v in exp.items():
if 'ports' in v:
v['ports'].sort()
self.assertDictEqual(output, exp)
def test_global_asic_acl1(self):
argument = "-m {} -p {} --var-json \"ACL_TABLE\"".format(self.sample_graph1, self.sample_port_config)
self.maxDiff = None
output = json.loads(self.run_script(argument))
exp = {\
'SNMP_ACL': {'policy_desc': 'SNMP_ACL', 'type': 'CTRLPLANE', 'stage': 'ingress', 'services': ['SNMP']},
'EVERFLOW': {'policy_desc': 'EVERFLOW', 'stage': 'ingress', 'ports': ['Ethernet0', 'Ethernet4', 'Ethernet8', 'Ethernet12', 'Ethernet16', 'Ethernet20', 'Ethernet24', 'Ethernet28'], 'type': 'MIRROR'},
'EVERFLOWV6': {'policy_desc': 'EVERFLOWV6', 'stage': 'ingress', 'ports': ['Ethernet0', 'Ethernet4', 'Ethernet8', 'Ethernet12', 'Ethernet16', 'Ethernet20', 'Ethernet24', 'Ethernet28'], 'type': 'MIRRORV6'},
'SSH_ONLY': {'policy_desc': 'SSH_ONLY', 'type': 'CTRLPLANE', 'stage': 'ingress', 'services': ['SSH']}}
for k, v in output.items():
if 'ports' in v:
v['ports'].sort()
for k, v in exp.items():
if 'ports' in v:
v['ports'].sort()
self.assertDictEqual(output, exp)
def test_front_end_asic_acl(self):
argument = "-m {} -p {} -n asic0 --var-json \"ACL_TABLE\"".format(self.sample_graph, self.port_config[0])
@ -347,7 +368,7 @@ class TestMultiNpuCfgGen(TestCase):
def test_loopback_intfs(self):
argument = "-m {} --var-json \"LOOPBACK_INTERFACE\"".format(self.sample_graph)
argument = "-m {} -p {} --var-json \"LOOPBACK_INTERFACE\"".format(self.sample_graph, self.sample_port_config)
output = json.loads(self.run_script(argument))
self.assertDictEqual(output, {\
"Loopback0": {},
@ -355,7 +376,7 @@ class TestMultiNpuCfgGen(TestCase):
"Loopback0|FC00:1::32/128": {}})
# The asic configuration should have 2 loopback interfaces
argument = "-m {} -n asic0 --var-json \"LOOPBACK_INTERFACE\"".format(self.sample_graph)
argument = "-m {} -p {} -n asic0 --var-json \"LOOPBACK_INTERFACE\"".format(self.sample_graph, self.port_config[0])
output = json.loads(self.run_script(argument))
self.assertDictEqual(output, { \
"Loopback0": {},
@ -365,7 +386,7 @@ class TestMultiNpuCfgGen(TestCase):
"Loopback4096|8.0.0.0/32": {},
"Loopback4096|FD00:1::32/128": {}})
argument = "-m {} -n asic3 --var-json \"LOOPBACK_INTERFACE\"".format(self.sample_graph)
argument = "-m {} -p {} -n asic3 --var-json \"LOOPBACK_INTERFACE\"".format(self.sample_graph, self.port_config[3])
output = json.loads(self.run_script(argument))
self.assertDictEqual(output, {\
"Loopback0": {},