Skip to content

Commit bec3dd0

Browse files
e2e: remove duplicate code of testing with operator
move duplicate code for testing plugins using operator to operator module replace the code for deploying operator webhook in operator module with the code using utils.Kubectl to make simple for undeploying Signed-off-by: Hyeongju Johannes Lee <hyeongju.lee@intel.com>
1 parent e57723c commit bec3dd0

File tree

4 files changed

+45
-82
lines changed

4 files changed

+45
-82
lines changed

test/e2e/dsa/dsa.go

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -119,28 +119,4 @@ func describe() {
119119
})
120120
})
121121
})
122-
123-
ginkgo.Describe("With using operator", func() {
124-
ginkgo.It("deploys DSA plugin with operator", func(ctx context.Context) {
125-
utils.Kubectl("", "apply", "-k", "deployments/operator/default/kustomization.yaml")
126-
127-
if _, err := e2epod.WaitForPodsWithLabelRunningReady(ctx, f.ClientSet, ns, labels.Set{"control-plane": "controller-manager"}.AsSelector(), 1, timeout); err != nil {
128-
framework.Failf("unable to wait for all pods to be running and ready: %v", err)
129-
}
130-
131-
utils.Kubectl("", "apply", "-f", "deployments/operator/samples/deviceplugin_v1_dsadeviceplugin.yaml")
132-
133-
if _, err := e2epod.WaitForPodsWithLabelRunningReady(ctx, f.ClientSet, ns, labels.Set{"app": "intel-dsa-plugin"}.AsSelector(), 1, timeout); err != nil {
134-
framework.Failf("unable to wait for all pods to be running and ready: %v", err)
135-
}
136-
137-
if err := utils.WaitForNodesWithResource(ctx, f.ClientSet, "dsa.intel.com/wq-user-dedicated", timeout); err != nil {
138-
framework.Failf("unable to wait for nodes to have positive allocatable resource: %v", err)
139-
}
140-
141-
utils.Kubectl("", "delete", "-f", "deployments/operator/samples/deviceplugin_v1_dsadeviceplugin.yaml")
142-
143-
utils.Kubectl("", "delete", "-k", "deployments/operator/default/kustomization.yaml")
144-
})
145-
})
146122
}

test/e2e/iaa/iaa.go

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -119,28 +119,4 @@ func describe() {
119119
})
120120
})
121121
})
122-
123-
ginkgo.Describe("With using operator", func() {
124-
ginkgo.It("deploys IAA plugin with operator", func(ctx context.Context) {
125-
utils.Kubectl("", "apply", "-k", "deployments/operator/default/kustomization.yaml")
126-
127-
if _, err := e2epod.WaitForPodsWithLabelRunningReady(ctx, f.ClientSet, ns, labels.Set{"control-plane": "controller-manager"}.AsSelector(), 1, timeout); err != nil {
128-
framework.Failf("unable to wait for all pods to be running and ready: %v", err)
129-
}
130-
131-
utils.Kubectl("", "apply", "-f", "deployments/operator/samples/deviceplugin_v1_iaadeviceplugin.yaml")
132-
133-
if _, err := e2epod.WaitForPodsWithLabelRunningReady(ctx, f.ClientSet, ns, labels.Set{"app": "intel-iaa-plugin"}.AsSelector(), 1, timeout); err != nil {
134-
framework.Failf("unable to wait for all pods to be running and ready: %v", err)
135-
}
136-
137-
if err := utils.WaitForNodesWithResource(ctx, f.ClientSet, "iaa.intel.com/wq-user-dedicated", timeout); err != nil {
138-
framework.Failf("unable to wait for nodes to have positive allocatable resource: %v", err)
139-
}
140-
141-
utils.Kubectl("", "delete", "-f", "deployments/operator/samples/deviceplugin_v1_iaadeviceplugin.yaml")
142-
143-
utils.Kubectl("", "delete", "-k", "deployments/operator/default/kustomization.yaml")
144-
})
145-
})
146122
}

test/e2e/operator/operator.go

Lines changed: 45 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,22 @@ package inteldevicepluginsoperator
1717

1818
import (
1919
"context"
20+
"time"
2021

2122
"github.com/intel/intel-device-plugins-for-kubernetes/test/e2e/utils"
2223
"github.com/onsi/ginkgo/v2"
2324
"github.com/onsi/gomega"
2425
v1 "k8s.io/api/core/v1"
26+
"k8s.io/apimachinery/pkg/labels"
2527
"k8s.io/kubernetes/test/e2e/framework"
28+
e2epod "k8s.io/kubernetes/test/e2e/framework/pod"
2629
admissionapi "k8s.io/pod-security-admission/api"
2730
)
2831

2932
const (
3033
kustomizationYaml = "deployments/operator/default/kustomization.yaml"
34+
ns = "inteldeviceplugins-system"
35+
timeout = time.Second * 120
3136
)
3237

3338
func init() {
@@ -41,11 +46,17 @@ func describe() {
4146
var webhook v1.Pod
4247

4348
ginkgo.BeforeEach(func(ctx context.Context) {
44-
kustomizationPath, err := utils.LocateRepoFile(kustomizationYaml)
45-
if err != nil {
46-
framework.Failf("unable to locate %q: %v", kustomizationYaml, err)
49+
ginkgo.By("deploying operator")
50+
utils.Kubectl("", "apply", "-k", kustomizationYaml)
51+
52+
if _, err := e2epod.WaitForPodsWithLabelRunningReady(ctx, f.ClientSet, ns, labels.Set{"control-plane": "controller-manager"}.AsSelector(), 1, timeout); err != nil {
53+
framework.Failf("unable to wait for all pods to be running and ready: %v", err)
4754
}
48-
webhook = utils.DeployWebhook(ctx, f, kustomizationPath)
55+
})
56+
57+
ginkgo.AfterEach(func() {
58+
ginkgo.By("undeploying operator")
59+
utils.Kubectl("", "delete", "-k", kustomizationYaml)
4960
})
5061

5162
ginkgo.It("checks the operator webhook pod is safely configured", func(ctx context.Context) {
@@ -54,4 +65,34 @@ func describe() {
5465
err = utils.TestWebhookServerTLS(ctx, f, "https://inteldeviceplugins-webhook-service")
5566
gomega.Expect(err).To(gomega.BeNil())
5667
})
68+
69+
ginkgo.It("deploys IAA plugin with operator", func(ctx context.Context) {
70+
testPluginWithOperator("iaa", []v1.ResourceName{"iaa.intel.com/wq-user-dedicated"}, f, ctx)
71+
})
72+
73+
ginkgo.It("deploys DSA plugin with operator", func(ctx context.Context) {
74+
testPluginWithOperator("dsa", []v1.ResourceName{"dsa.intel.com/wq-user-dedicated"}, f, ctx)
75+
})
76+
77+
ginkgo.It("deploys SGX plugin with operator", func(ctx context.Context) {
78+
testPluginWithOperator("sgx", []v1.ResourceName{"sgx.intel.com/epc", "sgx.intel.com/enclave", "sgx.intel.com/provision"}, f, ctx)
79+
})
80+
}
81+
82+
func testPluginWithOperator(deviceName string, resourceNames []v1.ResourceName, f *framework.Framework, ctx context.Context) {
83+
dpSampleYaml := "deployments/operator/samples/deviceplugin_v1_" + deviceName + "deviceplugin.yaml"
84+
85+
utils.Kubectl("", "apply", "-f", dpSampleYaml)
86+
87+
if _, err := e2epod.WaitForPodsWithLabelRunningReady(ctx, f.ClientSet, ns, labels.Set{"app": "intel-" + deviceName + "-plugin"}.AsSelector(), 1, timeout); err != nil {
88+
framework.Failf("unable to wait for all pods to be running and ready: %v", err)
89+
}
90+
91+
for _, resourceName := range resourceNames {
92+
if err := utils.WaitForNodesWithResource(ctx, f.ClientSet, resourceName, timeout); err != nil {
93+
framework.Failf("unable to wait for nodes to have positive allocatable resource: %v", err)
94+
}
95+
}
96+
97+
utils.Kubectl("", "delete", "-f", dpSampleYaml)
5798
}

test/e2e/sgx/sgx.go

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -118,34 +118,4 @@ func describe() {
118118

119119
e2ekubectl.RunKubectlOrDie(f.Namespace.Name, "delete", "-k", filepath.Dir(deploymentPluginPath))
120120
})
121-
122-
ginkgo.It("deploys SGX plugin with operator", func(ctx context.Context) {
123-
utils.Kubectl("", "apply", "-k", "deployments/operator/default/kustomization.yaml")
124-
125-
if _, err := e2epod.WaitForPodsWithLabelRunningReady(ctx, f.ClientSet, ns, labels.Set{"control-plane": "controller-manager"}.AsSelector(), 1, timeout); err != nil {
126-
framework.Failf("unable to wait for all pods to be running and ready: %v", err)
127-
}
128-
129-
utils.Kubectl("", "apply", "-f", "deployments/operator/samples/deviceplugin_v1_sgxdeviceplugin.yaml")
130-
131-
if _, err := e2epod.WaitForPodsWithLabelRunningReady(ctx, f.ClientSet, ns, labels.Set{"app": "intel-sgx-plugin"}.AsSelector(), 1, timeout); err != nil {
132-
framework.Failf("unable to wait for all pods to be running and ready: %v", err)
133-
}
134-
135-
if err := utils.WaitForNodesWithResource(ctx, f.ClientSet, "sgx.intel.com/epc", 150*time.Second); err != nil {
136-
framework.Failf("unable to wait for nodes to have positive allocatable epc resource: %v", err)
137-
}
138-
139-
if err := utils.WaitForNodesWithResource(ctx, f.ClientSet, "sgx.intel.com/enclave", 30*time.Second); err != nil {
140-
framework.Failf("unable to wait for nodes to have positive allocatable enclave resource: %v", err)
141-
}
142-
143-
if err := utils.WaitForNodesWithResource(ctx, f.ClientSet, "sgx.intel.com/provision", 30*time.Second); err != nil {
144-
framework.Failf("unable to wait for nodes to have positive allocatable provision resource: %v", err)
145-
}
146-
147-
utils.Kubectl("", "delete", "-f", "deployments/operator/samples/deviceplugin_v1_sgxdeviceplugin.yaml")
148-
149-
utils.Kubectl("", "delete", "-k", "deployments/operator/default/kustomization.yaml")
150-
})
151121
}

0 commit comments

Comments
 (0)