mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-11-28 12:21:12 +00:00
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:
@@ -57,11 +57,11 @@ var _ = SIGDescribe("AppArmor [Feature:AppArmor][NodeFeature:AppArmor]", func()
|
||||
f := framework.NewDefaultFramework("apparmor-test")
|
||||
f.NamespacePodSecurityEnforceLevel = admissionapi.LevelPrivileged
|
||||
|
||||
ginkgo.It("should reject an unloaded profile", func() {
|
||||
ginkgo.It("should reject an unloaded profile", func(ctx context.Context) {
|
||||
status := runAppArmorTest(f, false, v1.AppArmorBetaProfileNamePrefix+"non-existent-profile")
|
||||
gomega.Expect(status.ContainerStatuses[0].State.Waiting.Message).To(gomega.ContainSubstring("apparmor"))
|
||||
})
|
||||
ginkgo.It("should enforce a profile blocking writes", func() {
|
||||
ginkgo.It("should enforce a profile blocking writes", func(ctx context.Context) {
|
||||
status := runAppArmorTest(f, true, v1.AppArmorBetaProfileNamePrefix+apparmorProfilePrefix+"deny-write")
|
||||
if len(status.ContainerStatuses) == 0 {
|
||||
framework.Failf("Unexpected pod status: %s", spew.Sdump(status))
|
||||
@@ -72,7 +72,7 @@ var _ = SIGDescribe("AppArmor [Feature:AppArmor][NodeFeature:AppArmor]", func()
|
||||
gomega.Expect(state.ExitCode).To(gomega.Not(gomega.BeZero()), "ContainerStateTerminated: %+v", state)
|
||||
|
||||
})
|
||||
ginkgo.It("should enforce a permissive profile", func() {
|
||||
ginkgo.It("should enforce a permissive profile", func(ctx context.Context) {
|
||||
status := runAppArmorTest(f, true, v1.AppArmorBetaProfileNamePrefix+apparmorProfilePrefix+"audit-write")
|
||||
if len(status.ContainerStatuses) == 0 {
|
||||
framework.Failf("Unexpected pod status: %s", spew.Sdump(status))
|
||||
@@ -88,7 +88,7 @@ var _ = SIGDescribe("AppArmor [Feature:AppArmor][NodeFeature:AppArmor]", func()
|
||||
f := framework.NewDefaultFramework("apparmor-test")
|
||||
f.NamespacePodSecurityEnforceLevel = admissionapi.LevelPrivileged
|
||||
|
||||
ginkgo.It("should reject a pod with an AppArmor profile", func() {
|
||||
ginkgo.It("should reject a pod with an AppArmor profile", func(ctx context.Context) {
|
||||
status := runAppArmorTest(f, false, v1.AppArmorBetaProfileRuntimeDefault)
|
||||
expectSoftRejection(status)
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user