Skip to content

Add GCU test cases for k8s table#11458

Merged
qiluo-msft merged 6 commits intosonic-net:masterfrom
lixiaoyuner:dev/yunli1/add-gcu-test-cases-for-k8s-table
Feb 7, 2024
Merged

Add GCU test cases for k8s table#11458
qiluo-msft merged 6 commits intosonic-net:masterfrom
lixiaoyuner:dev/yunli1/add-gcu-test-cases-for-k8s-table

Conversation

@lixiaoyuner
Copy link
Copy Markdown
Contributor

@lixiaoyuner lixiaoyuner commented Jan 31, 2024

Description of PR

Summary:
Fixes # (issue)
Testcase of k8s config for generic updater apply-patch
ADO: 26662927

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?

This PR is to verify the usage of 'config apply-patch' works for k8s config

How did you do it?

Add k8s config to dut and check if config changes as expected

How did you verify/test it?

Run test of sonic-mgmt/tests/generic_config_updater/test_kubernetes_config.py on KVM

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

Documentation

@mssonicbld
Copy link
Copy Markdown
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.........................................................Failed
- hook id: end-of-file-fixer
- exit code: 1
- files were modified by this hook

Fixing tests/generic_config_updater/test_kubernetes_config.py

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/generic_config_updater/test_kubernetes_config.py:21:121: E501 line too long (149 > 120 characters)
tests/generic_config_updater/test_kubernetes_config.py:22:121: E501 line too long (151 > 120 characters)
tests/generic_config_updater/test_kubernetes_config.py:28:21: E128 continuation line under-indented for visual indent
tests/generic_config_updater/test_kubernetes_config.py:30:21: E128 continuation line under-indented for visual indent
tests/generic_config_updater/test_kubernetes_config.py:32:121: E501 line too long (133 > 120 characters)
...
[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>

@mssonicbld
Copy link
Copy Markdown
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.................................................Failed
- hook id: trailing-whitespace
- exit code: 1
- files were modified by this hook

Fixing tests/generic_config_updater/test_kubernetes_config.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
flake8...............................................(no files to check)Skipped
check conditional mark sort..........................(no files to check)Skipped

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>

@lixiaoyuner lixiaoyuner marked this pull request as ready for review February 1, 2024 09:31
delete_checkpoint(duthost)


def get_k8s_runningconfig(duthost):
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Any other check method other than running config?
The success of apply-patch operation should guarantee the CONFIG_DB update.
Is there a show command such as show k8s server?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks for this comment, have add 'show kube server' related validation.

Copy link
Copy Markdown
Contributor

@wen587 wen587 left a comment

Choose a reason for hiding this comment

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

LGTM



test_data_1 = {
0: (K8SEMPTYTOHALFPATCH, K8SHALFCONFIG, EMPTYK8STABLE, SUCCEED),
Copy link
Copy Markdown
Contributor

@qiluo-msft qiluo-msft Feb 5, 2024

Choose a reason for hiding this comment

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

0

Maintaining the index is not necessary. Could you remove? #Closed

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks for this comment, fixed.

@StormLiangMS
Copy link
Copy Markdown
Collaborator

hi @lixiaoyuner could you run test with 202305 image with this one? Would like to avoid regression for 202305 branch at this stage.

@lixiaoyuner
Copy link
Copy Markdown
Contributor Author

hi @lixiaoyuner could you run test with 202305 image with this one? Would like to avoid regression for 202305 branch at this stage.

Have tested with 202305 latest image, it's good to run this test. And also tested with 202311 latest image, it's good to run this test.

mssonicbld pushed a commit to mssonicbld/sonic-mgmt that referenced this pull request Mar 5, 2024
## Description of PR

Summary:
Fixes # (issue)
Testcase of k8s config for generic updater apply-patch

### Type of change

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

## Approach
#### What is the motivation for this PR?
This PR is to verify the usage of 'config apply-patch' works for k8s config
#### How did you do it?
Add k8s config to dut and check if config changes as expected
#### How did you verify/test it?
Run test of sonic-mgmt/tests/generic_config_updater/test_kubernetes_config.py on KVM
@mssonicbld
Copy link
Copy Markdown
Collaborator

Cherry-pick PR to 202305: #11901

mssonicbld pushed a commit to mssonicbld/sonic-mgmt that referenced this pull request Mar 5, 2024
## Description of PR

Summary:
Fixes # (issue)
Testcase of k8s config for generic updater apply-patch

### Type of change

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

## Approach
#### What is the motivation for this PR?
This PR is to verify the usage of 'config apply-patch' works for k8s config
#### How did you do it?
Add k8s config to dut and check if config changes as expected
#### How did you verify/test it?
Run test of sonic-mgmt/tests/generic_config_updater/test_kubernetes_config.py on KVM
@mssonicbld
Copy link
Copy Markdown
Collaborator

Cherry-pick PR to 202311: #11902

mssonicbld pushed a commit that referenced this pull request Mar 5, 2024
## Description of PR

Summary:
Fixes # (issue)
Testcase of k8s config for generic updater apply-patch

### Type of change

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

## Approach
#### What is the motivation for this PR?
This PR is to verify the usage of 'config apply-patch' works for k8s config
#### How did you do it?
Add k8s config to dut and check if config changes as expected
#### How did you verify/test it?
Run test of sonic-mgmt/tests/generic_config_updater/test_kubernetes_config.py on KVM
mssonicbld pushed a commit that referenced this pull request Mar 5, 2024
## Description of PR

Summary:
Fixes # (issue)
Testcase of k8s config for generic updater apply-patch

### Type of change

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

## Approach
#### What is the motivation for this PR?
This PR is to verify the usage of 'config apply-patch' works for k8s config
#### How did you do it?
Add k8s config to dut and check if config changes as expected
#### How did you verify/test it?
Run test of sonic-mgmt/tests/generic_config_updater/test_kubernetes_config.py on KVM
@anamehra
Copy link
Copy Markdown
Contributor

Hi @lixiaoyuner , with this new testcase on a KUBERNETES enabled build, we observed following loganalyzer errors:

               Match Messages:
E               Apr 26 04:49:06.951797 bjw-can-8102-1 ERR ctrmgrd.py: Refer file /tmp/tmpj2csr7f7kube_hints_ for troubleshooting tips
E               
E               Apr 26 04:49:06.952134 bjw-can-8102-1 ERR ctrmgrd.py: Join failed: HTTPSConnectionPool(host='k8svip.ap.gbl', port=6443): Max retries exceeded with url: /api/v1/namespaces/default/configmaps/kube-root-ca.crt (Caused by NameResolutionError("&lt;urllib3.connection.HTTPSConnection object at 0x7fce9a825250&gt;: Failed to resolve 'k8svip.ap.gbl' ([Errno -3] Temporary failure in name resolution)"))
E               
E               Apr 26 04:49:46.964672 bjw-can-8102-1 ERR ctrmgrd.py: Refer file /tmp/tmp4r0omiobkube_hints_ for troubleshooting tips
E               
E               Apr 26 04:49:46.964855 bjw-can-8102-1 ERR ctrmgrd.py: Join failed: HTTPSConnectionPool(host='k8svip.ap.gbl', port=6443): Max retries exceeded with url: /api/v1/namespaces/default/configmaps/kube-root-ca.crt (Caused by NameResolutionError("&lt;urllib3.connection.HTTPSConnection object at 0x7fce9a825c70&gt;: Failed to resolve 'k8svip.ap.gbl' ([Errno -3] Temporary failure in name resolution)"))
E

I see the testcase using the hostname 'k8svip.ap.gbl'. What is the expectation with the test environment?

Thanks!

@lixiaoyuner
Copy link
Copy Markdown
Contributor Author

lixiaoyuner commented May 20, 2024

Hi @lixiaoyuner , with this new testcase on a KUBERNETES enabled build, we observed following loganalyzer errors:

               Match Messages:
E               Apr 26 04:49:06.951797 bjw-can-8102-1 ERR ctrmgrd.py: Refer file /tmp/tmpj2csr7f7kube_hints_ for troubleshooting tips
E               
E               Apr 26 04:49:06.952134 bjw-can-8102-1 ERR ctrmgrd.py: Join failed: HTTPSConnectionPool(host='k8svip.ap.gbl', port=6443): Max retries exceeded with url: /api/v1/namespaces/default/configmaps/kube-root-ca.crt (Caused by NameResolutionError("&lt;urllib3.connection.HTTPSConnection object at 0x7fce9a825250&gt;: Failed to resolve 'k8svip.ap.gbl' ([Errno -3] Temporary failure in name resolution)"))
E               
E               Apr 26 04:49:46.964672 bjw-can-8102-1 ERR ctrmgrd.py: Refer file /tmp/tmp4r0omiobkube_hints_ for troubleshooting tips
E               
E               Apr 26 04:49:46.964855 bjw-can-8102-1 ERR ctrmgrd.py: Join failed: HTTPSConnectionPool(host='k8svip.ap.gbl', port=6443): Max retries exceeded with url: /api/v1/namespaces/default/configmaps/kube-root-ca.crt (Caused by NameResolutionError("&lt;urllib3.connection.HTTPSConnection object at 0x7fce9a825c70&gt;: Failed to resolve 'k8svip.ap.gbl' ([Errno -3] Temporary failure in name resolution)"))
E

I see the testcase using the hostname 'k8svip.ap.gbl'. What is the expectation with the test environment?

Thanks!

@anamehra , actually it's a fake hostname, not a real endpoint. For this case, just want to test the GCU command to update k8s table config. And there is PR to ignore the error, #12849. Any more concerns about this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants