@@ -17,17 +17,22 @@ package inteldevicepluginsoperator
17
17
18
18
import (
19
19
"context"
20
+ "time"
20
21
21
22
"github.com/intel/intel-device-plugins-for-kubernetes/test/e2e/utils"
22
23
"github.com/onsi/ginkgo/v2"
23
24
"github.com/onsi/gomega"
24
25
v1 "k8s.io/api/core/v1"
26
+ "k8s.io/apimachinery/pkg/labels"
25
27
"k8s.io/kubernetes/test/e2e/framework"
28
+ e2epod "k8s.io/kubernetes/test/e2e/framework/pod"
26
29
admissionapi "k8s.io/pod-security-admission/api"
27
30
)
28
31
29
32
const (
30
33
kustomizationYaml = "deployments/operator/default/kustomization.yaml"
34
+ ns = "inteldeviceplugins-system"
35
+ timeout = time .Second * 120
31
36
)
32
37
33
38
func init () {
@@ -41,11 +46,17 @@ func describe() {
41
46
var webhook v1.Pod
42
47
43
48
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 )
47
54
}
48
- webhook = utils .DeployWebhook (ctx , f , kustomizationPath )
55
+ })
56
+
57
+ ginkgo .AfterEach (func () {
58
+ ginkgo .By ("undeploying operator" )
59
+ utils .Kubectl ("" , "delete" , "-k" , kustomizationYaml )
49
60
})
50
61
51
62
ginkgo .It ("checks the operator webhook pod is safely configured" , func (ctx context.Context ) {
@@ -54,4 +65,34 @@ func describe() {
54
65
err = utils .TestWebhookServerTLS (ctx , f , "https://inteldeviceplugins-webhook-service" )
55
66
gomega .Expect (err ).To (gomega .BeNil ())
56
67
})
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 )
57
98
}
0 commit comments