Skip to content

Commit

Permalink
Merge branch '202305' into 202305
Browse files Browse the repository at this point in the history
  • Loading branch information
yxieca authored Dec 18, 2023
2 parents 0761f04 + 1a59a6d commit 758ca0b
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 83 deletions.
24 changes: 0 additions & 24 deletions scripts/db_migrator.py
Original file line number Diff line number Diff line change
Expand Up @@ -621,28 +621,6 @@ def migrate_feature_timer(self):
config.pop('has_timer')
self.configDB.set_entry('FEATURE', feature, config)

def migrate_route_table(self):
"""
Handle route table migration. Migrations handled:
1. 'weight' attr in ROUTE object was introduced 202205 onwards.
Upgrade from older branch to 202205 will require this 'weight' attr to be added explicitly
2. 'protocol' attr in ROUTE introduced in 202305 onwards.
WarmRestartHelper reconcile logic requires to have "protocol" field in the old dumped ROUTE_TABLE.
"""
route_table = self.appDB.get_table("ROUTE_TABLE")
for route_prefix, route_attr in route_table.items():
if type(route_prefix) == tuple:
# IPv6 route_prefix is returned from db as tuple
route_key = "ROUTE_TABLE:" + ":".join(route_prefix)
else:
# IPv4 route_prefix is returned from db as str
route_key = "ROUTE_TABLE:{}".format(route_prefix)

if 'weight' not in route_attr:
self.appDB.set(self.appDB.APPL_DB, route_key, 'weight','')

if 'protocol' not in route_attr:
self.appDB.set(self.appDB.APPL_DB, route_key, 'protocol', '')

def migrate_routing_config_mode(self):
# DEVICE_METADATA - synchronous_mode entry
Expand Down Expand Up @@ -1096,8 +1074,6 @@ def common_migration_ops(self):
else:
log.log_notice("Asic Type: {}, Hwsku: {}".format(self.asic_type, self.hwsku))

self.migrate_route_table()

# Updating edgezone aggregator cable length config for T0 devices
self.update_edgezone_aggregator_config()
# update FRR config mode based on minigraph parser on target image
Expand Down
14 changes: 0 additions & 14 deletions tests/db_migrator_input/appl_db/routes_migrate_expected.json

This file was deleted.

10 changes: 0 additions & 10 deletions tests/db_migrator_input/appl_db/routes_migrate_input.json

This file was deleted.

35 changes: 0 additions & 35 deletions tests/db_migrator_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -660,41 +660,6 @@ def test_migrate_loopback_int(self):
diff = DeepDiff(resulting_keys, expected_keys, ignore_order=True)
assert not diff

class TestWarmUpgrade_without_required_attributes(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
dbconnector.dedicated_dbs['APPL_DB'] = None

def test_migrate_weights_protocol_for_nexthops(self):
dbconnector.dedicated_dbs['CONFIG_DB'] = os.path.join(mock_db_path, 'config_db', 'routes_migrate_input')
dbconnector.dedicated_dbs['APPL_DB'] = os.path.join(mock_db_path, 'appl_db', 'routes_migrate_input')

import db_migrator
dbmgtr = db_migrator.DBMigrator(None)
dbmgtr.migrate()
dbconnector.dedicated_dbs['APPL_DB'] = os.path.join(mock_db_path, 'appl_db', 'routes_migrate_expected')
expected_db = Db()

# verify migrated appDB
expected_appl_db = SonicV2Connector(host='127.0.0.1')
expected_appl_db.connect(expected_appl_db.APPL_DB)
expected_keys = expected_appl_db.keys(expected_appl_db.APPL_DB, "ROUTE_TABLE:*")
expected_keys.sort()
resulting_keys = dbmgtr.appDB.keys(dbmgtr.appDB.APPL_DB, "ROUTE_TABLE:*")
resulting_keys.sort()
assert expected_keys == resulting_keys
for key in expected_keys:
resulting_keys = dbmgtr.appDB.get_all(dbmgtr.appDB.APPL_DB, key)
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):
Expand Down

0 comments on commit 758ca0b

Please sign in to comment.