-
Notifications
You must be signed in to change notification settings - Fork 9
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
Keep k8s resources on test failure #236
Conversation
7761f58
to
20a90bb
Compare
20a90bb
to
7763aa9
Compare
Signed-off-by: Pablo Chacin <pablochacin@gmail.com>
Signed-off-by: Pablo Chacin <pablochacin@gmail.com>
Signed-off-by: Pablo Chacin <pablochacin@gmail.com>
7763aa9
to
a148748
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.
Looking great, I think this is a very useful feature for debugging e2e scenarios. Thanks for taking care of this!
if err != nil { | ||
t.Errorf("error creating test namespace: %v", err) | ||
t.Errorf("failed to create test namespace: %v", err) |
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.
Probably a discussion for another PR, but t.Fatalf
would be preferred in this cases, as it protects us from forgetting the return
line below.
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 would prefer to unify this in another PR.
options: []TestNamespaceOption{WithPrefix("prefix-")}, | ||
expectError: false, | ||
check: func(k8s kubernetes.Interface, ns string) error { | ||
return nil |
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.
Should we check here that strings.HasPrefix(ns, "prefix-")
?
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 catch, I forgot to implement the checks 😅
Signed-off-by: Pablo Chacin <pablochacin@gmail.com>
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.
LGTM!
Description
This PR adds a helper for e2e tests that allows retaining the namespace used for a test if the test fails.
Fixes #228
Note to reviewers
Testing this PR is tricky as the expected behavior is triggered by a failed test. Therefore, a unit test was added that actually fails, but still checks if the expected behavior happened.
Another important note is that this test requires the sub-test not to run in parallel or otherwise the validation would happen before the subtests ends. However, the
tparallel
linter would complain if the sub-test does not specifiest.Parallel()
and it does not accept thenolint
directive.A workaround for the two issues about is to make this test build only if the
keeponfail
tag is set in thego test
commandThe command for running this test and the expected output is shown below:
Checklist:
make lint
) and all checks pass.make test
) and all tests pass.make e2e-xxx
foragent
,disruptors
,kubernetes
orcluster
related changes)