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

test: add context-aware integration tests #399

Conversation

fabriziosestito
Copy link
Contributor

@fabriziosestito fabriziosestito commented Dec 15, 2023

Description

This PR introduces context-aware integration tests.
The following runtimes have been tested by using context-aware test policies:

Todo

  • [ ]: move the test policies to the Kubewarden organization

To be able to run the tests, a mock Kubernetes client was created by using this guide: https://kube.rs/controllers/testing/#unit-tests-with-mocks
Since there is nothing equivalent to envtest in Rust, using a mock allows us to save some CI time (and effort) by relying on a mock kube-rs Client.

An alternative could have been setting up a real cluster, but dealing with the isolation and testcontainers was a big downside and the return on investment wasn't worth it for this type of test, since the goal is testing the policy evaluator and considering we already have e2e tests in place.

@fabriziosestito fabriziosestito force-pushed the test/add-context-aware-integration-tests branch 2 times, most recently from fe05241 to 1a000b5 Compare December 15, 2023 07:48
@fabriziosestito fabriziosestito force-pushed the test/add-context-aware-integration-tests branch 2 times, most recently from 7a811f7 to 32f0c21 Compare December 17, 2023 11:02
Copy link
Member

@jvanz jvanz left a comment

Choose a reason for hiding this comment

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

LGTM. I just have a quick question. I'll not give a "approved" flag because the PR is a draft and I know that Fabrizio is working on this still.

tests/integration_test.rs Outdated Show resolved Hide resolved
@fabriziosestito fabriziosestito force-pushed the test/add-context-aware-integration-tests branch from 32f0c21 to 7a42537 Compare December 18, 2023 19:14
@fabriziosestito fabriziosestito force-pushed the test/add-context-aware-integration-tests branch 3 times, most recently from 0e026ad to 443bd1d Compare December 19, 2023 08:02
@fabriziosestito fabriziosestito changed the title test: add context aware integration tests test: add context-aware integration tests Dec 19, 2023
@fabriziosestito fabriziosestito marked this pull request as ready for review December 19, 2023 08:26
@fabriziosestito fabriziosestito requested a review from a team as a code owner December 19, 2023 08:26
Copy link
Member

@flavio flavio left a comment

Choose a reason for hiding this comment

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

Love it! One minor nitpick, see my comment.

I would start the transfer process of the test policies to the kubewaden organization, and then change this PR to consume the images from there. Then we can merge it

tests/common/mod.rs Show resolved Hide resolved
Signed-off-by: Fabrizio Sestito <fabrizio.sestito@suse.com>
Signed-off-by: Fabrizio Sestito <fabrizio.sestito@suse.com>
Signed-off-by: Fabrizio Sestito <fabrizio.sestito@suse.com>
@fabriziosestito fabriziosestito force-pushed the test/add-context-aware-integration-tests branch from 4a48d59 to f50075c Compare December 20, 2023 08:55
Copy link
Member

@viccuad viccuad left a comment

Choose a reason for hiding this comment

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

LGTM!

@fabriziosestito fabriziosestito merged commit 74b7aff into kubewarden:main Dec 20, 2023
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

4 participants