From 396e2bc58155295ab7fa638c8bda57c3f7402931 Mon Sep 17 00:00:00 2001 From: Jan Safranek Date: Mon, 19 Dec 2016 10:33:38 +0100 Subject: [PATCH] Add configmap test --- test/e2e/volumes.go | 78 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) diff --git a/test/e2e/volumes.go b/test/e2e/volumes.go index 08caf7054d3..3119b3d52d0 100644 --- a/test/e2e/volumes.go +++ b/test/e2e/volumes.go @@ -828,4 +828,82 @@ var _ = framework.KubeDescribe("Volumes [Feature:Volumes]", func() { testVolumeClient(cs, config, &fsGroup, tests) }) }) + + //////////////////////////////////////////////////////////////////////// + // ConfigMap + //////////////////////////////////////////////////////////////////////// + + framework.KubeDescribe("ConfigMap", func() { + It("should be mountable", func() { + config := VolumeTestConfig{ + namespace: namespace.Name, + prefix: "configmap", + } + + defer func() { + if clean { + volumeTestCleanup(f, config) + } + }() + configMap := &v1.ConfigMap{ + TypeMeta: metav1.TypeMeta{ + Kind: "ConfigMap", + APIVersion: "v1", + }, + ObjectMeta: v1.ObjectMeta{ + Name: config.prefix + "-map", + }, + Data: map[string]string{ + "first": "this is the first file", + "second": "this is the second file", + "third": "this is the third file", + }, + } + if _, err := cs.Core().ConfigMaps(namespace.Name).Create(configMap); err != nil { + framework.Failf("unable to create test configmap: %v", err) + } + defer func() { + _ = cs.Core().ConfigMaps(namespace.Name).Delete(configMap.Name, nil) + }() + + // Test one ConfigMap mounted several times to test #28502 + tests := []VolumeTest{ + { + volume: v1.VolumeSource{ + ConfigMap: &v1.ConfigMapVolumeSource{ + LocalObjectReference: v1.LocalObjectReference{ + Name: config.prefix + "-map", + }, + Items: []v1.KeyToPath{ + { + Key: "first", + Path: "firstfile", + }, + }, + }, + }, + file: "firstfile", + expectedContent: "this is the first file", + }, + { + volume: v1.VolumeSource{ + ConfigMap: &v1.ConfigMapVolumeSource{ + LocalObjectReference: v1.LocalObjectReference{ + Name: config.prefix + "-map", + }, + Items: []v1.KeyToPath{ + { + Key: "second", + Path: "secondfile", + }, + }, + }, + }, + file: "secondfile", + expectedContent: "this is the second file", + }, + } + testVolumeClient(cs, config, nil, tests) + }) + }) })