From d20fc3c8721c758d9a009095c682682f437e9c96 Mon Sep 17 00:00:00 2001 From: Dev Ojha <47282568+developfast@users.noreply.github.com> Date: Fri, 7 Apr 2023 16:31:15 -0700 Subject: [PATCH] [202012][DBMigrator] Update db_migrator to support EdgeZoneAggregator Buffer Config for T0s (#2768) * edgezoneagg buffer upgrade * Removed checking function for version changes Removed function to check if a version is greater than another version as it is no longer needed * Update sample-t0-edgezoneagg-config-input.json * Update sample-t0-edgezoneagg-config-output.json * Update sample-t0-edgezoneagg-config-same-cable-input.json * Update sample-t0-edgezoneagg-config-same-cable-output.json * migrated to common migration * Update sample-t0-edgezoneagg-config-output.json * Update sample-t0-edgezoneagg-config-same-cable-output.json --- scripts/db_migrator.py | 61 +++++++-- .../sample-t0-edgezoneagg-config-input.json | 123 ++++++++++++++++++ .../sample-t0-edgezoneagg-config-output.json | 123 ++++++++++++++++++ ...0-edgezoneagg-config-same-cable-input.json | 123 ++++++++++++++++++ ...-edgezoneagg-config-same-cable-output.json | 123 ++++++++++++++++++ tests/db_migrator_test.py | 40 +++++- 6 files changed, 583 insertions(+), 10 deletions(-) create mode 100644 tests/db_migrator_input/config_db/sample-t0-edgezoneagg-config-input.json create mode 100644 tests/db_migrator_input/config_db/sample-t0-edgezoneagg-config-output.json create mode 100644 tests/db_migrator_input/config_db/sample-t0-edgezoneagg-config-same-cable-input.json create mode 100644 tests/db_migrator_input/config_db/sample-t0-edgezoneagg-config-same-cable-output.json diff --git a/scripts/db_migrator.py b/scripts/db_migrator.py index 12d1d6ba2c..3bb6fec122 100755 --- a/scripts/db_migrator.py +++ b/scripts/db_migrator.py @@ -162,7 +162,7 @@ def migrate_mgmt_ports_on_s6100(self): self.appDB.set(self.appDB.APPL_DB, 'PORT_TABLE:PortConfigDone', 'count', str(total_count)) log.log_notice("Port count updated from {} to : {}".format(portCount, self.appDB.get(self.appDB.APPL_DB, 'PORT_TABLE:PortConfigDone', 'count'))) return True - + def migrate_intf_table(self): ''' Migrate all data from existing INTF table in APP DB during warmboot with IP Prefix @@ -260,7 +260,6 @@ def migrate_config_db_buffer_tables_for_dynamic_calculation(self, speed_list, ca @append_item_method - a function which is called to append an item to the list of pending commit items any update to buffer configuration will be pended and won't be applied until all configuration is checked and aligns with the default one - 1. Buffer profiles for lossless PGs in BUFFER_PROFILE table will be removed if their names have the convention of pg_lossless___profile where the speed and cable_length belongs speed_list and cable_len_list respectively @@ -344,7 +343,6 @@ def prepare_dynamic_buffer_for_warm_reboot(self, buffer_pools=None, buffer_profi ''' This is the very first warm reboot of buffermgrd (dynamic) if the system reboot from old image by warm-reboot In this case steps need to be taken to get buffermgrd prepared (for warm reboot) - During warm reboot, buffer tables should be installed in the first place. However, it isn't able to achieve that when system is warm-rebooted from an old image without dynamic buffer supported, because the buffer info wasn't in the APPL_DB in the old image. @@ -352,7 +350,6 @@ def prepare_dynamic_buffer_for_warm_reboot(self, buffer_pools=None, buffer_profi During warm-reboot, db_migrator adjusts buffer info in CONFIG_DB by removing some fields according to requirement from dynamic buffer calculation. The buffer info before that adjustment needs to be copied to APPL_DB. - 1. set WARM_RESTART_TABLE|buffermgrd as {restore_count: 0} 2. Copy the following tables from CONFIG_DB into APPL_DB in case of warm reboot The separator in fields that reference objects in other table needs to be updated from '|' to ':' @@ -362,7 +359,6 @@ def prepare_dynamic_buffer_for_warm_reboot(self, buffer_pools=None, buffer_profi - BUFFER_QUEUE, separator updated for field 'profile - BUFFER_PORT_INGRESS_PROFILE_LIST, separator updated for field 'profile_list' - BUFFER_PORT_EGRESS_PROFILE_LIST, separator updated for field 'profile_list' - ''' warmreboot_state = self.stateDB.get(self.stateDB.STATE_DB, 'WARM_RESTART_ENABLE_TABLE|system', 'enable') mmu_size = self.stateDB.get(self.stateDB.STATE_DB, 'BUFFER_MAX_PARAM_TABLE|global', 'mmu_size') @@ -428,7 +424,7 @@ def prepare_dynamic_buffer_for_warm_reboot(self, buffer_pools=None, buffer_profi return True def migrate_pfcwd_sw_enable_table(self): - """ + """ Migrate "pfc_enable" to "pfc_enable" and "pfcwd_sw_enable" 1. pfc_enable means enable pfc on certain queues 2. pfcwd_sw_enable means enable PFC software watchdog on certain queues @@ -512,6 +508,50 @@ def migrate_port_qos_map_global(self): self.configDB.set_entry('PORT_QOS_MAP', 'global', {"dscp_to_tc_map": "[DSCP_TO_TC_MAP|{}]".format(dscp_to_tc_map_table_names[0])}) log.log_info("Created entry for global DSCP_TO_TC_MAP {}".format(dscp_to_tc_map_table_names[0])) + def update_edgezone_aggregator_config(self): + """ + Update cable length configuration in ConfigDB for T0 neighbor interfaces + connected to EdgeZone Aggregator devices, while resetting the port values to trigger a buffer change + 1. Find a list of all interfaces connected to an EdgeZone Aggregator device. + 2. If all the cable lengths are the same, do nothing and return. + 3. If there are different cable lengths, update CABLE_LENGTH values for these interfaces with a constant value of 40m. + """ + device_neighbor_metadata = self.configDB.get_table("DEVICE_NEIGHBOR_METADATA") + device_neighbors = self.configDB.get_table("DEVICE_NEIGHBOR") + cable_length = self.configDB.get_table("CABLE_LENGTH") + port_table = self.configDB.get_table("PORT") + edgezone_aggregator_devs = [] + edgezone_aggregator_intfs = [] + EDGEZONE_AGG_CABLE_LENGTH = "40m" + for k, v in device_neighbor_metadata.items(): + if v.get("type") == "EdgeZoneAggregator": + edgezone_aggregator_devs.append(k) + + if len(edgezone_aggregator_devs) == 0: + return + + for intf, intf_info in device_neighbors.items(): + if intf_info.get("name") in edgezone_aggregator_devs: + edgezone_aggregator_intfs.append(intf) + + cable_length_table = self.configDB.get_entry("CABLE_LENGTH", "AZURE") + first_cable_intf = next(iter(cable_length_table)) + first_cable_length = cable_length_table[first_cable_intf] + index = 0 + + for intf, length in cable_length_table.items(): + index += 1 + if first_cable_length != length: + break + elif index == len(cable_length_table): + # All cable lengths are the same, nothing to modify + return + + for intf, length in cable_length_table.items(): + if intf in edgezone_aggregator_intfs: + # Set new cable length values + self.configDB.set(self.configDB.CONFIG_DB, "CABLE_LENGTH|AZURE", intf, EDGEZONE_AGG_CABLE_LENGTH) + def version_unknown(self): """ version_unknown tracks all SONiC versions that doesn't have a version @@ -711,7 +751,7 @@ def common_migration_ops(self): self.configDB.set_entry(init_cfg_table, key, new_cfg) self.migrate_copp_table() - if self.asic_type == "broadcom" and 'Force10-S6100' in self.hwsku: + if self.asic_type == "broadcom" and 'Force10-S6100' in self.hwsku: self.migrate_mgmt_ports_on_s6100() else: log.log_notice("Asic Type: {}, Hwsku: {}".format(self.asic_type, self.hwsku)) @@ -725,10 +765,13 @@ def common_migration_ops(self): # version 2_0_1 has been occupied by 202106 if self.asic_type == "mellanox": self.mellanox_buffer_migrator.mlnx_reclaiming_unused_buffer() - - # Migrate pfcwd_sw_enable table + + # Migrate pfcwd_sw_enable table self.migrate_pfcwd_sw_enable_table() + # Updating edgezone aggregator cable length config for T0 devices + self.update_edgezone_aggregator_config() + def migrate(self): version = self.get_version() log.log_info('Upgrading from version ' + version) diff --git a/tests/db_migrator_input/config_db/sample-t0-edgezoneagg-config-input.json b/tests/db_migrator_input/config_db/sample-t0-edgezoneagg-config-input.json new file mode 100644 index 0000000000..ef21d0692d --- /dev/null +++ b/tests/db_migrator_input/config_db/sample-t0-edgezoneagg-config-input.json @@ -0,0 +1,123 @@ +{ + "DEVICE_NEIGHBOR_METADATA|ARISTA01T1": { + "hwsku": "Arista-VM", + "mgmt_addr": "10.64.247.200", + "type": "EdgeZoneAggregator" + }, + "DEVICE_NEIGHBOR_METADATA|ARISTA02T1": { + "hwsku": "Arista-VM", + "mgmt_addr": "10.64.247.200", + "type": "EdgeZoneAggregator" + }, + "DEVICE_NEIGHBOR_METADATA|ARISTA03T1": { + "hwsku": "Arista-VM", + "mgmt_addr": "10.64.247.200", + "type": "EdgeZoneAggregator" + }, + "DEVICE_NEIGHBOR_METADATA|ARISTA04T1": { + "hwsku": "Arista-VM", + "mgmt_addr": "10.64.247.200", + "type": "EdgeZoneAggregator" + }, + "DEVICE_NEIGHBOR|Ethernet0": { + "name": "ARISTA01T1", + "port": "Ethernet1" + }, + "DEVICE_NEIGHBOR|Ethernet4": { + "name": "ARISTA02T1", + "port": "Ethernet1" + }, + "DEVICE_NEIGHBOR|Ethernet8": { + "name": "ARISTA03T1", + "port": "Ethernet1" + }, + "DEVICE_NEIGHBOR|Ethernet12": { + "name": "ARISTA04T1", + "port": "Ethernet1" + }, + "DEVICE_NEIGHBOR|Ethernet16": { + "name": "Servers1", + "port": "eth0" + }, + "DEVICE_NEIGHBOR|Ethernet20": { + "name": "Servers2", + "port": "eth0" + }, + "PORT|Ethernet0": { + "admin_status": "up", + "alias": "Ethernet1/1", + "description": "", + "index": "1", + "lanes": "77,78", + "mtu": "9100", + "pfc_asym": "off", + "speed": "100000", + "tpid": "0x8100" + }, + "PORT|Ethernet4": { + "admin_status": "up", + "alias": "Ethernet2/1", + "description": "", + "index": "2", + "lanes": "79,80", + "mtu": "9100", + "pfc_asym": "off", + "speed": "100000", + "tpid": "0x8100" + }, + "PORT|Ethernet8": { + "admin_status": "up", + "alias": "Ethernet3/1", + "description": "", + "index": "3", + "lanes": "81,82", + "mtu": "9100", + "pfc_asym": "off", + "speed": "100000", + "tpid": "0x8100" + }, + "PORT|Ethernet12": { + "admin_status": "up", + "alias": "Ethernet4/1", + "description": "", + "index": "4", + "lanes": "83,84", + "mtu": "9100", + "pfc_asym": "off", + "speed": "100000", + "tpid": "0x8100" + }, + "PORT|Ethernet16": { + "admin_status": "up", + "alias": "Ethernet5/1", + "description": "", + "index": "5", + "lanes": "85,86", + "mtu": "9100", + "pfc_asym": "off", + "speed": "100000", + "tpid": "0x8100" + }, + "PORT|Ethernet20": { + "admin_status": "up", + "alias": "Ethernet6/1", + "description": "", + "index": "6", + "lanes": "87,88", + "mtu": "9100", + "pfc_asym": "off", + "speed": "100000", + "tpid": "0x8100" + }, + "CABLE_LENGTH|AZURE": { + "Ethernet0": "300m", + "Ethernet4": "300m", + "Ethernet8": "300m", + "Ethernet12": "300m", + "Ethernet16": "5m", + "Ethernet20": "5m" + }, + "VERSIONS|DATABASE": { + "VERSION": "version_1_0_1" + } +} diff --git a/tests/db_migrator_input/config_db/sample-t0-edgezoneagg-config-output.json b/tests/db_migrator_input/config_db/sample-t0-edgezoneagg-config-output.json new file mode 100644 index 0000000000..81af4c34f5 --- /dev/null +++ b/tests/db_migrator_input/config_db/sample-t0-edgezoneagg-config-output.json @@ -0,0 +1,123 @@ +{ + "DEVICE_NEIGHBOR_METADATA|ARISTA01T1": { + "hwsku": "Arista-VM", + "mgmt_addr": "10.64.247.200", + "type": "EdgeZoneAggregator" + }, + "DEVICE_NEIGHBOR_METADATA|ARISTA02T1": { + "hwsku": "Arista-VM", + "mgmt_addr": "10.64.247.200", + "type": "EdgeZoneAggregator" + }, + "DEVICE_NEIGHBOR_METADATA|ARISTA03T1": { + "hwsku": "Arista-VM", + "mgmt_addr": "10.64.247.200", + "type": "EdgeZoneAggregator" + }, + "DEVICE_NEIGHBOR_METADATA|ARISTA04T1": { + "hwsku": "Arista-VM", + "mgmt_addr": "10.64.247.200", + "type": "EdgeZoneAggregator" + }, + "DEVICE_NEIGHBOR|Ethernet0": { + "name": "ARISTA01T1", + "port": "Ethernet1" + }, + "DEVICE_NEIGHBOR|Ethernet4": { + "name": "ARISTA02T1", + "port": "Ethernet1" + }, + "DEVICE_NEIGHBOR|Ethernet8": { + "name": "ARISTA03T1", + "port": "Ethernet1" + }, + "DEVICE_NEIGHBOR|Ethernet12": { + "name": "ARISTA04T1", + "port": "Ethernet1" + }, + "DEVICE_NEIGHBOR|Ethernet16": { + "name": "Servers1", + "port": "eth0" + }, + "DEVICE_NEIGHBOR|Ethernet20": { + "name": "Servers2", + "port": "eth0" + }, + "PORT|Ethernet0": { + "admin_status": "up", + "alias": "Ethernet1/1", + "description": "", + "index": "1", + "lanes": "77,78", + "mtu": "9100", + "pfc_asym": "off", + "speed": "100000", + "tpid": "0x8100" + }, + "PORT|Ethernet4": { + "admin_status": "up", + "alias": "Ethernet2/1", + "description": "", + "index": "2", + "lanes": "79,80", + "mtu": "9100", + "pfc_asym": "off", + "speed": "100000", + "tpid": "0x8100" + }, + "PORT|Ethernet8": { + "admin_status": "up", + "alias": "Ethernet3/1", + "description": "", + "index": "3", + "lanes": "81,82", + "mtu": "9100", + "pfc_asym": "off", + "speed": "100000", + "tpid": "0x8100" + }, + "PORT|Ethernet12": { + "admin_status": "up", + "alias": "Ethernet4/1", + "description": "", + "index": "4", + "lanes": "83,84", + "mtu": "9100", + "pfc_asym": "off", + "speed": "100000", + "tpid": "0x8100" + }, + "PORT|Ethernet16": { + "admin_status": "up", + "alias": "Ethernet5/1", + "description": "", + "index": "5", + "lanes": "85,86", + "mtu": "9100", + "pfc_asym": "off", + "speed": "100000", + "tpid": "0x8100" + }, + "PORT|Ethernet20": { + "admin_status": "up", + "alias": "Ethernet6/1", + "description": "", + "index": "6", + "lanes": "87,88", + "mtu": "9100", + "pfc_asym": "off", + "speed": "100000", + "tpid": "0x8100" + }, + "CABLE_LENGTH|AZURE": { + "Ethernet0": "40m", + "Ethernet4": "40m", + "Ethernet8": "40m", + "Ethernet12": "40m", + "Ethernet16": "5m", + "Ethernet20": "5m" + }, + "VERSIONS|DATABASE": { + "VERSION": "version_2_0_2" + } +} diff --git a/tests/db_migrator_input/config_db/sample-t0-edgezoneagg-config-same-cable-input.json b/tests/db_migrator_input/config_db/sample-t0-edgezoneagg-config-same-cable-input.json new file mode 100644 index 0000000000..74b2e8e60e --- /dev/null +++ b/tests/db_migrator_input/config_db/sample-t0-edgezoneagg-config-same-cable-input.json @@ -0,0 +1,123 @@ +{ + "DEVICE_NEIGHBOR_METADATA|ARISTA01T1": { + "hwsku": "Arista-VM", + "mgmt_addr": "10.64.247.200", + "type": "EdgeZoneAggregator" + }, + "DEVICE_NEIGHBOR_METADATA|ARISTA02T1": { + "hwsku": "Arista-VM", + "mgmt_addr": "10.64.247.200", + "type": "EdgeZoneAggregator" + }, + "DEVICE_NEIGHBOR_METADATA|ARISTA03T1": { + "hwsku": "Arista-VM", + "mgmt_addr": "10.64.247.200", + "type": "EdgeZoneAggregator" + }, + "DEVICE_NEIGHBOR_METADATA|ARISTA04T1": { + "hwsku": "Arista-VM", + "mgmt_addr": "10.64.247.200", + "type": "EdgeZoneAggregator" + }, + "DEVICE_NEIGHBOR|Ethernet0": { + "name": "ARISTA01T1", + "port": "Ethernet1" + }, + "DEVICE_NEIGHBOR|Ethernet4": { + "name": "ARISTA02T1", + "port": "Ethernet1" + }, + "DEVICE_NEIGHBOR|Ethernet8": { + "name": "ARISTA03T1", + "port": "Ethernet1" + }, + "DEVICE_NEIGHBOR|Ethernet12": { + "name": "ARISTA04T1", + "port": "Ethernet1" + }, + "DEVICE_NEIGHBOR|Ethernet16": { + "name": "Servers1", + "port": "eth0" + }, + "DEVICE_NEIGHBOR|Ethernet20": { + "name": "Servers2", + "port": "eth0" + }, + "PORT|Ethernet0": { + "admin_status": "up", + "alias": "Ethernet1/1", + "description": "", + "index": "1", + "lanes": "77,78", + "mtu": "9100", + "pfc_asym": "off", + "speed": "100000", + "tpid": "0x8100" + }, + "PORT|Ethernet4": { + "admin_status": "up", + "alias": "Ethernet2/1", + "description": "", + "index": "2", + "lanes": "79,80", + "mtu": "9100", + "pfc_asym": "off", + "speed": "100000", + "tpid": "0x8100" + }, + "PORT|Ethernet8": { + "admin_status": "up", + "alias": "Ethernet3/1", + "description": "", + "index": "3", + "lanes": "81,82", + "mtu": "9100", + "pfc_asym": "off", + "speed": "100000", + "tpid": "0x8100" + }, + "PORT|Ethernet12": { + "admin_status": "up", + "alias": "Ethernet4/1", + "description": "", + "index": "4", + "lanes": "83,84", + "mtu": "9100", + "pfc_asym": "off", + "speed": "100000", + "tpid": "0x8100" + }, + "PORT|Ethernet16": { + "admin_status": "up", + "alias": "Ethernet5/1", + "description": "", + "index": "5", + "lanes": "85,86", + "mtu": "9100", + "pfc_asym": "off", + "speed": "100000", + "tpid": "0x8100" + }, + "PORT|Ethernet20": { + "admin_status": "up", + "alias": "Ethernet6/1", + "description": "", + "index": "6", + "lanes": "87,88", + "mtu": "9100", + "pfc_asym": "off", + "speed": "100000", + "tpid": "0x8100" + }, + "CABLE_LENGTH|AZURE": { + "Ethernet0": "300m", + "Ethernet4": "300m", + "Ethernet8": "300m", + "Ethernet12": "300m", + "Ethernet16": "300m", + "Ethernet20": "300m" + }, + "VERSIONS|DATABASE": { + "VERSION": "version_1_0_1" + } +} diff --git a/tests/db_migrator_input/config_db/sample-t0-edgezoneagg-config-same-cable-output.json b/tests/db_migrator_input/config_db/sample-t0-edgezoneagg-config-same-cable-output.json new file mode 100644 index 0000000000..4b7484f21e --- /dev/null +++ b/tests/db_migrator_input/config_db/sample-t0-edgezoneagg-config-same-cable-output.json @@ -0,0 +1,123 @@ +{ + "DEVICE_NEIGHBOR_METADATA|ARISTA01T1": { + "hwsku": "Arista-VM", + "mgmt_addr": "10.64.247.200", + "type": "EdgeZoneAggregator" + }, + "DEVICE_NEIGHBOR_METADATA|ARISTA02T1": { + "hwsku": "Arista-VM", + "mgmt_addr": "10.64.247.200", + "type": "EdgeZoneAggregator" + }, + "DEVICE_NEIGHBOR_METADATA|ARISTA03T1": { + "hwsku": "Arista-VM", + "mgmt_addr": "10.64.247.200", + "type": "EdgeZoneAggregator" + }, + "DEVICE_NEIGHBOR_METADATA|ARISTA04T1": { + "hwsku": "Arista-VM", + "mgmt_addr": "10.64.247.200", + "type": "EdgeZoneAggregator" + }, + "DEVICE_NEIGHBOR|Ethernet0": { + "name": "ARISTA01T1", + "port": "Ethernet1" + }, + "DEVICE_NEIGHBOR|Ethernet4": { + "name": "ARISTA02T1", + "port": "Ethernet1" + }, + "DEVICE_NEIGHBOR|Ethernet8": { + "name": "ARISTA03T1", + "port": "Ethernet1" + }, + "DEVICE_NEIGHBOR|Ethernet12": { + "name": "ARISTA04T1", + "port": "Ethernet1" + }, + "DEVICE_NEIGHBOR|Ethernet16": { + "name": "Servers1", + "port": "eth0" + }, + "DEVICE_NEIGHBOR|Ethernet20": { + "name": "Servers2", + "port": "eth0" + }, + "PORT|Ethernet0": { + "admin_status": "up", + "alias": "Ethernet1/1", + "description": "", + "index": "1", + "lanes": "77,78", + "mtu": "9100", + "pfc_asym": "off", + "speed": "100000", + "tpid": "0x8100" + }, + "PORT|Ethernet4": { + "admin_status": "up", + "alias": "Ethernet2/1", + "description": "", + "index": "2", + "lanes": "79,80", + "mtu": "9100", + "pfc_asym": "off", + "speed": "100000", + "tpid": "0x8100" + }, + "PORT|Ethernet8": { + "admin_status": "up", + "alias": "Ethernet3/1", + "description": "", + "index": "3", + "lanes": "81,82", + "mtu": "9100", + "pfc_asym": "off", + "speed": "100000", + "tpid": "0x8100" + }, + "PORT|Ethernet12": { + "admin_status": "up", + "alias": "Ethernet4/1", + "description": "", + "index": "4", + "lanes": "83,84", + "mtu": "9100", + "pfc_asym": "off", + "speed": "100000", + "tpid": "0x8100" + }, + "PORT|Ethernet16": { + "admin_status": "up", + "alias": "Ethernet5/1", + "description": "", + "index": "5", + "lanes": "85,86", + "mtu": "9100", + "pfc_asym": "off", + "speed": "100000", + "tpid": "0x8100" + }, + "PORT|Ethernet20": { + "admin_status": "up", + "alias": "Ethernet6/1", + "description": "", + "index": "6", + "lanes": "87,88", + "mtu": "9100", + "pfc_asym": "off", + "speed": "100000", + "tpid": "0x8100" + }, + "CABLE_LENGTH|AZURE": { + "Ethernet0": "300m", + "Ethernet4": "300m", + "Ethernet8": "300m", + "Ethernet12": "300m", + "Ethernet16": "300m", + "Ethernet20": "300m" + }, + "VERSIONS|DATABASE": { + "VERSION": "version_2_0_2" + } +} diff --git a/tests/db_migrator_test.py b/tests/db_migrator_test.py index 98ae12b2e7..1a8fe5cf5a 100644 --- a/tests/db_migrator_test.py +++ b/tests/db_migrator_test.py @@ -299,7 +299,7 @@ def test_global_dscp_to_tc_map_migrator(self): diff = DeepDiff(resulting_table, expected_table, ignore_order=True) assert not diff - + # Check port_qos_map|global is not generated on mellanox asic dbconnector.dedicated_dbs['CONFIG_DB'] = os.path.join(mock_db_path, 'config_db', 'qos_map_table_global_input') dbmgtr_mlnx = db_migrator.DBMigrator(None) @@ -376,3 +376,41 @@ def test_migrate_loopback_int(self): expected_keys = expected_appl_db.get_all(expected_appl_db.APPL_DB, key) diff = DeepDiff(resulting_keys, expected_keys, ignore_order=True) assert not diff + +class TestWarmUpgrade_T0_EdgeZoneAggregator(object): + @classmethod + def setup_class(cls): + os.environ['UTILITIES_UNIT_TESTING'] = "2" + + @classmethod + def teardown_class(cls): + os.environ['UTILITIES_UNIT_TESTING'] = "0" + dbconnector.dedicated_dbs['CONFIG_DB'] = None + + def test_warm_upgrade_t0_edgezone_aggregator_diff_cable_length(self): + dbconnector.dedicated_dbs['CONFIG_DB'] = os.path.join(mock_db_path, 'config_db', 'sample-t0-edgezoneagg-config-input') + import db_migrator + dbmgtr = db_migrator.DBMigrator(None) + dbmgtr.migrate() + dbconnector.dedicated_dbs['CONFIG_DB'] = os.path.join(mock_db_path, 'config_db', 'sample-t0-edgezoneagg-config-output') + expected_db = Db() + + resulting_table = dbmgtr.configDB.get_table('CABLE_LENGTH') + expected_table = expected_db.cfgdb.get_table('CABLE_LENGTH') + + diff = DeepDiff(resulting_table, expected_table, ignore_order=True) + assert not diff + + def test_warm_upgrade_t0_edgezone_aggregator_same_cable_length(self): + dbconnector.dedicated_dbs['CONFIG_DB'] = os.path.join(mock_db_path, 'config_db', 'sample-t0-edgezoneagg-config-same-cable-input') + import db_migrator + dbmgtr = db_migrator.DBMigrator(None) + dbmgtr.migrate() + dbconnector.dedicated_dbs['CONFIG_DB'] = os.path.join(mock_db_path, 'config_db', 'sample-t0-edgezoneagg-config-same-cable-output') + expected_db = Db() + + resulting_table = dbmgtr.configDB.get_table('CABLE_LENGTH') + expected_table = expected_db.cfgdb.get_table('CABLE_LENGTH') + + diff = DeepDiff(resulting_table, expected_table, ignore_order=True) + assert not diff