-
Notifications
You must be signed in to change notification settings - Fork 1k
[IPv6 only]Fixture to convert/revert the mgmt-ip to IPv6 olny, enhance connection plugin #11957
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
yejianquan
merged 1 commit into
sonic-net:master
from
yejianquan:jianquanye/support_ipv6_only
Mar 14, 2024
Merged
Changes from all commits
Commits
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
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 |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| import pytest | ||
|
|
||
| from tests.common.fixtures.duthost_utils import convert_and_restore_config_db_to_ipv6_only # noqa F401 | ||
| from tests.common.helpers.assertions import pytest_assert | ||
|
|
||
| pytestmark = [ | ||
| pytest.mark.topology('any'), | ||
| pytest.mark.device_type('vs') | ||
| ] | ||
|
|
||
|
|
||
| def test_bgp_facts_ipv6_only(duthosts, enum_frontend_dut_hostname, enum_asic_index, | ||
| convert_and_restore_config_db_to_ipv6_only): # noqa F811 | ||
| """compare the bgp facts between observed states and target state""" | ||
|
|
||
| duthost = duthosts[enum_frontend_dut_hostname] | ||
|
|
||
| bgp_facts = duthost.bgp_facts(instance_id=enum_asic_index)['ansible_facts'] | ||
| namespace = duthost.get_namespace_from_asic_id(enum_asic_index) | ||
| config_facts = duthost.config_facts(host=duthost.hostname, source="running", namespace=namespace)['ansible_facts'] | ||
| sonic_db_cmd = "sonic-db-cli {}".format("-n " + namespace if namespace else "") | ||
| for k, v in list(bgp_facts['bgp_neighbors'].items()): | ||
| # Verify bgp sessions are established | ||
| assert v['state'] == 'established' | ||
| # Verify local ASNs in bgp sessions | ||
| assert v['local AS'] == int(config_facts['DEVICE_METADATA']['localhost']['bgp_asn'].encode().decode("utf-8")) | ||
| # Check bgpmon functionality by validate STATE DB contains this neighbor as well | ||
| state_fact = duthost.shell('{} STATE_DB HGET "NEIGH_STATE_TABLE|{}" "state"' | ||
| .format(sonic_db_cmd, k), module_ignore_errors=False)['stdout_lines'] | ||
| peer_type = duthost.shell('{} STATE_DB HGET "NEIGH_STATE_TABLE|{}" "peerType"' | ||
| .format(sonic_db_cmd, k), | ||
| module_ignore_errors=False)['stdout_lines'] | ||
| assert state_fact[0] == "Established" | ||
| assert peer_type[0] == "i-BGP" if v['remote AS'] == v['local AS'] else "e-BGP" | ||
|
|
||
| # In multi-asic, would have 'BGP_INTERNAL_NEIGHBORS' and possibly no 'BGP_NEIGHBOR' (ebgp) neighbors. | ||
| nbrs_in_cfg_facts = {} | ||
| nbrs_in_cfg_facts.update(config_facts.get('BGP_NEIGHBOR', {})) | ||
| nbrs_in_cfg_facts.update(config_facts.get('BGP_INTERNAL_NEIGHBOR', {})) | ||
| # In VoQ Chassis, we would have BGP_VOQ_CHASSIS_NEIGHBOR as well. | ||
| nbrs_in_cfg_facts.update(config_facts.get('BGP_VOQ_CHASSIS_NEIGHBOR', {})) | ||
| for k, v in list(nbrs_in_cfg_facts.items()): | ||
| # Compare the bgp neighbors name with config db bgp neighbors name | ||
| assert v['name'] == bgp_facts['bgp_neighbors'][k]['description'] | ||
| # Compare the bgp neighbors ASN with config db | ||
| assert int(v['asn'].encode().decode("utf-8")) == bgp_facts['bgp_neighbors'][k]['remote AS'] | ||
|
|
||
|
|
||
| def test_show_features_ipv6_only(duthosts, enum_dut_hostname, convert_and_restore_config_db_to_ipv6_only): # noqa F811 | ||
| """Verify show features command output against CONFIG_DB | ||
| """ | ||
|
|
||
| duthost = duthosts[enum_dut_hostname] | ||
| features_dict, succeeded = duthost.get_feature_status() | ||
| pytest_assert(succeeded, "failed to obtain feature status") | ||
| for cmd_key, cmd_value in list(features_dict.items()): | ||
| redis_value = duthost.shell('/usr/bin/redis-cli -n 4 --raw hget "FEATURE|{}" "state"' | ||
| .format(cmd_key), module_ignore_errors=False)['stdout'] | ||
| pytest_assert(redis_value.lower() == cmd_value.lower(), | ||
| "'{}' is '{}' which does not match with config_db".format(cmd_key, cmd_value)) |
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.
Uh oh!
There was an error while loading. Please reload this page.