1
16
17
18
19 package storage
20
21 import (
22 "context"
23
24 "github.com/onsi/ginkgo/v2"
25 v1 "k8s.io/api/core/v1"
26 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
27 clientset "k8s.io/client-go/kubernetes"
28 "k8s.io/kubernetes/test/e2e/framework"
29 e2evolume "k8s.io/kubernetes/test/e2e/framework/volume"
30 "k8s.io/kubernetes/test/e2e/storage/utils"
31 admissionapi "k8s.io/pod-security-admission/api"
32 )
33
34
35 var _ = utils.SIGDescribe("Volumes", func() {
36 f := framework.NewDefaultFramework("volume")
37 f.NamespacePodSecurityLevel = admissionapi.LevelBaseline
38
39
40
41 var cs clientset.Interface
42 var namespace *v1.Namespace
43
44 ginkgo.BeforeEach(func() {
45 cs = f.ClientSet
46 namespace = f.Namespace
47 })
48
49 ginkgo.Describe("ConfigMap", func() {
50 ginkgo.It("should be mountable", func(ctx context.Context) {
51 config := e2evolume.TestConfig{
52 Namespace: namespace.Name,
53 Prefix: "configmap",
54 }
55 configMap := &v1.ConfigMap{
56 TypeMeta: metav1.TypeMeta{
57 Kind: "ConfigMap",
58 APIVersion: "v1",
59 },
60 ObjectMeta: metav1.ObjectMeta{
61 Name: config.Prefix + "-map",
62 },
63 Data: map[string]string{
64 "first": "this is the first file",
65 "second": "this is the second file",
66 "third": "this is the third file",
67 },
68 }
69 if _, err := cs.CoreV1().ConfigMaps(namespace.Name).Create(ctx, configMap, metav1.CreateOptions{}); err != nil {
70 framework.Failf("unable to create test configmap: %v", err)
71 }
72 defer func() {
73 _ = cs.CoreV1().ConfigMaps(namespace.Name).Delete(ctx, configMap.Name, metav1.DeleteOptions{})
74 }()
75
76
77 tests := []e2evolume.Test{
78 {
79 Volume: v1.VolumeSource{
80 ConfigMap: &v1.ConfigMapVolumeSource{
81 LocalObjectReference: v1.LocalObjectReference{
82 Name: config.Prefix + "-map",
83 },
84 Items: []v1.KeyToPath{
85 {
86 Key: "first",
87 Path: "firstfile",
88 },
89 },
90 },
91 },
92 File: "firstfile",
93 ExpectedContent: "this is the first file",
94 },
95 {
96 Volume: v1.VolumeSource{
97 ConfigMap: &v1.ConfigMapVolumeSource{
98 LocalObjectReference: v1.LocalObjectReference{
99 Name: config.Prefix + "-map",
100 },
101 Items: []v1.KeyToPath{
102 {
103 Key: "second",
104 Path: "secondfile",
105 },
106 },
107 },
108 },
109 File: "secondfile",
110 ExpectedContent: "this is the second file",
111 },
112 }
113 e2evolume.TestVolumeClient(ctx, f, config, nil, "" , tests)
114 })
115 })
116 })
117
View as plain text