-
Notifications
You must be signed in to change notification settings - Fork 1k
Check if BGP has Loopback0 IP as its router ID #8576
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 14 commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
7e8dd58
Add bgp router id check to sanity_check
kellyyeh 66c8807
Revert "Add bgp router id check to sanity_check"
kellyyeh fc456fa
Add __checkBgpRouterId in advanced_reboot test
kellyyeh aa0132b
Update advanced_reboot.py
kellyyeh 02e6b18
Update log
kellyyeh ca97b7f
Merge branch 'sonic-net:master' into router-id
kellyyeh 0e4d7c2
Retrieve bgp id router through json
kellyyeh 4fb3ee9
Merge branch 'router-id' of github.com:kellyyeh/sonic-mgmt into route…
kellyyeh 0e811f3
Handle return
kellyyeh fc6613e
Fix pre-commit
kellyyeh 7187b81
Update
kellyyeh 80929f0
Address comment
kellyyeh e544d29
precommit
kellyyeh f572a85
Merge branch 'sonic-net:master' into router-id
kellyyeh bcba008
Make check_bgp_router_id common
kellyyeh d238add
Merge branch 'router-id' of github.com:kellyyeh/sonic-mgmt into route…
kellyyeh a1702fb
Fix pre-commit
kellyyeh d3a0cf4
Fix pre-commit
kellyyeh d175a66
Add missing parameter
kellyyeh 2f2a6b4
Skip on multi-asic
kellyyeh File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -146,7 +146,7 @@ def _check_interfaces_on_dut(*args, **kwargs): | |
|
|
||
|
|
||
| @pytest.fixture(scope="module") | ||
| def check_bgp(duthosts): | ||
| def check_bgp(duthosts, tbinfo): | ||
| init_result = {"failed": False, "check_item": "bgp"} | ||
|
|
||
| def _check(*args, **kwargs): | ||
|
|
@@ -206,6 +206,21 @@ def _check_bgp_status_helper(): | |
| check_result['failed'] = False | ||
| return not check_result['failed'] | ||
|
|
||
| def _check_bgp_router_id(tbinfo): | ||
| duthost = kwargs['node'] | ||
|
||
| mgFacts = duthost.get_extended_minigraph_facts(tbinfo) | ||
| check_bgp_router_id_cmd = r'vtysh -c "show ip bgp summary json"' | ||
| bgp_summary = duthost.shell(check_bgp_router_id_cmd, module_ignore_errors=True) | ||
| bgp_summary_json = json.loads(bgp_summary['stdout']) | ||
| router_id = str(bgp_summary_json['ipv4Unicast']['routerId']) | ||
| loopback0 = str(mgFacts['minigraph_lo_interfaces'][0]['addr']) | ||
| if router_id == loopback0: | ||
| logger.info("BGP router identifier: %s == Loopback0 address %s" % (router_id, loopback0)) | ||
| return True | ||
| else: | ||
| logger.info("BGP router identifier %s != Loopback0 address %s" % (router_id, loopback0)) | ||
| return False | ||
|
|
||
| logger.info("Checking bgp status on host %s ..." % dut.hostname) | ||
| check_result = {"failed": False, "check_item": "bgp", "host": dut.hostname} | ||
|
|
||
|
|
@@ -230,6 +245,10 @@ def _check_bgp_status_helper(): | |
| else: | ||
| logger.info('No BGP neighbors are down on %s' % dut.hostname) | ||
|
|
||
| if not wait_until(timeout, interval, 0, _check_bgp_router_id, tbinfo): | ||
| check_result['failed'] = True | ||
| logger.info("Failed to verify BGP router identifier is Loopback0 address on %s" % dut.hostname) | ||
|
|
||
| logger.info("Done checking bgp status on %s" % dut.hostname) | ||
| results[dut.hostname] = check_result | ||
|
|
||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Possible exception here if stdout is not in json format for some reason.