Skip to content
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

Fix do_init function in telemetry/conftest.py #16546

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

weiguo-nvidia
Copy link
Contributor

Description of PR

Summary: Fix do_init function in telemetry/conftest.py
Fixes #
Test case telemetry/test_events.py::test_events failed in fixture test_eventd_healthy with error message FileNotFoundError: [Errno 2] No such file or directory: 'logs/telemetry/files/heartbeat.json'

  • Issue1: The os.mkdir() function can only create one-level directory and cannot automatically create multiple directories. When create logs/telemetry, if "logs" directory does not exist, it will raise an error. Use os.makedirs() function can avoid this issue.

  • Issue2: The error message Dir/file already exists in the except section is inaccurate. Failure may also be due to other reasons, and this log might be confusing.

  • Issue3: Just copy telemetry/validate_yang_events.py once

Add pdb output

> /root/mars/workspace/sonic-mgmt/tests/telemetry/conftest.py(158)do_init()
(Pdb) os.getcwd()
'/root/mars/workspace/sonic-mgmt/tests'
-> for i in [BASE_DIR, DATA_DIR]:
(Pdb) DATA_DIR
'logs/telemetry/files'
(Pdb) BASE_DIR
'logs/telemetry'
(Pdb) n
> /root/mars/workspace/sonic-mgmt/tests/telemetry/conftest.py(159)do_init()
-> try:
(Pdb) n
> /root/mars/workspace/sonic-mgmt/tests/telemetry/conftest.py(160)do_init()
-> os.mkdir(i)
(Pdb) n
FileNotFoundError: [Errno 2] No such file or directory: 'logs/telemetry'
> /root/mars/workspace/sonic-mgmt/tests/telemetry/conftest.py(160)do_init()
-> os.mkdir(i)
(Pdb) n
> /root/mars/workspace/sonic-mgmt/tests/telemetry/conftest.py(161)do_init()
-> except OSError as e:
(Pdb) n
> /root/mars/workspace/sonic-mgmt/tests/telemetry/conftest.py(162)do_init()
-> logger.info("Dir/file already exists: {}, skipping mkdir".format(e))
(Pdb) n
04:58:02 conftest.do_init                         L0162 INFO   | Dir/file already exists: [Errno 2] No such file or directory: 'logs/telemetry', skipping mkdir

Type of change

  • Bug fix
  • Testbed and Framework(new/improvement)
  • New Test case
    • Skipped for non-supported platforms
  • Test case improvement

Back port request

  • 202012
  • 202205
  • 202305
  • 202311
  • 202405
  • 202411

Approach

What is the motivation for this PR?

How did you do it?

How did you verify/test it?

Any platform specific information?

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

Documentation

@mssonicbld
Copy link
Collaborator

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

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.

2 participants