-
Notifications
You must be signed in to change notification settings - Fork 746
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
Create a test case for testing L2 configuration. #14714
Conversation
The pre-commit check detected issues in the files touched by this pull request. Detailed pre-commit check results: To run the pre-commit checks locally, you can follow below steps:
|
The pre-commit check detected issues in the files touched by this pull request. Detailed pre-commit check results: To run the pre-commit checks locally, you can follow below steps:
|
tests/l2/test_l2_configure.py
Outdated
" | sudo config load /dev/stdin -y".format(hwsku) | ||
duthost.shell(l2_cfg) | ||
duthost.shell("sudo config qos reload --no-dynamic-buffer") | ||
time.sleep(30) |
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.
We should try best to remove sleeping for fixed time:
- if too long, waste overall test runtime
- if too short, test may be flaky on some weaker hwsku
Could you use function "wait_until" for a special signal? You may use redis-cli monitor
to observe what is really happening.
Or maybe you do not need to sleep at all? #Closed
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 removed this. This is replaced by a reboot (which is one step in the expected test case).
tests/l2/test_l2_configure.py
Outdated
# Restore from L2 | ||
logger.info("Restoring DUT into L3 mode.") | ||
duthost.shell("sudo config reload -y") | ||
time.sleep(30) |
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.
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.
Removed. config_reload api resolve this issue.
tests/l2/test_l2_configure.py
Outdated
new_vlan = duthost.shell("show vlan config")["stdout"] | ||
new_int = duthost.shell("show int status")["stdout"] | ||
pytest_expect(orig_vlan != new_vlan, "vlan config not updated.") | ||
pytest_expect(orig_int != new_int, "interface status not updated.") |
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.
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.
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.
Sorry please take this commit as a draft. I updated the test expectation to enforce the expectation you said. Please take a look.
Step 3 is not included in this test.
|
tests/l2/test_l2_configure.py
Outdated
duthost.shell(l2_cfg) | ||
duthost.shell("sudo config qos reload --no-dynamic-buffer") | ||
duthost.shell("sudo config save -y") | ||
reboot(duthost, localhost) |
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.
After cold rebooting, the image version remains unchanged, and the db_migrator will not function. Consequently, the CONFIG_DB will remain the same.
Therefore, this test cannot verify our bug fix.
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.
Updated test. Please take a look.
tests/l2/test_l2_configure.py
Outdated
|
||
# Restore from L2 | ||
logger.info("Restoring DUT into L3 mode.") | ||
duthost.shell("sudo config reload -y") |
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.
we have config_reload
API to guarantee some critical service is up
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.
Done.
tests/l2/test_l2_configure.py
Outdated
logger.info("Restoring DUT into L3 mode.") | ||
duthost.shell("sudo config reload /tmp/orig_config.json -y") | ||
duthost.shell("sudo config save -y") | ||
time.sleep(30) |
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.
Same as the above comment.
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.
Done.
tests/l2/test_l2_configure.py
Outdated
logger.info("Checking vlan and interface facts.") | ||
new_vlan = duthost.shell("show vlan config")["stdout"] | ||
new_int = duthost.shell("show int status")["stdout"] | ||
pytest_expect(orig_vlan != new_vlan, "vlan config not updated.") |
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.
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.
Done.
tests/common/helpers/assertions.py
Outdated
@@ -9,6 +9,16 @@ def pytest_assert(condition, message=None): | |||
pytest.fail(message) | |||
|
|||
|
|||
def pytest_expect(condition, message=None): |
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.
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.
Done.
tests/l2/test_l2_configure.py
Outdated
logger.info("Checking vlan and interface facts.") | ||
new_vlan = duthost.shell("show vlan config")["stdout"] | ||
new_int = duthost.shell("show int status")["stdout"] | ||
pytest_expect(orig_vlan != new_vlan, "vlan config not updated.") |
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.
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.
Removed this check. This is not the focus of the test so I was just placing this here as a place holder.
tests/l2/test_l2_configure.py
Outdated
Args: | ||
duthosts: set of DUTs. | ||
""" | ||
# Setup. |
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.
The pre-commit check detected issues in the files touched by this pull request. Detailed pre-commit check results: To run the pre-commit checks locally, you can follow below steps:
|
Updated the testcase according to comment. The test case should reflect what the issue is looking for. |
tests/l2/conftest.py
Outdated
# conftest.py for L2 configuration. | ||
|
||
|
||
def pytest_addoption(parser): |
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.
Nightly test is used to verify specified sonic version, if we upgrade sonic image in this test, we can't add test to nightly test.
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.
This is what the issue is asking so if we can't upgrade, we need to find another way to trigger db_migrator?
Btw the test will restore the original image. Is that good enough?
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.
Please confirm with Vaibhav, I guess we need to upgrade from 20191130.xx to 20240531.xx and verify L2 configuration.
If we do this in nightly test for 20240531.xx, how do you choose new image to upgrade?
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'll check with him. Maybe we should do a --source_image and --target_image. It will make more sense to upgrade from an older image to 20240531 in the nightly test.
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.
Checked with Vaibhab, this test should be in nightly. I will rewrite part of the test according to test_upgrade_path.py to better accommodate that.
tests/l2/test_l2_configure.py
Outdated
# Step 4: Verifies no config fro minigraph is written into ConfigDB. | ||
try: | ||
for table in ["TELEMETRY", "RESTAPI", "DEVICE_METADATA"]: | ||
count = int(duthost.shell('redis-cli --scan --pattern "{}*" | wc -l'.format(table))['stdout']) |
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.
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.
Looks like this reflect a real issue as I can see those unwanted table all the time, i.e. before l2, after l2, and after installing the image.
admin@vlab-01:~$ sonic-db-cli CONFIG_DB KEYS "TELEMETRY|*"
TELEMETRY|gnmi
TELEMETRY|certs
The pre-commit check detected issues in the files touched by this pull request. Detailed pre-commit check results: To run the pre-commit checks locally, you can follow below steps:
|
66e89cc
to
47d615f
Compare
for table in ["TELEMETRY", "RESTAPI"]: | ||
pytest_assert( | ||
is_table_empty(duthost, table), "{} table is not empty!".format(table) | ||
) |
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.
Need to recover original configuration.
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.
This is already done in the setup_env fixture in the same file.
tests/l2/test_l2_configure.py
Outdated
logger = logging.getLogger(__name__) | ||
|
||
pytestmark = [ | ||
pytest.mark.topology("any"), |
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.
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.
Thanks! Done.
The test will now simply configure L2 and then check config db. TESTED: passed on 202012.66 (image with db_migrator fix) failed on 202012.76 (image without fix) failed at master head (with fixes, so indicates some other bugs)
Force push to fix a commit message. |
Can you check database version before and after config reload? admin@str-msn2700-20:~$ sonic-db-cli CONFIG_DB hgetall "VERSIONS|DATABASE" |
@ganglyu done. |
@ganglyu |
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.
Database version is not changed after config reload, so db migrator should not change anything.
I don't understand why database is changed, but I will approve this PR for further investigation.
"gwaddr": "{}" | ||
}} | ||
}}, | ||
"DEVICE_METADATA": {{ |
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.
The step in test does not follow https://github.com/sonic-net/SONiC/wiki/L2-Switch-mode exactly. For example, DualToR is not considered. And the commands used does not exact match. #Closed
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 the record, this comes from testbed_set_l2.yml. The wiki way requires running over console and I haven't find a reliable API in sonic-mgmt that pass the test. I'll see if there is any other way to make it work.
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.
Spoke with Gang and Xin yesterday. And it appears the testbed_set_l2.yml method of setting up is a L2 mode is a workaround since ansible library requires the ssh session to be always active, and we don't have library support for doing it through console.
Reference: https://github.com/sonic-net/SONiC/wiki/L2-Switch-mode ### Description of PR Create a test case for configuring switch to L2 mode. Summary: Add a test case for writing L2 configuration into config DB. This is precursor to a testcase requested in issue 8777 sonic-net#8777 ### Approach Add a test case #### What is the motivation for this PR? Address sonic-net#8777 #### How did you do it? #### How did you verify/test it? Ran on virtual switch.
Reference: https://github.com/sonic-net/SONiC/wiki/L2-Switch-mode ### Description of PR Create a test case for configuring switch to L2 mode. Summary: Add a test case for writing L2 configuration into config DB. This is precursor to a testcase requested in issue 8777 sonic-net#8777 ### Approach Add a test case #### What is the motivation for this PR? Address sonic-net#8777 #### How did you do it? #### How did you verify/test it? Ran on virtual switch.
Reference: https://github.com/sonic-net/SONiC/wiki/L2-Switch-mode ### Description of PR Create a test case for configuring switch to L2 mode. Summary: Add a test case for writing L2 configuration into config DB. This is precursor to a testcase requested in issue 8777 sonic-net#8777 ### Approach Add a test case #### What is the motivation for this PR? Address sonic-net#8777 #### How did you do it? #### How did you verify/test it? Ran on virtual switch.
Reference: https://github.com/sonic-net/SONiC/wiki/L2-Switch-mode
Description of PR
Create a test case for configuring switch to L2 mode.
Summary:
Add a test case for writing L2 configuration into config DB. This is precursor to a testcase requested in
issue 8777 #8777
Fixes # (issue)
Type of change
Back port request
Approach
Add a test case
What is the motivation for this PR?
Address #8777
How did you do it?
How did you verify/test it?
Ran on virtual switch.
Any platform specific information?
No.
Supported testbed topology if it's a new test case?
Any.
Documentation