From 81c91819950959d272bf565f52250da599f6bbaf Mon Sep 17 00:00:00 2001 From: "Tim St. Clair" Date: Wed, 31 May 2017 12:58:43 -0700 Subject: [PATCH] Capture better debug logs on AppArmor test failure --- test/e2e/apparmor.go | 21 ++++++++++++++------- test/e2e/common/apparmor.go | 1 + 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/test/e2e/apparmor.go b/test/e2e/apparmor.go index 389d549045d..5bff1f974f9 100644 --- a/test/e2e/apparmor.go +++ b/test/e2e/apparmor.go @@ -26,13 +26,20 @@ import ( var _ = framework.KubeDescribe("AppArmor", func() { f := framework.NewDefaultFramework("apparmor") - BeforeEach(func() { - common.SkipIfAppArmorNotSupported() - common.LoadAppArmorProfiles(f) - }) + Context("load AppArmor profiles", func() { + BeforeEach(func() { + common.SkipIfAppArmorNotSupported() + common.LoadAppArmorProfiles(f) + }) + AfterEach(func() { + if !CurrentGinkgoTestDescription().Failed { + return + } + framework.LogFailedContainers(f.ClientSet, f.Namespace.Name, framework.Logf) + }) - It("should enforce an AppArmor profile", func() { - common.CreateAppArmorTestPod(f, true) - framework.LogFailedContainers(f.ClientSet, f.Namespace.Name, framework.Logf) + It("should enforce an AppArmor profile", func() { + common.CreateAppArmorTestPod(f, true) + }) }) }) diff --git a/test/e2e/common/apparmor.go b/test/e2e/common/apparmor.go index 68906cf70b8..5604ae65a11 100644 --- a/test/e2e/common/apparmor.go +++ b/test/e2e/common/apparmor.go @@ -60,6 +60,7 @@ elif ! touch %[2]s; then exit 2 elif ! grep "%[3]s" /proc/1/attr/current; then echo "FAILURE: not running with expected profile %[3]s" + echo "found: $(cat /proc/1/attr/current)" exit 3 fi`, appArmorDeniedPath, appArmorAllowedPath, appArmorProfilePrefix+f.Namespace.Name)