8000 [Bug] [CLI] test-case-selector option does not work with resource · Issue #12456 · kyverno/kyverno · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

[Bug] [CLI] test-case-selector option does not work with resource #12456

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

Open
2 tasks done
afarbos opened this issue Mar 19, 2025 · 3 comments · May be fixed by #12681
Open
2 tasks done

[Bug] [CLI] test-case-selector option does not work with resource #12456

afarbos opened this issue Mar 19, 2025 · 3 comments · May be fixed by #12681
Assignees
Labels
bug Something isn't working cli:test The CLI test command related issue. test Tasks related to unit/e2e tests. triage Default label assigned to all new issues indicating label curation is needed to fully organize. type:cli cli releated issue

Comments

@afarbos
Copy link
afarbos commented Mar 19, 2025

Kyverno CLI Version

1.13.4

Description

According to https://kyverno.io/docs/kyverno-cli/usage/test/#test-subset-of-resources the test-case-selector allows to run a subset of tests based on policy, rule and/or resource.
The resource selector does not work, all resources are tested even when one is specified.

relates to #10406

Steps to reproduce

$ kyverno version && kyverno test https://github.com/kyverno/policies/other/require-pdb/.kyverno-test --git-branch main --test-case-selector "resource=nginx-deploy-pass"

Version: 1.13.4
Time: ---
Git commit ID: ---
Enumerating objects: 5110, done.
Counting objects: 100% (5110/5110), done.
Compressing objects: 100% (3171/3171), done.
Total 5110 (delta 2302), reused 3919 (delta 1902), pack-reused 0 (from 0)
Loading test  ( /other/require-pdb/.kyverno-test/kyverno-test.yaml ) ...
  Loading values/variables ...
  Loading policies ...
  Loading resources ...
  Loading exceptions ...
  Applying 1 policy to 2 resources ...
  Checking results ...

│────│─────────────│─────────────│──────────────────────────────│────────│────────│
│ ID │ POLICY      │ RULE        │ RESOURCE                     │ RESULT │ REASON │
│────│─────────────│─────────────│──────────────────────────────│────────│────────│
│ 1  │ require-pdb │ require-pdb │ Deployment/nginx-deploy-pass │ Pass   │ Ok     │
│ 2  │ require-pdb │ require-pdb │ Deployment/nginx-deploy-skip │ Pass   │ Ok     │
│────│─────────────│─────────────│──────────────────────────────│────────│────────│


Test Summary: 2 tests passed and 0 tests failed

Expected behavior

$ kyverno version && kyverno test https://github.com/kyverno/policies/other/require-pdb/.kyverno-test --git-branch main --test-case-selector "resource=foo"

Version: 1.13.4
Time: ---
Git commit ID: ---
Enumerating objects: 5110, done.
Counting objects: 100% (5110/5110), done.
Compressing objects: 100% (3171/3171), done.
Total 5110 (delta 2302), reused 3919 (delta 1902), pack-reused 0 (from 0)

Test Summary: 0 tests passed and 0 tests failed

Screenshots

See CLI output above

Kyverno logs

See CLI output above

Slack discussion

https://cloud-native.slack.com/archives/C02CEARLA3D/p1741815210978819

Troubleshooting

  • I have read and followed the troubleshooting guide.
  • I have searched other issues in this repository and mine is not recorded.
@afarbos afarbos added bug Something isn't working triage Default label assigned to all new issues indicating label curation is needed to fully organize. type:cli cli releated issue labels Mar 19, 2025
Copy link
welcome bot commented Mar 19, 2025

Thanks for opening your first issue here! Be sure to follow the issue template!

@dosubot dosubot bot added cli:test The CLI test command related issue. test Tasks related to unit/e2e tests. labels Mar 19, 2025
@dhimanAbhi
Copy link
Contributor

Hi @afarbos,
I reviewed the codebase and found that resources are not being filtered because the resource field is deprecated, and resources should be used instead. However, when running the test case selector, using "resources=any_resource" doesn't work either. Based on my findings, this seems to be due to the filter.Apply() function not being updated accordingly.

@realshuting , I’d like to work on this issue.

@dhimanAbhi
Copy link
Contributor

/assign

@dhim
6E1B
anAbhi dhimanAbhi linked a pull request Apr 9, 2025 that will close this issue
7 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working cli:test The CLI test command related issue. test Tasks related to unit/e2e tests. triage Default label assigned to all new issues indicating label curation is needed to fully organize. type:cli cli releated issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants
0