-
Notifications
You must be signed in to change notification settings - Fork 1k
[SRv6] Add SRv6 control plane test case #16516
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 all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
56a38d0
add SRv6 control plane test case
BYGX-wcr 2b021e2
add topo marker and make the test case compatible with multi-asic dev…
BYGX-wcr 0f9841b
fix format errors
BYGX-wcr 4f828be
update the test case to adapt to the new CONFIG_DB schema and enhance…
BYGX-wcr 23e6308
fix extra long lines
BYGX-wcr 3dc76a6
remove trailing white spaces
BYGX-wcr ac58914
add t1 in topo marker as well
BYGX-wcr 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,115 @@ | ||
| import time | ||
| import pytest | ||
|
|
||
| pytestmark = [ | ||
| pytest.mark.topology('t0', 't1') | ||
| ] | ||
|
|
||
| WAIT_TIME = 5 | ||
|
|
||
|
|
||
| def test_uN_config(duthosts, enum_frontend_dut_hostname, enum_rand_one_asic_index): | ||
| duthost = duthosts[enum_frontend_dut_hostname] | ||
| asic_index = enum_rand_one_asic_index | ||
|
|
||
| if duthost.is_multi_asic: | ||
| cli_options = " -n " + duthost.get_namespace_from_asic_id(asic_index) | ||
| else: | ||
| cli_options = '' | ||
|
|
||
| sonic_db_cli = "sonic-db-cli" + cli_options | ||
| vtysh_shell = "vtysh" + cli_options | ||
|
|
||
| # add a locator configuration entry | ||
| duthost.command(sonic_db_cli + " CONFIG_DB HSET SRV6_MY_LOCATORS\\|loc1 prefix fcbb:bbbb:1::") | ||
| # add a uN sid configuration entry | ||
| duthost.command(sonic_db_cli + | ||
| " CONFIG_DB HSET SRV6_MY_SIDS\\|loc1\\|fcbb:bbbb:1::/48 action uN decap_dscp_mode pipe") | ||
| time.sleep(WAIT_TIME) | ||
|
|
||
| frr_config = duthost.command(vtysh_shell + " -c \"show running-config\"")["stdout"] | ||
|
|
||
| # verify that bgpcfgd generates FRR config correctly | ||
| assert "locator loc1" in frr_config | ||
| assert "sid fcbb:bbbb:1::/48 locator loc1 behavior uN" in frr_config | ||
|
|
||
| appl_db_my_sids = duthost.command(sonic_db_cli + " APPL_DB keys SRV6_MY_SID_TABLE*")["stdout"] | ||
|
|
||
| # verify that APPL_DB gets programmed by FRR correctly | ||
| assert "SRV6_MY_SID_TABLE:32:16:0:0:fcbb:bbbb:1::" in appl_db_my_sids | ||
| assert "un" == duthost.command(sonic_db_cli + | ||
| " APPL_DB hget SRV6_MY_SID_TABLE:32:16:0:0:fcbb:bbbb:1:: action")["stdout"] | ||
|
|
||
| # delete the configurations | ||
| duthost.command(sonic_db_cli + " CONFIG_DB DEL SRV6_MY_LOCATORS\\|loc1") | ||
| duthost.command(sonic_db_cli + " CONFIG_DB DEL SRV6_MY_SIDS\\|loc1\\|fcbb:bbbb:1::/48") | ||
| time.sleep(WAIT_TIME) | ||
|
|
||
| frr_config = duthost.command(vtysh_shell + " -c \"show running-config\"")["stdout"] | ||
|
|
||
| # verify that bgpcfgd deletes relevant FRR config | ||
| assert "locator loc1" not in frr_config | ||
| assert "sid fcbb:bbbb:1::/48 locator loc1 behavior uN" not in frr_config | ||
|
|
||
| appl_db_my_sids = duthost.command(sonic_db_cli + " APPL_DB keys SRV6_MY_SID_TABLE*")["stdout"] | ||
|
|
||
| # verify that the APPL_DB entry gets cleaned correctly | ||
| assert "SRV6_MY_SID_TABLE:32:16:0:0:fcbb:bbbb:1::" not in appl_db_my_sids | ||
|
|
||
|
|
||
| def test_uDT46_config(duthosts, enum_frontend_dut_hostname, enum_rand_one_asic_index): | ||
| duthost = duthosts[enum_frontend_dut_hostname] | ||
| asic_index = enum_rand_one_asic_index | ||
|
|
||
| if duthost.is_multi_asic: | ||
| cli_options = " -n " + duthost.get_namespace_from_asic_id(asic_index) | ||
| else: | ||
| cli_options = '' | ||
|
|
||
| sonic_db_cli = "sonic-db-cli" + cli_options | ||
| vtysh_shell = "vtysh" + cli_options | ||
|
|
||
| # add Vrf1 config | ||
| duthost.command("config vrf add Vrf1") | ||
| duthost.command("sysctl -w net.vrf.strict_mode=1") | ||
|
|
||
| # add a locator configuration entry | ||
| duthost.command(sonic_db_cli + " CONFIG_DB HSET SRV6_MY_LOCATORS\\|loc1 prefix fcbb:bbbb:1::") | ||
| # add a uDT46 sid configuration entry | ||
| duthost.command(sonic_db_cli + " CONFIG_DB HSET SRV6_MY_SIDS\\|loc1\\|fcbb:bbbb:1:2::/64 \ | ||
| action uDT46 decap_vrf Vrf1 decap_dscp_mode uniform") | ||
| time.sleep(WAIT_TIME) | ||
|
|
||
| frr_config = duthost.command(vtysh_shell + " -c \"show running-config\"")["stdout"] | ||
|
|
||
| # verify that bgpcfgd generates FRR config correctly | ||
| assert "locator loc1" in frr_config | ||
| assert "sid fcbb:bbbb:1:2::/64 locator loc1 behavior uDT46 vrf Vrf1" in frr_config | ||
|
|
||
| appl_db_my_sids = duthost.command(sonic_db_cli + " APPL_DB keys SRV6_MY_SID_TABLE*")["stdout"] | ||
|
|
||
| # verify that APPL_DB gets programmed by FRR correctly | ||
| assert "SRV6_MY_SID_TABLE:32:16:16:0:fcbb:bbbb:1:2::" in appl_db_my_sids | ||
| assert "udt46" == duthost.command(sonic_db_cli + | ||
| " APPL_DB hget SRV6_MY_SID_TABLE:32:16:16:0:fcbb:bbbb:1:2:: action")["stdout"] | ||
| assert "Vrf1" == duthost.command(sonic_db_cli + | ||
| " APPL_DB hget SRV6_MY_SID_TABLE:32:16:16:0:fcbb:bbbb:1:2:: vrf")["stdout"] | ||
|
|
||
| # delete the configurations | ||
| duthost.command(sonic_db_cli + " CONFIG_DB DEL SRV6_MY_LOCATORS\\|loc1") | ||
| duthost.command(sonic_db_cli + " CONFIG_DB DEL SRV6_MY_SIDS\\|loc1\\|fcbb:bbbb:1:2::/64") | ||
| time.sleep(WAIT_TIME) | ||
|
|
||
| frr_config = duthost.command(vtysh_shell + " -c \"show running-config\"")["stdout"] | ||
|
|
||
| # verify that bgpcfgd deletes relevant FRR config | ||
| assert "locator loc1" not in frr_config | ||
| assert "sid fcbb:bbbb:1:2::/64 locator loc1 behavior uDT46 vrf Vrf1" not in frr_config | ||
|
|
||
| appl_db_my_sids = duthost.command(sonic_db_cli + " APPL_DB keys SRV6_MY_SID_TABLE*")["stdout"] | ||
|
|
||
| # verify that the APPL_DB entry gets cleaned correctly | ||
| assert "SRV6_MY_SID_TABLE:32:16:16:0:fcbb:bbbb:1:2::" not in appl_db_my_sids | ||
|
|
||
| # delete the Vrf config | ||
| duthost.command("config vrf del Vrf1") | ||
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.
for sonic testing do we need this >
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.
yes, without this setting. uDT46 SID will not get programmed into kernel and APPL_DB
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.
Yes, this is needed.
‑ By default, FRR tries to install all routes in the Linux kernel before installing in SONiC
‑ In order to have the SID programmed into SONiC APPL DB, they must be successfully programmed in the Linux Kernel first