sonic-mgmt icon indicating copy to clipboard operation
sonic-mgmt copied to clipboard

Fix the test_show_platform_fan test case statistically failure

Open nhe-NV opened this issue 2 years ago • 16 comments

Fix the test_show_platform_fan test case statistically failure and fix the pep8 failure at the same time

Fan having temporary status “NOT OK” is not a bug. It could happen in following case:

  1. Thermalctld/kernel changes the target speed. Hardware needs time to adjust the fan speed to target speed.
  2. Another thread of thermalctld reads the target speed and actual speed immediately. At this time point, there is a gap between fan target speed and actual speed which would cause “high speed warning” and fan status “NOT OK”.

Add retry in the test case to make the test case stable

Change-Id: I0433700a93d6a2ec6ed715f13b3d45e92935561f

Description of PR

Summary: Fix the test_show_platform_fan test case statistically failure Fixes # (issue)

Type of change

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

Back port request

  • [ ] 201911
  • [x] 202012
  • [x] 202205

Approach

What is the motivation for this PR?

Fix the test_show_platform_fan test case statistically failure

How did you do it?

Add retry when validate the fan status

How did you verify/test it?

Run the test_show_platform.py for 10 times, and no failure.

Any platform specific information?

No

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

Documentation

nhe-NV avatar Nov 03 '22 06:11 nhe-NV

The pre-commit check detected issues in the files touched by this pull request. The detected issues may be old or new. For new issues, please try to fix them.

For old issues, it is not mandatory to fix them because they were not caused by this change. It is unfair to blame author of this pull request. But if you can take extra effort to fix the old issues as well, that would be great!

Detailed pre-commit check results: trim trailing whitespace.................................................Failed
- hook id: trailing-whitespace
- exit code: 1
- files were modified by this hook

Fixing tests/platform_tests/cli/test_show_platform.py

fix end of files.........................................................Passed
check yaml...........................................(no files to check)Skipped
check for added large files..............................................Passed
check python ast.........................................................Passed
flake8...................................................................Failed
- hook id: flake8
- exit code: 1

tests/platform_tests/cli/test_show_platform.py:202:49: W605 invalid escape sequence 's'

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>

azure-pipelines[bot] avatar Nov 03 '22 06:11 azure-pipelines[bot]

The pre-commit check detected issues in the files touched by this pull request. The detected issues may be old or new. For new issues, please try to fix them.

For old issues, it is not mandatory to fix them because they were not caused by this change. It is unfair to blame author of this pull request. But if you can take extra effort to fix the old issues as well, that would be great!

Detailed pre-commit check results: trim trailing whitespace.................................................Failed
- hook id: trailing-whitespace
- exit code: 1
- files were modified by this hook

Fixing tests/platform_tests/cli/test_show_platform.py

fix end of files.........................................................Passed
check yaml...........................................(no files to check)Skipped
check for added large files..............................................Passed
check python ast.........................................................Passed
flake8...................................................................Passed

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>

azure-pipelines[bot] avatar Nov 03 '22 07:11 azure-pipelines[bot]

/azp run

yejianquan avatar Nov 03 '22 07:11 yejianquan

Azure Pipelines successfully started running 1 pipeline(s).

azure-pipelines[bot] avatar Nov 03 '22 07:11 azure-pipelines[bot]

The pre-commit check detected issues in the files touched by this pull request. The detected issues may be old or new. For new issues, please try to fix them.

For old issues, it is not mandatory to fix them because they were not caused by this change. It is unfair to blame author of this pull request. But if you can take extra effort to fix the old issues as well, that would be great!

Detailed pre-commit check results: trim trailing whitespace.................................................Failed
- hook id: trailing-whitespace
- exit code: 1
- files were modified by this hook

Fixing tests/platform_tests/cli/test_show_platform.py

fix end of files.........................................................Passed
check yaml...........................................(no files to check)Skipped
check for added large files..............................................Passed
check python ast.........................................................Passed
flake8...................................................................Passed

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>

azure-pipelines[bot] avatar Nov 03 '22 07:11 azure-pipelines[bot]

The pre-commit check detected issues in the files touched by this pull request. The detected issues may be old or new. For new issues, please try to fix them.

For old issues, it is not mandatory to fix them because they were not caused by this change. It is unfair to blame author of this pull request. But if you can take extra effort to fix the old issues as well, that would be great!

Detailed pre-commit check results: trim trailing whitespace.................................................Failed
- hook id: trailing-whitespace
- exit code: 1
- files were modified by this hook

Fixing tests/platform_tests/cli/test_show_platform.py

fix end of files.........................................................Passed
check yaml...........................................(no files to check)Skipped
check for added large files..............................................Passed
check python ast.........................................................Passed
flake8...................................................................Passed

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>

azure-pipelines[bot] avatar Nov 03 '22 14:11 azure-pipelines[bot]

/azpw run

nhe-NV avatar Nov 04 '22 01:11 nhe-NV

/AzurePipelines run

mssonicbld avatar Nov 04 '22 01:11 mssonicbld

Azure Pipelines successfully started running 1 pipeline(s).

azure-pipelines[bot] avatar Nov 04 '22 01:11 azure-pipelines[bot]

/azpw run

nhe-NV avatar Nov 07 '22 08:11 nhe-NV

/AzurePipelines run

mssonicbld avatar Nov 07 '22 08:11 mssonicbld

Azure Pipelines successfully started running 1 pipeline(s).

azure-pipelines[bot] avatar Nov 07 '22 08:11 azure-pipelines[bot]

/azpw run

nhe-NV avatar Nov 08 '22 00:11 nhe-NV

/AzurePipelines run

mssonicbld avatar Nov 08 '22 00:11 mssonicbld

Azure Pipelines successfully started running 1 pipeline(s).

azure-pipelines[bot] avatar Nov 08 '22 00:11 azure-pipelines[bot]

@keboliu could you please review?

liat-grozovik avatar Nov 10 '22 12:11 liat-grozovik