@@ -17,17 +17,22 @@ package inteldevicepluginsoperator
1717
1818import (
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
2932const (
3033 kustomizationYaml = "deployments/operator/default/kustomization.yaml"
34+ ns = "inteldeviceplugins-system"
35+ timeout = time .Second * 120
3136)
3237
3338func 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}
0 commit comments