Skip to content

Commit 91d826f

Browse files
Merge pull request #1472 from hj-johannes-lee/PR-2023-022
e2e: remove duplicate code of testing with operator
2 parents 5ce4a9b + bec3dd0 commit 91d826f

File tree

4 files changed

+45
-82
lines changed

4 files changed

+45
-82
lines changed

test/e2e/dsa/dsa.go

-24
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

-24
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

+45-4
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

-30
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)