Skip to content

Commit

Permalink
Added a test case for fast reboot from other vendor NOS to SONiC.
Browse files Browse the repository at this point in the history
Details:
A new test case was added to fast reboot script.
This test case mimics a fast reboot from other vendor nos to SONiC, by flushing all DBs that
are part of the boot process, so the boot will be initiated with clean DBs as if it was booting from other nos.
  • Loading branch information
AharonMalkin committed Sep 15, 2022
1 parent bdd7663 commit ff5c90f
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 5 deletions.
7 changes: 6 additions & 1 deletion ansible/roles/test/files/ptftests/advanced-reboot.py
Original file line number Diff line number Diff line change
Expand Up @@ -1327,8 +1327,13 @@ def reboot_dut(self):
self.sender_thr.start()

self.log("Rebooting remote side")
if self.reboot_type != 'service-warm-restart':
if self.reboot_type != 'service-warm-restart' and self.test_params['other_vendor_flag'] is False:
stdout, stderr, return_code = self.dut_connection.execCommand("sudo " + self.reboot_type, timeout=30)

elif self.test_params['other_vendor_flag'] is True:
ignore_db_integrity_check = " -d"
stdout, stderr, return_code = self.dut_connection.execCommand("sudo " + self.reboot_type + ignore_db_integrity_check, timeout=30)

else:
self.restart_service()
return
Expand Down
9 changes: 7 additions & 2 deletions tests/common/fixtures/advanced_reboot.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import itertools
import json
import logging
import re
import pytest
import time
import os
Expand Down Expand Up @@ -605,6 +606,7 @@ def __runPtfRunner(self, rebootOper=None):
"dut_hostname" : self.rebootData['dut_hostname'],
"reboot_limit_in_seconds" : self.rebootLimit,
"reboot_type" : self.rebootType,
"other_vendor_flag" : self.other_vendor_nos,
"portchannel_ports_file" : self.rebootData['portchannel_interfaces_file'],
"vlan_ports_file" : self.rebootData['vlan_interfaces_file'],
"ports_file" : self.rebootData['ports_file'],
Expand Down Expand Up @@ -644,8 +646,11 @@ def __runPtfRunner(self, rebootOper=None):

self.__updateAndRestartArpResponder(rebootOper)


logger.info('Run advanced-reboot ReloadTest on the PTF host. TestCase: {}, sub-case: {}'.format(\
if rebootOper is None and self.other_vendor_nos is True:
logger.info('Run advanced-reboot ReloadTest on the PTF host. TestCase: {}, sub-case:'
' Reboot from other vendor nos'.format(self.request.node.name))
else:
logger.info('Run advanced-reboot ReloadTest on the PTF host. TestCase: {}, sub-case: {}'.format(\
self.request.node.name, str(rebootOper)))
result = ptf_runner(
self.ptfhost,
Expand Down
34 changes: 32 additions & 2 deletions tests/platform_tests/test_advanced_reboot.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
pytest.mark.disable_loganalyzer,
pytest.mark.topology('t0')
]
logger = logging.getLogger()

def pytest_generate_tests(metafunc):
input_sad_cases = metafunc.config.getoption("sad_case_list")
Expand All @@ -32,16 +33,31 @@ def pytest_generate_tests(metafunc):
def test_fast_reboot(request, get_advanced_reboot, verify_dut_health,
advanceboot_loganalyzer, capture_interface_counters):
'''
Fast reboot test case is run using advacned reboot test fixture
Fast reboot test case is run using advanced reboot test fixture
@param request: Spytest commandline argument
@param get_advanced_reboot: advanced reboot test fixture
'''
advancedReboot = get_advanced_reboot(rebootType='fast-reboot',\
advanceboot_loganalyzer=advanceboot_loganalyzer)
advanceboot_loganalyzer=advanceboot_loganalyzer, other_vendor_nos = False)
advancedReboot.runRebootTestcase()


@pytest.mark.usefixtures('get_advanced_reboot')
def test_fast_reboot_from_other_vendor(duthosts, rand_one_dut_hostname, request, get_advanced_reboot, verify_dut_health,
advanceboot_loganalyzer, capture_interface_counters):
'''
Fast reboot test from other vendor case is run using advanced reboot test fixture
@param request: Spytest commandline argument
@param get_advanced_reboot: advanced reboot test fixture
'''
duthost = duthosts[rand_one_dut_hostname]
advancedReboot = get_advanced_reboot(rebootType='fast-reboot', other_vendor_nos = True,\
advanceboot_loganalyzer=advanceboot_loganalyzer)
preboot_oper = flush_dbs(duthost)
advancedReboot.runRebootTestcase(preboot_setup = preboot_oper)

@pytest.mark.device_type('vs')
def test_warm_reboot(request, get_advanced_reboot, verify_dut_health,
advanceboot_loganalyzer, capture_interface_counters):
Expand Down Expand Up @@ -129,3 +145,17 @@ def test_cancelled_warm_reboot(request, add_fail_step_to_reboot, verify_dut_heal
add_fail_step_to_reboot('warm-reboot')
advancedReboot = get_advanced_reboot(rebootType='warm-reboot', allow_fail=True)
advancedReboot.runRebootTestcase()

def flush_dbs(duthost):
"""
This Function will flush all unnecessary databases, to mimic reboot from other vendor
"""
logger.info('Flushing databases from switch')
db_dic = { 0: 'Application DB',
1: 'ASIC DB',
2: 'Counters DB',
5: 'Flex Counters DB',
6: 'State DB'
}
for db in db_dic.keys():
duthost.shell('redis-cli -n {} flushdb'.format(db))

0 comments on commit ff5c90f

Please sign in to comment.