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

Support for running image-based gadgets test in k8s #2867

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

pawarpranav83
Copy link
Contributor

@pawarpranav83 pawarpranav83 commented May 17, 2024

Support for running image-based gadgets test in k8s cluster with kubectl-gadget.

Previously we were running the test with ig alongside local containers, this PR adds support for running these tests with kubectl-gadget in the k8s cluster (minikube).

We try to have a single test, which applies different options for the factory runner as well as expected entry based on whether it's ig or kubectl-gadget.

Issue #2046

How to use

Set IG_PATH=ig (for testing with local containers using ig) or IG_PATH=kubectl-gadget and IG_RUNTIME=kubernetes (for testing with containers running in minikube cluster, need to run minikube-deploy before).

Note: You can set this to the actual path of those applications as well, for example, ./ig or ./kubectl-gadget, should contain the keyword kubectl-gadget for CurrentTestComponent to be set as KubectlGadgetTestComponent.

Test Command: make -C ./gadgets test-k8s

Copy link
Member

@mauriciovasquezbernal mauriciovasquezbernal left a comment

Choose a reason for hiding this comment

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

My idea was more to implement a new "kubernetes container runtime". i.e. something that runs containers using kubernetes. I hacked a bit and got something working on fa5f2d1, please check the commit message with more details.

What do you think about using it?

pkg/testing/match/match.go Outdated Show resolved Hide resolved
@pawarpranav83 pawarpranav83 force-pushed the testing-fw branch 3 times, most recently from e2ec249 to 052e435 Compare May 21, 2024 17:18
Copy link
Member

@mauriciovasquezbernal mauriciovasquezbernal left a comment

Choose a reason for hiding this comment

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

Some more comments. It's looking really good!

pkg/container-utils/testutils/k8s.go Outdated Show resolved Hide resolved
pkg/testing/component/component.go Outdated Show resolved Hide resolved
pkg/testing/component/component.go Outdated Show resolved Hide resolved
pkg/testing/component/component.go Outdated Show resolved Hide resolved
pkg/testing/utils/utils.go Outdated Show resolved Hide resolved
gadgets/trace_open/test/trace_open_test.go Outdated Show resolved Hide resolved
gadgets/trace_open/test/trace_open_test.go Show resolved Hide resolved
gadgets/trace_open/test/trace_open_test.go Outdated Show resolved Hide resolved
Copy link
Member

@mauriciovasquezbernal mauriciovasquezbernal left a comment

Choose a reason for hiding this comment

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

I think it's almost ready to go. Few final nits, I'll approve once them are handled. Great job!

pkg/container-utils/testutils/k8s.go Outdated Show resolved Hide resolved
pkg/types/types.go Outdated Show resolved Hide resolved
gadgets/Makefile Outdated Show resolved Hide resolved
gadgets/Makefile Outdated Show resolved Hide resolved
pkg/testing/component/component.go Outdated Show resolved Hide resolved
pkg/testing/component/utils.go Outdated Show resolved Hide resolved
gadgets/trace_open/test/trace_open_test.go Outdated Show resolved Hide resolved
pkg/testing/component/component.go Outdated Show resolved Hide resolved
@pawarpranav83 pawarpranav83 force-pushed the testing-fw branch 2 times, most recently from 02bb6a1 to a027fd6 Compare May 31, 2024 09:06
Copy link
Member

@mauriciovasquezbernal mauriciovasquezbernal left a comment

Choose a reason for hiding this comment

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

LGTM. Would you mind fixing the last lint error? I'll merge it after it. Thanks!

@pawarpranav83
Copy link
Contributor Author

Should we add a job for running these tests in a minikube cluster, we just have the ig test for now.

@mauriciovasquezbernal
Copy link
Member

That would be great if you are able to make it. Perhaps we can reuse the same job with a matrix strategy.

Signed-off-by: pawarpranav83 <pawar.pranav83@gmail.com>
Signed-off-by: pawarpranav83 <pawar.pranav83@gmail.com>
Copy link
Member

@eiffel-fl eiffel-fl left a comment

Choose a reason for hiding this comment

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

Hi!

Thank you for working on this! I have some comments but nothing critical!
Let's see how the CI reacts.

Best regards.

pkg/container-utils/testutils/k8s.go Show resolved Hide resolved
pkg/container-utils/testutils/k8s.go Show resolved Hide resolved
pkg/testing/utils/utils.go Show resolved Hide resolved
pkg/testing/utils/utils.go Show resolved Hide resolved
Signed-off-by: pawarpranav83 <pawar.pranav83@gmail.com>
…for testing with k8s

Signed-off-by: pawarpranav83 <pawar.pranav83@gmail.com>
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.

None yet

3 participants