e2e: accept context from Ginkgo

Every ginkgo callback should return immediately when a timeout occurs or the
test run manually gets aborted with CTRL-C. To do that, they must take a ctx
parameter and pass it through to all code which might block.

This is a first automated step towards that: the additional parameter got added
with

    sed -i 's/\(framework.ConformanceIt\|ginkgo.It\)\(.*\)func() {$/\1\2func(ctx context.Context) {/' \
        $(git grep -l -e framework.ConformanceIt -e ginkgo.It )
    $GOPATH/bin/goimports -w $(git status | grep modified: | sed -e 's/.* //')

log_test.go was left unchanged.
This commit is contained in:
Patrick Ohly
2022-10-17 14:47:15 +02:00
parent 63ff4a2659
commit df5d84ae81
291 changed files with 1542 additions and 1454 deletions

View File

@@ -17,6 +17,7 @@ limitations under the License.
package e2enode
import (
"context"
"fmt"
"net"
"os/exec"
@@ -43,7 +44,7 @@ var _ = SIGDescribe("Security Context", func() {
})
ginkgo.Context("[NodeConformance][LinuxOnly] Container PID namespace sharing", func() {
ginkgo.It("containers in pods using isolated PID namespaces should all receive PID 1", func() {
ginkgo.It("containers in pods using isolated PID namespaces should all receive PID 1", func(ctx context.Context) {
ginkgo.By("Create a pod with isolated PID namespaces.")
e2epod.NewPodClient(f).CreateSync(&v1.Pod{
ObjectMeta: metav1.ObjectMeta{Name: "isolated-pid-ns-test-pod"},
@@ -72,7 +73,7 @@ var _ = SIGDescribe("Security Context", func() {
}
})
ginkgo.It("processes in containers sharing a pod namespace should be able to see each other", func() {
ginkgo.It("processes in containers sharing a pod namespace should be able to see each other", func(ctx context.Context) {
ginkgo.By("Create a pod with shared PID namespace.")
e2epod.NewPodClient(f).CreateSync(&v1.Pod{
ObjectMeta: metav1.ObjectMeta{Name: "shared-pid-ns-test-pod"},
@@ -146,7 +147,7 @@ var _ = SIGDescribe("Security Context", func() {
nginxPid = strings.TrimSpace(output)
})
ginkgo.It("should show its pid in the host PID namespace [NodeFeature:HostAccess]", func() {
ginkgo.It("should show its pid in the host PID namespace [NodeFeature:HostAccess]", func(ctx context.Context) {
busyboxPodName := "busybox-hostpid-" + string(uuid.NewUUID())
createAndWaitHostPidPod(busyboxPodName, true)
logs, err := e2epod.GetPodLogs(f.ClientSet, f.Namespace.Name, busyboxPodName, busyboxPodName)
@@ -166,7 +167,7 @@ var _ = SIGDescribe("Security Context", func() {
}
})
ginkgo.It("should not show its pid in the non-hostpid containers [NodeFeature:HostAccess]", func() {
ginkgo.It("should not show its pid in the non-hostpid containers [NodeFeature:HostAccess]", func(ctx context.Context) {
busyboxPodName := "busybox-non-hostpid-" + string(uuid.NewUUID())
createAndWaitHostPidPod(busyboxPodName, false)
logs, err := e2epod.GetPodLogs(f.ClientSet, f.Namespace.Name, busyboxPodName, busyboxPodName)
@@ -222,7 +223,7 @@ var _ = SIGDescribe("Security Context", func() {
framework.Logf("Got host shared memory ID %q", hostSharedMemoryID)
})
ginkgo.It("should show the shared memory ID in the host IPC containers [NodeFeature:HostAccess]", func() {
ginkgo.It("should show the shared memory ID in the host IPC containers [NodeFeature:HostAccess]", func(ctx context.Context) {
ipcutilsPodName := "ipcutils-hostipc-" + string(uuid.NewUUID())
createAndWaitHostIPCPod(ipcutilsPodName, true)
logs, err := e2epod.GetPodLogs(f.ClientSet, f.Namespace.Name, ipcutilsPodName, ipcutilsPodName)
@@ -237,7 +238,7 @@ var _ = SIGDescribe("Security Context", func() {
}
})
ginkgo.It("should not show the shared memory ID in the non-hostIPC containers [NodeFeature:HostAccess]", func() {
ginkgo.It("should not show the shared memory ID in the non-hostIPC containers [NodeFeature:HostAccess]", func(ctx context.Context) {
ipcutilsPodName := "ipcutils-non-hostipc-" + string(uuid.NewUUID())
createAndWaitHostIPCPod(ipcutilsPodName, false)
logs, err := e2epod.GetPodLogs(f.ClientSet, f.Namespace.Name, ipcutilsPodName, ipcutilsPodName)
@@ -305,7 +306,7 @@ var _ = SIGDescribe("Security Context", func() {
framework.Logf("Opened a new tcp port %q", listeningPort)
})
ginkgo.It("should listen on same port in the host network containers [NodeFeature:HostAccess]", func() {
ginkgo.It("should listen on same port in the host network containers [NodeFeature:HostAccess]", func(ctx context.Context) {
busyboxPodName := "busybox-hostnetwork-" + string(uuid.NewUUID())
createAndWaitHostNetworkPod(busyboxPodName, true)
logs, err := e2epod.GetPodLogs(f.ClientSet, f.Namespace.Name, busyboxPodName, busyboxPodName)
@@ -319,7 +320,7 @@ var _ = SIGDescribe("Security Context", func() {
}
})
ginkgo.It("shouldn't show the same port in the non-hostnetwork containers [NodeFeature:HostAccess]", func() {
ginkgo.It("shouldn't show the same port in the non-hostnetwork containers [NodeFeature:HostAccess]", func(ctx context.Context) {
busyboxPodName := "busybox-non-hostnetwork-" + string(uuid.NewUUID())
createAndWaitHostNetworkPod(busyboxPodName, false)
logs, err := e2epod.GetPodLogs(f.ClientSet, f.Namespace.Name, busyboxPodName, busyboxPodName)