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

POC: Kubernetes integration tests #323

Merged
merged 1 commit into from
Aug 29, 2023
Merged

Conversation

pablochacin
Copy link
Collaborator

@pablochacin pablochacin commented Aug 25, 2023

Description

The kubernetes package offers helper functions that are used by the disruptors. Testing this package with the kubernetes client mock is insufficient due to its many limitations. The mock does not validate the objects submitted to the API, and it does not support the generation of events (required for example by watchers) in a reliable way.

This PR is a Proof of concept of using TestContainers for the kubernetes integration tests using the k3s module that allows spawning a fully functional kubernetes cluster running in a container.

Its main advantage with respect to the existing tests is the speed of spawning the Kubernetes cluster.

Checklist:

  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works.
  • I have run linter locally (make lint) and all checks pass.
  • I have run tests locally (make test) and all tests pass.
  • I have run relevant e2e test locally (make e2e-xxx for agent, disruptors, kubernetes or cluster related changes)
  • Any dependent changes have been merged and published in downstream modules

@pablochacin pablochacin marked this pull request as ready for review August 28, 2023 22:07
@pablochacin pablochacin requested review from roobre and removed request for roobre August 28, 2023 22:08
@pablochacin pablochacin marked this pull request as draft August 28, 2023 22:12
@pablochacin pablochacin force-pushed the kubernetes-integration-tests branch 2 times, most recently from 82e53ce to 8e693c2 Compare August 28, 2023 22:23
@pablochacin pablochacin marked this pull request as ready for review August 28, 2023 22:26
Copy link
Collaborator

@roobre roobre left a comment

Choose a reason for hiding this comment

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

Looking good, I like how the setup is not very long and the tests are pretty concise.

Left only a question regarding the tiemout parameter and a few small suggestions.

pkg/kubernetes/integration_test.go Show resolved Hide resolved
pkg/kubernetes/integration_test.go Outdated Show resolved Hide resolved
pkg/kubernetes/integration_test.go Outdated Show resolved Hide resolved
Copy link
Collaborator

@roobre roobre left a comment

Choose a reason for hiding this comment

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

LGTM

Signed-off-by: Pablo Chacin <pablochacin@gmail.com>
@pablochacin pablochacin merged commit 6b5e14b into main Aug 29, 2023
7 checks passed
@pablochacin pablochacin deleted the kubernetes-integration-tests branch August 29, 2023 16:53
@pablochacin pablochacin mentioned this pull request Sep 12, 2023
9 tasks
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

2 participants