-
Notifications
You must be signed in to change notification settings - Fork 692
[vs tests]: Add mirror session warm reboot test #1130
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
Closed
Closed
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
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 |
|---|---|---|
|
|
@@ -234,7 +234,121 @@ def ping_new_ips(dvs): | |
| dvs.runcmd(['sh', '-c', "ping -c 1 -W 0 -q {}.0.0.{} > /dev/null 2>&1".format(i*4,j+NUM_NEIGH_PER_INTF+2)]) | ||
| dvs.runcmd(['sh', '-c', "ping6 -c 1 -W 0 -q {}00::{} > /dev/null 2>&1".format(i*4,j+NUM_NEIGH_PER_INTF+2)]) | ||
|
|
||
|
|
||
| def create_mirror_session(dvs, name, src, dst, gre, dscp, ttl, queue): | ||
| """ | ||
| Creates a mirror session. This method will wait 1 second to allow | ||
| redis updates to propagate. | ||
| """ | ||
| tbl = swsscommon.Table(dvs.cdb, "MIRROR_SESSION") | ||
| fvs = swsscommon.FieldValuePairs([("src_ip", src), | ||
| ("dst_ip", dst), | ||
| ("gre_type", gre), | ||
| ("dscp", dscp), | ||
| ("ttl", ttl), | ||
| ("queue", queue)]) | ||
| tbl.set(name, fvs) | ||
| time.sleep(1) | ||
|
|
||
|
|
||
| def remove_mirror_session(dvs, name): | ||
| """ | ||
| Deletes a mirror session. This method will wait 1 second to allow | ||
| redis updates to propagate. | ||
| """ | ||
| tbl = swsscommon.Table(dvs.cdb, "MIRROR_SESSION") | ||
| tbl._del(name) | ||
| time.sleep(1) | ||
|
|
||
|
|
||
| def get_mirror_session_state(dvs, name): | ||
| """ | ||
| Gets the current state of a mirror session. This method will cause | ||
| your test to fail if the given mirror session does not exist. | ||
|
|
||
| Example output: | ||
| { | ||
| "src_ip": "10.0.0.0", | ||
| "dst_ip": "192.168.1.1", | ||
| ... | ||
| } | ||
| """ | ||
| tbl = swsscommon.Table(dvs.sdb, "MIRROR_SESSION_TABLE") | ||
| (status, fvs) = tbl.get(name) | ||
| assert status | ||
| assert len(fvs) > 0 | ||
| return {fv[0]: fv[1] for fv in fvs} | ||
|
|
||
|
|
||
| class TestWarmReboot(object): | ||
| def test_MirrorSessionWarmReboot(self, dvs, testlog): | ||
| """ | ||
| This test verifies that mirror session monitor ports are not | ||
| changed after warm reboot. | ||
| """ | ||
|
|
||
| # Setup the virtual switch | ||
| dvs.setup_db() | ||
| dvs.runcmd("config warm_restart enable swss") | ||
|
|
||
| # Setup neighbors for the test | ||
| dvs.set_interface_status("Ethernet12", "up") | ||
| dvs.set_interface_status("Ethernet16", "up") | ||
| dvs.set_interface_status("Ethernet20", "up") | ||
|
|
||
| dvs.add_ip_address("Ethernet12", "10.0.0.0/31") | ||
| dvs.add_ip_address("Ethernet16", "11.0.0.0/31") | ||
| dvs.add_ip_address("Ethernet20", "12.0.0.0/31") | ||
|
|
||
| dvs.add_neighbor("Ethernet12", "10.0.0.1", "02:04:06:08:10:12") | ||
| dvs.add_neighbor("Ethernet16", "11.0.0.1", "03:04:06:08:10:12") | ||
| dvs.add_neighbor("Ethernet20", "12.0.0.1", "04:04:06:08:10:12") | ||
|
|
||
| # Set test_session1 monitor port as Ethernet12 | ||
| dvs.add_route("2.2.2.2", "10.0.0.1") | ||
| create_mirror_session(dvs, "test_session1", "1.1.1.1", "2.2.2.2", "0x6558", "8", "100", "0") | ||
|
|
||
| # Set test_session2 monitor port as Ethernet16 | ||
| dvs.update_route_ecmp("2.2.2.2", ["11.0.0.1", "10.0.0.1"]) | ||
| create_mirror_session(dvs, "test_session2", "1.1.1.1", "2.2.2.2", "0x6558", "8", "100", "0") | ||
|
|
||
| # Set test_session3 monitor port as Ethernet20 | ||
| dvs.update_route_ecmp("2.2.2.2", ["12.0.0.1", "11.0.0.1", "10.0.0.1"]) | ||
| create_mirror_session(dvs, "test_session3", "1.1.1.1", "2.2.2.2", "0x6558", "8", "100", "0") | ||
|
|
||
| test_session1_mp = get_mirror_session_state(dvs, "test_session1")["monitor_port"] | ||
| test_session2_mp = get_mirror_session_state(dvs, "test_session2")["monitor_port"] | ||
| test_session3_mp = get_mirror_session_state(dvs, "test_session3")["monitor_port"] | ||
|
|
||
| # Perform the warm reboot | ||
| dvs.stop_swss() | ||
| dvs.start_swss() | ||
| time.sleep(5) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is sleep 5 seconds enough? You could polling "show warm_restart state" and wait until orchagent is reconciled. That would take lot longer than 5 seconds though. |
||
|
|
||
| # Verify that all monitor ports are still the same after warm reboot | ||
| assert test_session1_mp == get_mirror_session_state(dvs, "test_session1")["monitor_port"] | ||
| assert test_session2_mp == get_mirror_session_state(dvs, "test_session2")["monitor_port"] | ||
| assert test_session3_mp == get_mirror_session_state(dvs, "test_session3")["monitor_port"] | ||
|
|
||
| # Teardown the mirror sessions and routes | ||
| remove_mirror_session(dvs, "test_session1") | ||
| remove_mirror_session(dvs, "test_session2") | ||
| remove_mirror_session(dvs, "test_session3") | ||
|
|
||
| dvs.remove_route("2.2.2.2") | ||
|
|
||
| dvs.remove_neighbor("Ethernet12", "10.0.0.1") | ||
| dvs.remove_neighbor("Ethernet16", "11.0.0.1") | ||
| dvs.remove_neighbor("Ethernet20", "12.0.0.1") | ||
|
|
||
| dvs.remove_ip_address("Ethernet12", "10.0.0.0/31") | ||
| dvs.remove_ip_address("Ethernet16", "11.0.0.0/31") | ||
| dvs.remove_ip_address("Ethernet20", "12.0.0.0/31") | ||
|
|
||
| dvs.set_interface_status("Ethernet12", "down") | ||
| dvs.set_interface_status("Ethernet16", "down") | ||
| dvs.set_interface_status("Ethernet20", "down") | ||
|
|
||
| def test_PortSyncdWarmRestart(self, dvs, testlog): | ||
|
|
||
| conf_db = swsscommon.DBConnector(swsscommon.CONFIG_DB, dvs.redis_sock, 0) | ||
|
|
@@ -325,7 +439,6 @@ def test_PortSyncdWarmRestart(self, dvs, testlog): | |
| intf_tbl._del("Ethernet20") | ||
| time.sleep(2) | ||
|
|
||
|
|
||
| def test_VlanMgrdWarmRestart(self, dvs, testlog): | ||
|
|
||
| conf_db = swsscommon.DBConnector(swsscommon.CONFIG_DB, dvs.redis_sock, 0) | ||
|
|
@@ -815,7 +928,6 @@ def test_swss_neighbor_syncup(self, dvs, testlog): | |
| intf_tbl._del("{}".format(intfs[1])) | ||
| time.sleep(2) | ||
|
|
||
|
|
||
| # TODO: The condition of warm restart readiness check is still under discussion. | ||
| def test_OrchagentWarmRestartReadyCheck(self, dvs, testlog): | ||
|
|
||
|
|
||
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.
I suggest moving warm restart setting close to swss restart.