Skip to content

Commit

Permalink
[db_migrator] Set correct CURRENT_VERSION, extend UT
Browse files Browse the repository at this point in the history
Signed-off-by: vadymhlushko-mlnx <vadymh@nvidia.com>
  • Loading branch information
vadymhlushko-mlnx committed Jul 11, 2023
1 parent daf5460 commit 5099e74
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 13 deletions.
21 changes: 14 additions & 7 deletions scripts/db_migrator.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def __init__(self, namespace, socket=None):
none-zero values.
build: sequentially increase within a minor version domain.
"""
self.CURRENT_VERSION = 'version_4_0_2'
self.CURRENT_VERSION = 'version_4_0_3'

self.TABLE_NAME = 'VERSIONS'
self.TABLE_KEY = 'DATABASE'
Expand Down Expand Up @@ -906,14 +906,9 @@ def version_3_0_5(self):
def version_3_0_6(self):
"""
Version 3_0_6
This is the latest version for 202211 branch
"""

log.log_info('Handling version_3_0_6')

if self.stateDB.keys(self.stateDB.STATE_DB, "FAST_REBOOT|system"):
self.migrate_config_db_flex_counter_delay_status()

self.set_version('version_4_0_0')
return 'version_4_0_0'

Expand Down Expand Up @@ -947,9 +942,21 @@ def version_4_0_1(self):
def version_4_0_2(self):
"""
Version 4_0_2.
This is the latest version for master branch
"""
log.log_info('Handling version_4_0_2')

if self.stateDB.keys(self.stateDB.STATE_DB, "FAST_REBOOT|system"):
self.migrate_config_db_flex_counter_delay_status()

self.set_version('version_4_0_3')
return 'version_4_0_3'

def version_4_0_3(self):
"""
Version 4_0_3.
This is the latest version for 202211 and master branches
"""
log.log_info('Handling version_4_0_3')
return None

def get_version(self):
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"VERSIONS|DATABASE": {
"VERSION": "version_3_0_6"
"VERSION": "version_4_0_3"
},
"FLEX_COUNTER_TABLE|ACL": {
"FLEX_COUNTER_STATUS": "true",
Expand Down
10 changes: 5 additions & 5 deletions tests/db_migrator_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -590,7 +590,7 @@ def test_warm_upgrade_t0_edgezone_aggregator_same_cable_length(self):
assert not diff


class TestFastUpgrade_to_3_0_6(object):
class TestFastUpgrade_to_4_0_3(object):
@classmethod
def setup_class(cls):
os.environ['UTILITIES_UNIT_TESTING'] = "2"
Expand All @@ -613,14 +613,14 @@ def check_config_db(self, result, expected):
for table in self.config_db_tables_to_verify:
assert result.get_table(table) == expected.get_table(table)

def test_fast_reboot_upgrade_to_3_0_6(self):
db_before_migrate = 'cross_branch_upgrade_to_3_0_6_input'
db_after_migrate = 'cross_branch_upgrade_to_3_0_6_expected'
def test_fast_reboot_upgrade_to_4_0_3(self):
db_before_migrate = 'cross_branch_upgrade_to_4_0_3_input'
db_after_migrate = 'cross_branch_upgrade_to_4_0_3_expected'
device_info.get_sonic_version_info = get_sonic_version_info_mlnx
db = self.mock_dedicated_config_db(db_before_migrate)
import db_migrator
dbmgtr = db_migrator.DBMigrator(None)
dbmgtr.migrate()
expected_db = self.mock_dedicated_config_db(db_after_migrate)
assert not self.check_config_db(dbmgtr.configDB, expected_db.cfgdb)

assert dbmgtr.CURRENT_VERSION == expected_db.cfgdb.get_entry('VERSIONS', 'DATABASE')['VERSION']

0 comments on commit 5099e74

Please sign in to comment.