Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: Avoid panics due to dereferencing a nil error
Set 'CmdRes.err' to a non-nil value when command is not successful. Also avoid calling 'Error()' on an error explicitly, so that no panics are caused when the error is 'nil'. This avoids test failures like this: STEP: Deleting namespace 2020022720301k8spolicytestclusterwidepoliciestestclusterwidecon ! Panic in Spec Setup (BeforeEach) [38.899 seconds] K8sPolicyTest /Users/jarno/go/src/github.com/cilium/cilium/test/ginkgo-ext/scopes.go:395 Clusterwide policies /Users/jarno/go/src/github.com/cilium/cilium/test/ginkgo-ext/scopes.go:395 Test clusterwide connectivity with policies [BeforeEach] /Users/jarno/go/src/github.com/cilium/cilium/test/ginkgo-ext/scopes.go:430 Test Panicked runtime error: invalid memory address or nil pointer dereference /Users/jarno/go/src/github.com/cilium/cilium/test/ginkgo-ext/scopes.go:374 Full Stack Trace github.com/cilium/cilium/test/ginkgo-ext.BeforeEach.func1.1(0xc000448900) /Users/jarno/go/src/github.com/cilium/cilium/test/ginkgo-ext/scopes.go:374 +0x5e panic(0x26993c0, 0x3ba0bd0) /usr/local/Cellar/go/1.13.8/libexec/src/runtime/panic.go:679 +0x1b2 github.com/cilium/cilium/test/helpers.(*Kubectl).NamespaceDelete(0xc000384e40, 0xc000811aa0, 0x3f, 0x2) /Users/jarno/go/src/github.com/cilium/cilium/test/helpers/kubectl.go:859 +0x2eb github.com/cilium/cilium/test/k8sT.glob..func7.11.1() /Users/jarno/go/src/github.com/cilium/cilium/test/k8sT/Policies.go:1375 +0x5b1 github.com/cilium/cilium/test/ginkgo-ext.BeforeEach.func1() Signed-off-by: Jarno Rajahalme <jarno@covalent.io>
- Loading branch information