Skip to content

Commit 77ad32e

Browse files
e2e, iaa: divide single It() to have multiple layers
Structure is as follows: Describe("IAA plugin") Describe("without using operator") BeforeEach("deploys plugin") Context("When device resources are available") BeforeEach("checks if resources are available") It("runs a pod requesting resources") Describe("with using operator") It("deploys with operator") Signed-off-by: Hyeongju Johannes Lee <hyeongju.lee@intel.com>
1 parent fc0d0b5 commit 77ad32e

File tree

1 file changed

+62
-52
lines changed

1 file changed

+62
-52
lines changed

test/e2e/iaa/iaa.go

Lines changed: 62 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -60,65 +60,75 @@ func describe() {
6060
framework.Failf("unable to locate %q: %v", demoYaml, err)
6161
}
6262

63-
ginkgo.It("runs IAA plugin and a demo workload", func() {
64-
ginkgo.By("deploying IAA plugin")
65-
e2ekubectl.RunKubectlOrDie(f.Namespace.Name, "create", "configmap", "intel-iaa-config", "--from-file="+configmap)
66-
67-
e2ekubectl.RunKubectlOrDie(f.Namespace.Name, "apply", "-k", filepath.Dir(kustomizationPath))
68-
69-
ginkgo.By("waiting for IAA plugin's availability")
70-
podList, err := e2epod.WaitForPodsWithLabelRunningReady(f.ClientSet, f.Namespace.Name,
71-
labels.Set{"app": "intel-iaa-plugin"}.AsSelector(), 1 /* one replica */, 300*time.Second)
72-
if err != nil {
73-
e2edebug.DumpAllNamespaceInfo(f.ClientSet, f.Namespace.Name)
74-
e2ekubectl.LogFailedContainers(f.ClientSet, f.Namespace.Name, framework.Logf)
75-
framework.Failf("unable to wait for all pods to be running and ready: %v", err)
76-
}
77-
78-
ginkgo.By("checking IAA plugin's securityContext")
79-
if err = utils.TestPodsFileSystemInfo(podList.Items); err != nil {
80-
framework.Failf("container filesystem info checks failed: %v", err)
81-
}
82-
83-
ginkgo.By("checking if the resource is allocatable")
84-
if err = utils.WaitForNodesWithResource(f.ClientSet, "iaa.intel.com/wq-user-dedicated", 300*time.Second); err != nil {
85-
framework.Failf("unable to wait for nodes to have positive allocatable resource: %v", err)
86-
}
87-
88-
e2ekubectl.RunKubectlOrDie(f.Namespace.Name, "apply", "-f", demoPath)
89-
90-
ginkgo.By("waiting for the IAA demo to succeed")
91-
e2epod.NewPodClient(f).WaitForSuccess(podName, 300*time.Second)
92-
93-
ginkgo.By("getting workload log")
94-
log, err := e2epod.GetPodLogs(f.ClientSet, f.Namespace.Name, podName, podName)
95-
96-
if err != nil {
97-
framework.Failf("unable to get log from pod: %v", err)
98-
}
99-
100-
framework.Logf("log output: %s", log)
63+
ginkgo.Describe("Without using operator", func() {
64+
ginkgo.BeforeEach(func() {
65+
ginkgo.By("deploying IAA plugin")
66+
e2ekubectl.RunKubectlOrDie(f.Namespace.Name, "create", "configmap", "intel-iaa-config", "--from-file="+configmap)
67+
68+
e2ekubectl.RunKubectlOrDie(f.Namespace.Name, "apply", "-k", filepath.Dir(kustomizationPath))
69+
70+
ginkgo.By("waiting for IAA plugin's availability")
71+
podList, err := e2epod.WaitForPodsWithLabelRunningReady(f.ClientSet, f.Namespace.Name,
72+
labels.Set{"app": "intel-iaa-plugin"}.AsSelector(), 1 /* one replica */, 300*time.Second)
73+
if err != nil {
74+
e2edebug.DumpAllNamespaceInfo(f.ClientSet, f.Namespace.Name)
75+
e2ekubectl.LogFailedContainers(f.ClientSet, f.Namespace.Name, framework.Logf)
76+
framework.Failf("unable to wait for all pods to be running and ready: %v", err)
77+
}
78+
79+
ginkgo.By("checking IAA plugin's securityContext")
80+
if err = utils.TestPodsFileSystemInfo(podList.Items); err != nil {
81+
framework.Failf("container filesystem info checks failed: %v", err)
82+
}
83+
})
84+
85+
ginkgo.Context("When IAA resources are available", func() {
86+
ginkgo.BeforeEach(func() {
87+
ginkgo.By("checking if the resource is allocatable")
88+
if err := utils.WaitForNodesWithResource(f.ClientSet, "iaa.intel.com/wq-user-dedicated", 300*time.Second); err != nil {
89+
framework.Failf("unable to wait for nodes to have positive allocatable resource: %v", err)
90+
}
91+
})
92+
93+
ginkgo.It("deploys a demo app", func() {
94+
e2ekubectl.RunKubectlOrDie(f.Namespace.Name, "apply", "-f", demoPath)
95+
96+
ginkgo.By("waiting for the IAA demo to succeed")
97+
e2epod.NewPodClient(f).WaitForSuccess(podName, 300*time.Second)
98+
99+
ginkgo.By("getting workload log")
100+
log, err := e2epod.GetPodLogs(f.ClientSet, f.Namespace.Name, podName, podName)
101+
102+
if err != nil {
103+
framework.Failf("unable to get log from pod: %v", err)
104+
}
105+
106+
framework.Logf("log output: %s", log)
107+
})
108+
})
101109
})
102110

103-
ginkgo.It("deploys IAA plugin with operator", func() {
104-
utils.Kubectl("", "apply", "-k", "deployments/operator/default/kustomization.yaml")
111+
ginkgo.Describe("With using operator", func() {
112+
ginkgo.It("deploys IAA plugin with operator", func() {
113+
utils.Kubectl("", "apply", "-k", "deployments/operator/default/kustomization.yaml")
105114

106-
if _, err := e2epod.WaitForPodsWithLabelRunningReady(f.ClientSet, ns, labels.Set{"control-plane": "controller-manager"}.AsSelector(), 1, timeout); err != nil {
107-
framework.Failf("unable to wait for all pods to be running and ready: %v", err)
108-
}
115+
if _, err := e2epod.WaitForPodsWithLabelRunningReady(f.ClientSet, ns, labels.Set{"control-plane": "controller-manager"}.AsSelector(), 1, timeout); err != nil {
116+
framework.Failf("unable to wait for all pods to be running and ready: %v", err)
117+
}
109118

110-
utils.Kubectl("", "apply", "-f", "deployments/operator/samples/deviceplugin_v1_iaadeviceplugin.yaml")
119+
utils.Kubectl("", "apply", "-f", "deployments/operator/samples/deviceplugin_v1_iaadeviceplugin.yaml")
111120

112-
if _, err := e2epod.WaitForPodsWithLabelRunningReady(f.ClientSet, ns, labels.Set{"app": "intel-iaa-plugin"}.AsSelector(), 1, timeout); err != nil {
113-
framework.Failf("unable to wait for all pods to be running and ready: %v", err)
114-
}
121+
if _, err := e2epod.WaitForPodsWithLabelRunningReady(f.ClientSet, ns, labels.Set{"app": "intel-iaa-plugin"}.AsSelector(), 1, timeout); err != nil {
122+
framework.Failf("unable to wait for all pods to be running and ready: %v", err)
123+
}
115124

116-
if err := utils.WaitForNodesWithResource(f.ClientSet, "iaa.intel.com/wq-user-dedicated", timeout); err != nil {
117-
framework.Failf("unable to wait for nodes to have positive allocatable resource: %v", err)
118-
}
125+
if err := utils.WaitForNodesWithResource(f.ClientSet, "iaa.intel.com/wq-user-dedicated", timeout); err != nil {
126+
framework.Failf("unable to wait for nodes to have positive allocatable resource: %v", err)
127+
}
119128

120-
utils.Kubectl("", "delete", "-f", "deployments/operator/samples/deviceplugin_v1_iaadeviceplugin.yaml")
129+
utils.Kubectl("", "delete", "-f", "deployments/operator/samples/deviceplugin_v1_iaadeviceplugin.yaml")
121130

122-
utils.Kubectl("", "delete", "-k", "deployments/operator/default/kustomization.yaml")
131+
utils.Kubectl("", "delete", "-k", "deployments/operator/default/kustomization.yaml")
132+
})
123133
})
124134
}

0 commit comments

Comments
 (0)