Skip to content

Add mark file for end to end test#12078

Merged
wangxin merged 8 commits intosonic-net:masterfrom
ganglyu:mark_disable_loganalyzer
Mar 26, 2024
Merged

Add mark file for end to end test#12078
wangxin merged 8 commits intosonic-net:masterfrom
ganglyu:mark_disable_loganalyzer

Conversation

@ganglyu
Copy link
Contributor

@ganglyu ganglyu commented Mar 21, 2024

Description of PR

Summary:
Add mark file for mgmt test.
Fixes # (issue)
Microsoft ADO: 24657445

Type of change

  • Bug fix
  • Testbed and Framework(new/improvement)
  • Test case(new/improvement)

Back port request

  • 201911
  • 202012
  • 202205
  • 202305
  • 202311

Approach

What is the motivation for this PR?

We need a flag to mark that DUT is under end to end test.
sonic-net/sonic-utilities#3102
db migrator needs to detect DUT is running in end to end test.

How did you do it?

Create /etc/sonic/mgmt_test_mark with fixture.

How did you verify/test it?

Run end to end test, and check /etc/sonic/mgmt_test_mark.

Any platform specific information?

Supported testbed topology if it's a new test case?

Documentation

@ganglyu ganglyu requested review from qiluo-msft and wangxin March 21, 2024 12:59
@mssonicbld
Copy link
Collaborator

The pre-commit check detected issues in the files touched by this pull request.
The pre-commit check is a mandatory check, please fix detected issues.

Detailed pre-commit check results:
trim trailing whitespace.................................................Passed
fix end of files.........................................................Passed
check yaml...........................................(no files to check)Skipped
check for added large files..............................................Passed
check python ast.........................................................Failed
- hook id: check-ast
- exit code: 1

tests/common/plugins/loganalyzer/init.py: failed parsing with CPython 3.8.10:

Traceback (most recent call last):
File "/home/AzDevOps/.cache/pre-commit/repot8sah67x/py_env-python3/lib/python3.8/site-packages/pre_commit_hooks/check_ast.py", line 21, in main
ast.parse(f.read(), filename=filename)
File "/usr/lib/python3.8/ast.py", line 47, in parse
return compile(source, filename, mode, flags,
File "tests/common/plugins/loganalyzer/init.py", line 57
except RunAnsibleModuleFail, AnsibleConnectionFailure as e:
^
SyntaxError: invalid syntax
...
[truncated extra lines, please run pre-commit locally to view full check results]

To run the pre-commit checks locally, you can follow below steps:

  1. Ensure that default python is python3. In sonic-mgmt docker container, default python is python2. You can run
    the check by activating the python3 virtual environment in sonic-mgmt docker container or outside of sonic-mgmt
    docker container.
  2. Ensure that the pre-commit package is installed:
sudo pip install pre-commit
  1. Go to repository root folder
  2. Install the pre-commit hooks:
pre-commit install
  1. Use pre-commit to check staged file:
pre-commit
  1. Alternatively, you can check committed files using:
pre-commit run --from-ref <commit_id> --to-ref <commit_id>

@ganglyu ganglyu closed this Mar 22, 2024
@ganglyu ganglyu reopened this Mar 22, 2024
@ganglyu ganglyu requested a review from liuh-80 March 22, 2024 11:45
mark_file = "/etc/sonic/disable_loganalyzer_mark"
for duthost in duthosts:
try:
duthost.shell("touch %s" % mark_file, module_ignore_errors=True)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

touch

I could not find any code related the usage of the file "disable_loganalyzer_mark". So I could not really understand "What is the motivation for this PR?"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sonic-net/sonic-utilities#3102
db migrator will use this flag to detect loganalyzer is disabled in end to end test.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated with simplified design.

@ganglyu ganglyu changed the title Add mark file for disable_loganalyzer Add mark file for end to end test Mar 25, 2024
mark_file = "/etc/sonic/mgmt_test_mark"
for duthost in duthosts:
try:
duthost.shell("touch %s" % mark_file, module_ignore_errors=True)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can use duthosts.shell as well. It will automatically dispatch the shell module to each duthost.
With module_ignore_error should be enough. No need to catch other exceptions. When the DUT is unreachable, the exception will be handled by other functions.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated.

@wangxin wangxin merged commit 36385e6 into sonic-net:master Mar 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants