-
Notifications
You must be signed in to change notification settings - Fork 0
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
chore: add integration tests #45
Conversation
23297d4
to
f455130
Compare
f455130
to
1e6366f
Compare
efb3e05
to
024c68d
Compare
024c68d
to
bc658f6
Compare
bc658f6
to
c2271c2
Compare
dfa58fe
to
0390e0f
Compare
0390e0f
to
569f289
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall LGTM, a few small comments
integration/buildcontainer_test.go
Outdated
"strings" | ||
) | ||
|
||
// buildContainer builds the container image for sm-k6-runner by running `docker` commands, generating an image on the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// buildContainer builds the container image for sm-k6-runner by running `docker` commands, generating an image on the | |
// buildContainer builds the container image for crocochrome by running `docker` commands, generating an image on the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hehe, this is a copypaste and it shows. Good catch!
integration/integration_test.go
Outdated
if err != nil { | ||
t.Fatalf("starting crocochrome container: %v", err) | ||
} | ||
testcontainers.CleanupContainer(t, cc) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Not a big deal, but the doc comment suggests we call this before the error check as a defer
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also on L91
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have done the "before error check" part, but the defer
one feels like an error in the docs to me: CleanupContainer
is already wrapping the remove call in t.Cleanup
, there doesn't seem to be any point to defer it further: https://github.com/testcontainers/testcontainers-go/blob/add4ac3f019b773ae08c1af05f57554ba6819430/testing.go#L73
integration/integration_test.go
Outdated
ctx, cancel := context.WithCancel(context.Background()) | ||
t.Cleanup(cancel) | ||
|
||
image, err := buildContainer("..", "crocochrome") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it worth adding a step to delete the image after the integration test suite runs?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I went ahead and implemented this, but after doing so I'm not sure there is really a point to it.
Even if I run docker rmi ...
, all the build cache and intermediate layers will remain, so I wonder what is the point of removing the tag if the users would need to garbage-collect the things that actually take space on its own.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point, I don't think it's necessary either :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the review @The-9880 ! Will apply the suggested changes on monday :)
integration/buildcontainer_test.go
Outdated
"strings" | ||
) | ||
|
||
// buildContainer builds the container image for sm-k6-runner by running `docker` commands, generating an image on the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hehe, this is a copypaste and it shows. Good catch!
ba140d6
to
b8c3887
Compare
b8c3887
to
101e4c1
Compare
This PR adds an integration test suite to crocochrome, which should help catch succinct errors in the crocochrome setup, such as misconfigurations of chromium, permissions, capabilities, etc. All other tests in the codebase run a simple script instead of real chromium.
The suite roughly works like this:
grafana/k6
, updated by renovate so we can notice if something breaks)error
does not appear in k6 logsAs normal, if any of these steps fail, the test fails.
All is done with testcontainers in go, so this test will normal run as part of
go test
without any special configuration, and should work everywhere as long as docker is available. As crocochrome is not multiarch though, running this test on arm might be very slow or not work at all. If this is the case, this test can be skipped by setting the env varTEST_INTEGRATION_SKIP
to any non-empty value.