Conversation
851af62 to
dd7cacb
Compare
dd7cacb to
ce3c160
Compare
|
Integration test results for ce3c160: fail 😕 |
ce3c160 to
cac1276
Compare
|
Integration test results for cac1276: success 🎉 |
c9e7b2e to
2f77ba3
Compare
|
Integration test results for 2f77ba3: fail 😕 |
b2e39b3 to
f0c441d
Compare
|
Integration test results for f0c441d: fail 😕 |
f0c441d to
9cece5e
Compare
|
Integration test results for 9cece5e: success 🎉 |
alpeb
left a comment
There was a problem hiding this comment.
According to this
linkerd2/test/inject/inject_test.go
Line 128 in 9cece5e
you're relying on the proxy-injector that one of the
install_test.go runs set up to get the pods injected in TestAnnotationPermutations, right?
I got confused by that a little bit. I think it'd be better to disassociate tests more, by having install_test.go clean up the webhook after it's done, and setting a new one for this test (to also be cleaned when finished).
All the other changes looked good to me. I left below a couple of nits.
| patchJSON := []byte(`[ | ||
| {"op": "remove", "path": "/spec/template/metadata/annotations/linkerd.io~1created-by"}, | ||
| {"op": "remove", "path": "/spec/template/metadata/annotations/linkerd.io~1proxy-version"} | ||
| ]`) |
There was a problem hiding this comment.
Nice leverage of json-patch here 😉
test/inject/inject_test.go
Outdated
| @@ -0,0 +1,282 @@ | |||
| package get | |||
| case "", k8s.ProxyInjectDisabled: | ||
| switch podAnnotation { | ||
| case k8s.ProxyInjectEnabled: | ||
| shouldBeInjected = true |
There was a problem hiding this comment.
Why favoring a switch here instead of a simple if?
There was a problem hiding this comment.
It's completely subjective. I tried writing this both ways, and I find the switch slightly more readable than the if.
Here they are side-by-side, let me know what you think:
shouldBeInjected := false
if nsAnnotation == "" || nsAnnotation == k8s.ProxyInjectDisabled {
shouldBeInjected = podAnnotation == k8s.ProxyInjectEnabled
} else if nsAnnotation == k8s.ProxyInjectEnabled {
shouldBeInjected = (podAnnotation == "" || podAnnotation == k8s.ProxyInjectEnabled)
}shouldBeInjected := false
switch nsAnnotation {
case "", k8s.ProxyInjectDisabled:
switch podAnnotation {
case k8s.ProxyInjectEnabled:
shouldBeInjected = true
}
case k8s.ProxyInjectEnabled:
switch podAnnotation {
case "", k8s.ProxyInjectEnabled:
shouldBeInjected = true
}
}There was a problem hiding this comment.
The outer switch looks good. I was gonna say ifs are better in the inner conditions, but not so much for the second one where an or is involved. But it's definitely more readable keeping all switches for consistency-sake. I'm gonna steal this idiom ![]()
|
Actually I'm not sure about my previous comment anymore. All the integration tests rely on the setup done by |
|
@alpeb Yup there's an assumption with the integration tests that Agree that |
This change introduces integration tests for `linkerd inject`. The tests perform CLI injection, with and without params, and validates the output, including annotations. Also add some known errors in logs to `install_test.go`. TODO: - deploy uninjected and injected resources to a default and auto-injected cluster - test creation and update Part of #2459 Signed-off-by: Andrew Seigner <[email protected]>
Signed-off-by: Andrew Seigner <[email protected]>
cfbac81 to
88332c8
Compare
|
Integration test results for 88332c8: success 🎉 |
This change introduces integration tests for `linkerd inject`. The tests perform CLI injection, with and without params, and validates the output, including annotations. Also add some known errors in logs to `install_test.go`. TODO: - deploy uninjected and injected resources to a default and auto-injected cluster - test creation and update Part of linkerd#2459 Signed-off-by: Andrew Seigner <[email protected]> Signed-off-by: [email protected] <[email protected]>
This change introduces integration tests for
linkerd inject. The testsperform CLI injection, with and without params, and validates the
output, including annotations.
Also add some known errors in logs to
install_test.go.TODO:
auto-injected cluster
Part of #2459
Signed-off-by: Andrew Seigner [email protected]