This repository has been archived by the owner on Jan 21, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
csidriver_test.go
69 lines (64 loc) · 2.26 KB
/
csidriver_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
package main_test
import (
local_k8s_cluster "code.cloudfoundry.org/smb-volume-k8s-local-cluster"
"encoding/json"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"os"
"time"
)
type CSIDriversInfo struct {
APIVersion string `json:"apiVersion"`
Items []Items `json:"items"`
Kind string `json:"kind"`
Metadata Metadata `json:"metadata"`
}
type Annotations struct {
KubectlKubernetesIoLastAppliedConfiguration string `json:"kubectl.kubernetes.io/last-applied-configuration"`
}
type Items struct {
APIVersion string `json:"apiVersion"`
Kind string `json:"kind"`
Metadata CSIDriverMeta `json:"metadata"`
Spec CSIDriverSpec `json:"spec"`
}
type CSIDriverMeta struct {
Annotations Annotations `json:"annotations"`
CreationTimestamp time.Time `json:"creationTimestamp"`
Name string `json:"name"`
ResourceVersion string `json:"resourceVersion"`
SelfLink string `json:"selfLink"`
UID string `json:"uid"`
}
type CSIDriverSpec struct {
AttachRequired bool `json:"attachRequired"`
PodInfoOnMount bool `json:"podInfoOnMount"`
VolumeLifecycleModes []string `json:"volumeLifecycleModes"`
}
type Metadata struct {
ResourceVersion string `json:"resourceVersion"`
SelfLink string `json:"selfLink"`
}
var _ = Describe("CSIDriver object", func() {
It("should register a CSIDriver object", func() {
getCsiDriverOutout := local_k8s_cluster.Kubectl("get", "csidriver", "-o", "json")
csiDriverInfos := CSIDriversInfo{}
Expect(json.Unmarshal([]byte(getCsiDriverOutout), &csiDriverInfos)).NotTo(HaveOccurred())
var csiDriver Items
for _, csiDriverInfo := range csiDriverInfos.Items {
if csiDriverInfo.Metadata.Name == "org.cloudfoundry.smb" {
csiDriver = csiDriverInfo
}
}
Expect(csiDriver).NotTo(BeNil())
Expect(csiDriver.Spec.AttachRequired).To(BeFalse())
Expect(csiDriver.Spec.PodInfoOnMount).To(BeFalse())
k8sVersion := os.Getenv("K8S_IMAGE")
if k8sVersion == "kindest/node:v1.15.7" {
Expect(csiDriver.Spec.VolumeLifecycleModes).To(BeNil())
} else {
Expect(csiDriver.Spec.VolumeLifecycleModes).To(ContainElement("Persistent"))
Expect(csiDriver.Spec.VolumeLifecycleModes).NotTo(ContainElement("Ephemeral"))
}
})
})