2015-02-20 05:36:23 +00:00
|
|
|
/*
|
2016-06-03 00:25:58 +00:00
|
|
|
Copyright 2015 The Kubernetes Authors.
|
2015-02-20 05:36:23 +00:00
|
|
|
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
you may not use this file except in compliance with the License.
|
|
|
|
You may obtain a copy of the License at
|
|
|
|
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
See the License for the specific language governing permissions and
|
|
|
|
limitations under the License.
|
|
|
|
*/
|
|
|
|
|
|
|
|
package downwardapi
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"io/ioutil"
|
|
|
|
"os"
|
|
|
|
"path"
|
|
|
|
"testing"
|
|
|
|
|
2017-06-22 18:24:23 +00:00
|
|
|
"k8s.io/api/core/v1"
|
2017-01-17 03:38:19 +00:00
|
|
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
2017-01-11 14:09:48 +00:00
|
|
|
"k8s.io/apimachinery/pkg/types"
|
2017-06-23 20:56:37 +00:00
|
|
|
clientset "k8s.io/client-go/kubernetes"
|
|
|
|
"k8s.io/client-go/kubernetes/fake"
|
2017-01-23 18:37:22 +00:00
|
|
|
utiltesting "k8s.io/client-go/util/testing"
|
2016-06-03 14:03:01 +00:00
|
|
|
"k8s.io/kubernetes/pkg/fieldpath"
|
2015-02-20 05:36:23 +00:00
|
|
|
"k8s.io/kubernetes/pkg/volume"
|
2018-09-11 18:30:48 +00:00
|
|
|
"k8s.io/kubernetes/pkg/volume/emptydir"
|
2016-02-29 21:31:42 +00:00
|
|
|
volumetest "k8s.io/kubernetes/pkg/volume/testing"
|
2015-02-20 05:36:23 +00:00
|
|
|
)
|
|
|
|
|
2016-10-18 17:52:37 +00:00
|
|
|
const (
|
|
|
|
downwardAPIDir = "..data"
|
|
|
|
testPodUID = types.UID("test_pod_uid")
|
|
|
|
testNamespace = "test_metadata_namespace"
|
|
|
|
testName = "test_metadata_name"
|
|
|
|
)
|
2016-04-21 21:09:02 +00:00
|
|
|
|
2016-01-15 05:00:58 +00:00
|
|
|
func newTestHost(t *testing.T, clientset clientset.Interface) (string, volume.VolumeHost) {
|
2016-01-25 21:57:42 +00:00
|
|
|
tempDir, err := utiltesting.MkTmpdir("downwardApi_volume_test.")
|
2015-02-20 05:36:23 +00:00
|
|
|
if err != nil {
|
|
|
|
t.Fatalf("can't make a temp rootdir: %v", err)
|
|
|
|
}
|
2018-09-11 18:30:48 +00:00
|
|
|
return tempDir, volumetest.NewFakeVolumeHost(tempDir, clientset, emptydir.ProbeVolumePlugins())
|
2015-02-20 05:36:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func TestCanSupport(t *testing.T) {
|
|
|
|
pluginMgr := volume.VolumePluginMgr{}
|
2016-01-25 21:57:42 +00:00
|
|
|
tmpDir, host := newTestHost(t, nil)
|
|
|
|
defer os.RemoveAll(tmpDir)
|
2017-07-26 00:48:26 +00:00
|
|
|
pluginMgr.InitPlugins(ProbeVolumePlugins(), nil /* prober */, host)
|
2015-02-20 05:36:23 +00:00
|
|
|
|
|
|
|
plugin, err := pluginMgr.FindPluginByName(downwardAPIPluginName)
|
|
|
|
if err != nil {
|
|
|
|
t.Errorf("Can't find the plugin by name")
|
|
|
|
}
|
2016-05-30 02:22:22 +00:00
|
|
|
if plugin.GetPluginName() != downwardAPIPluginName {
|
|
|
|
t.Errorf("Wrong name: %s", plugin.GetPluginName())
|
2015-02-20 05:36:23 +00:00
|
|
|
}
|
2017-10-31 15:20:21 +00:00
|
|
|
if !plugin.CanSupport(&volume.Spec{Volume: &v1.Volume{VolumeSource: v1.VolumeSource{DownwardAPI: &v1.DownwardAPIVolumeSource{}}}}) {
|
|
|
|
t.Errorf("Expected true")
|
|
|
|
}
|
|
|
|
if plugin.CanSupport(&volume.Spec{Volume: &v1.Volume{VolumeSource: v1.VolumeSource{}}}) {
|
|
|
|
t.Errorf("Expected false")
|
|
|
|
}
|
2015-02-20 05:36:23 +00:00
|
|
|
}
|
|
|
|
|
2016-10-18 17:52:37 +00:00
|
|
|
func TestDownwardAPI(t *testing.T) {
|
|
|
|
labels1 := map[string]string{
|
2015-02-20 05:36:23 +00:00
|
|
|
"key1": "value1",
|
2016-10-18 17:52:37 +00:00
|
|
|
"key2": "value2",
|
2015-02-20 05:36:23 +00:00
|
|
|
}
|
2016-10-18 17:52:37 +00:00
|
|
|
labels2 := map[string]string{
|
|
|
|
"key1": "value1",
|
|
|
|
"key2": "value2",
|
|
|
|
"key3": "value3",
|
2015-02-20 05:36:23 +00:00
|
|
|
}
|
|
|
|
annotations := map[string]string{
|
2018-07-09 19:44:03 +00:00
|
|
|
"a1": "value1",
|
|
|
|
"a2": "value2",
|
|
|
|
"multiline": "c\nb\na",
|
2016-10-18 17:52:37 +00:00
|
|
|
}
|
|
|
|
testCases := []struct {
|
|
|
|
name string
|
|
|
|
files map[string]string
|
|
|
|
modes map[string]int32
|
|
|
|
podLabels map[string]string
|
|
|
|
podAnnotations map[string]string
|
|
|
|
steps []testStep
|
|
|
|
}{
|
|
|
|
{
|
|
|
|
name: "test_labels",
|
|
|
|
files: map[string]string{"labels": "metadata.labels"},
|
|
|
|
podLabels: labels1,
|
|
|
|
steps: []testStep{
|
|
|
|
// for steps that involve files, stepName is also
|
|
|
|
// used as the name of the file to verify
|
|
|
|
verifyMapInFile{stepName{"labels"}, labels1},
|
|
|
|
},
|
2015-02-20 05:36:23 +00:00
|
|
|
},
|
2016-10-18 17:52:37 +00:00
|
|
|
{
|
|
|
|
name: "test_annotations",
|
|
|
|
files: map[string]string{"annotations": "metadata.annotations"},
|
|
|
|
podAnnotations: annotations,
|
|
|
|
steps: []testStep{
|
|
|
|
verifyMapInFile{stepName{"annotations"}, annotations},
|
|
|
|
},
|
2015-02-20 05:36:23 +00:00
|
|
|
},
|
2016-10-18 17:52:37 +00:00
|
|
|
{
|
|
|
|
name: "test_name",
|
|
|
|
files: map[string]string{"name_file_name": "metadata.name"},
|
|
|
|
steps: []testStep{
|
|
|
|
verifyLinesInFile{stepName{"name_file_name"}, testName},
|
|
|
|
},
|
2015-02-20 05:36:23 +00:00
|
|
|
},
|
2016-10-18 17:52:37 +00:00
|
|
|
{
|
|
|
|
name: "test_namespace",
|
|
|
|
files: map[string]string{"namespace_file_name": "metadata.namespace"},
|
|
|
|
steps: []testStep{
|
|
|
|
verifyLinesInFile{stepName{"namespace_file_name"}, testNamespace},
|
|
|
|
},
|
2015-02-20 05:36:23 +00:00
|
|
|
},
|
2016-10-18 17:52:37 +00:00
|
|
|
{
|
|
|
|
name: "test_write_twice_no_update",
|
|
|
|
files: map[string]string{"labels": "metadata.labels"},
|
|
|
|
podLabels: labels1,
|
|
|
|
steps: []testStep{
|
|
|
|
reSetUp{stepName{"resetup"}, false, nil},
|
|
|
|
verifyMapInFile{stepName{"labels"}, labels1},
|
|
|
|
},
|
2015-02-20 05:36:23 +00:00
|
|
|
},
|
2016-10-18 17:52:37 +00:00
|
|
|
{
|
|
|
|
name: "test_write_twice_with_update",
|
|
|
|
files: map[string]string{"labels": "metadata.labels"},
|
|
|
|
podLabels: labels1,
|
|
|
|
steps: []testStep{
|
|
|
|
reSetUp{stepName{"resetup"}, true, labels2},
|
|
|
|
verifyMapInFile{stepName{"labels"}, labels2},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "test_write_with_unix_path",
|
|
|
|
files: map[string]string{
|
|
|
|
"these/are/my/labels": "metadata.labels",
|
|
|
|
"these/are/your/annotations": "metadata.annotations",
|
|
|
|
},
|
|
|
|
podLabels: labels1,
|
|
|
|
podAnnotations: annotations,
|
|
|
|
steps: []testStep{
|
|
|
|
verifyMapInFile{stepName{"these/are/my/labels"}, labels1},
|
|
|
|
verifyMapInFile{stepName{"these/are/your/annotations"}, annotations},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "test_write_with_two_consecutive_slashes_in_the_path",
|
|
|
|
files: map[string]string{"this//labels": "metadata.labels"},
|
|
|
|
podLabels: labels1,
|
|
|
|
steps: []testStep{
|
|
|
|
verifyMapInFile{stepName{"this/labels"}, labels1},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "test_default_mode",
|
|
|
|
files: map[string]string{"name_file_name": "metadata.name"},
|
|
|
|
steps: []testStep{
|
|
|
|
verifyMode{stepName{"name_file_name"}, 0644},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "test_item_mode",
|
|
|
|
files: map[string]string{"name_file_name": "metadata.name"},
|
|
|
|
modes: map[string]int32{"name_file_name": 0400},
|
|
|
|
steps: []testStep{
|
|
|
|
verifyMode{stepName{"name_file_name"}, 0400},
|
|
|
|
},
|
2015-02-20 05:36:23 +00:00
|
|
|
},
|
|
|
|
}
|
2016-10-18 17:52:37 +00:00
|
|
|
for _, testCase := range testCases {
|
|
|
|
test := newDownwardAPITest(t, testCase.name, testCase.files, testCase.podLabels, testCase.podAnnotations, testCase.modes)
|
|
|
|
for _, step := range testCase.steps {
|
|
|
|
test.t.Logf("Test case: %q Step: %q", testCase.name, step.getName())
|
|
|
|
step.run(test)
|
|
|
|
}
|
|
|
|
test.tearDown()
|
2015-02-20 05:36:23 +00:00
|
|
|
}
|
2016-10-18 17:52:37 +00:00
|
|
|
}
|
2015-02-20 05:36:23 +00:00
|
|
|
|
2016-10-18 17:52:37 +00:00
|
|
|
type downwardAPITest struct {
|
|
|
|
t *testing.T
|
|
|
|
name string
|
|
|
|
plugin volume.VolumePlugin
|
|
|
|
pod *v1.Pod
|
|
|
|
mounter volume.Mounter
|
|
|
|
volumePath string
|
|
|
|
rootDir string
|
|
|
|
}
|
2015-02-20 05:36:23 +00:00
|
|
|
|
2016-10-18 17:52:37 +00:00
|
|
|
func newDownwardAPITest(t *testing.T, name string, volumeFiles, podLabels, podAnnotations map[string]string, modes map[string]int32) *downwardAPITest {
|
|
|
|
defaultMode := int32(0644)
|
|
|
|
var files []v1.DownwardAPIVolumeFile
|
|
|
|
for path, fieldPath := range volumeFiles {
|
|
|
|
file := v1.DownwardAPIVolumeFile{
|
|
|
|
Path: path,
|
|
|
|
FieldRef: &v1.ObjectFieldSelector{
|
|
|
|
FieldPath: fieldPath,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
if mode, found := modes[path]; found {
|
|
|
|
file.Mode = &mode
|
|
|
|
}
|
|
|
|
files = append(files, file)
|
2015-02-20 05:36:23 +00:00
|
|
|
}
|
2016-10-18 17:52:37 +00:00
|
|
|
podMeta := metav1.ObjectMeta{
|
|
|
|
Name: testName,
|
|
|
|
Namespace: testNamespace,
|
|
|
|
Labels: podLabels,
|
|
|
|
Annotations: podAnnotations,
|
2015-02-20 05:36:23 +00:00
|
|
|
}
|
2016-10-18 17:52:37 +00:00
|
|
|
clientset := fake.NewSimpleClientset(&v1.Pod{ObjectMeta: podMeta})
|
2015-02-20 05:36:23 +00:00
|
|
|
|
|
|
|
pluginMgr := volume.VolumePluginMgr{}
|
2016-10-18 17:52:37 +00:00
|
|
|
rootDir, host := newTestHost(t, clientset)
|
2017-07-26 00:48:26 +00:00
|
|
|
pluginMgr.InitPlugins(ProbeVolumePlugins(), nil /* prober */, host)
|
2015-02-20 05:36:23 +00:00
|
|
|
plugin, err := pluginMgr.FindPluginByName(downwardAPIPluginName)
|
|
|
|
if err != nil {
|
|
|
|
t.Errorf("Can't find the plugin by name")
|
|
|
|
}
|
|
|
|
|
2016-11-18 20:58:56 +00:00
|
|
|
volumeSpec := &v1.Volume{
|
2016-10-18 17:52:37 +00:00
|
|
|
Name: name,
|
2016-11-18 20:58:56 +00:00
|
|
|
VolumeSource: v1.VolumeSource{
|
|
|
|
DownwardAPI: &v1.DownwardAPIVolumeSource{
|
2016-07-11 00:48:28 +00:00
|
|
|
DefaultMode: &defaultMode,
|
2016-10-18 17:52:37 +00:00
|
|
|
Items: files,
|
|
|
|
},
|
2015-02-20 05:36:23 +00:00
|
|
|
},
|
|
|
|
}
|
2016-10-18 17:52:37 +00:00
|
|
|
podMeta.UID = testPodUID
|
|
|
|
pod := &v1.Pod{ObjectMeta: podMeta}
|
2016-03-23 05:12:21 +00:00
|
|
|
mounter, err := plugin.NewMounter(volume.NewSpecFromVolume(volumeSpec), pod, volume.VolumeOptions{})
|
2015-02-20 05:36:23 +00:00
|
|
|
if err != nil {
|
2016-03-23 05:12:21 +00:00
|
|
|
t.Errorf("Failed to make a new Mounter: %v", err)
|
2015-02-20 05:36:23 +00:00
|
|
|
}
|
2016-03-23 05:12:21 +00:00
|
|
|
if mounter == nil {
|
2016-12-19 07:42:14 +00:00
|
|
|
t.Fatalf("Got a nil Mounter")
|
2015-02-20 05:36:23 +00:00
|
|
|
}
|
|
|
|
|
2016-03-23 05:12:21 +00:00
|
|
|
volumePath := mounter.GetPath()
|
2016-10-18 17:52:37 +00:00
|
|
|
|
2016-03-23 05:12:21 +00:00
|
|
|
err = mounter.SetUp(nil)
|
2015-02-20 05:36:23 +00:00
|
|
|
if err != nil {
|
|
|
|
t.Errorf("Failed to setup volume: %v", err)
|
|
|
|
}
|
|
|
|
|
2016-10-18 17:52:37 +00:00
|
|
|
// downwardAPI volume should create its own empty wrapper path
|
|
|
|
podWrapperMetadataDir := fmt.Sprintf("%v/pods/%v/plugins/kubernetes.io~empty-dir/wrapped_%v", rootDir, testPodUID, name)
|
2015-02-20 05:36:23 +00:00
|
|
|
|
2016-10-18 17:52:37 +00:00
|
|
|
if _, err := os.Stat(podWrapperMetadataDir); err != nil {
|
|
|
|
if os.IsNotExist(err) {
|
|
|
|
t.Errorf("SetUp() failed, empty-dir wrapper path was not created: %s", podWrapperMetadataDir)
|
|
|
|
} else {
|
|
|
|
t.Errorf("SetUp() failed: %v", err)
|
|
|
|
}
|
2015-02-20 05:36:23 +00:00
|
|
|
}
|
|
|
|
|
2016-10-18 17:52:37 +00:00
|
|
|
return &downwardAPITest{
|
|
|
|
t: t,
|
|
|
|
plugin: plugin,
|
|
|
|
pod: pod,
|
|
|
|
mounter: mounter,
|
|
|
|
volumePath: volumePath,
|
|
|
|
rootDir: rootDir,
|
2015-02-20 05:36:23 +00:00
|
|
|
}
|
2016-10-18 17:52:37 +00:00
|
|
|
}
|
2015-02-20 05:36:23 +00:00
|
|
|
|
2016-10-18 17:52:37 +00:00
|
|
|
func (test *downwardAPITest) tearDown() {
|
|
|
|
unmounter, err := test.plugin.NewUnmounter(test.name, testPodUID)
|
2015-02-20 05:36:23 +00:00
|
|
|
if err != nil {
|
2016-10-18 17:52:37 +00:00
|
|
|
test.t.Errorf("Failed to make a new Unmounter: %v", err)
|
2015-02-20 05:36:23 +00:00
|
|
|
}
|
2016-10-18 17:52:37 +00:00
|
|
|
if unmounter == nil {
|
2016-12-19 07:42:14 +00:00
|
|
|
test.t.Fatalf("Got a nil Unmounter")
|
2015-02-20 05:36:23 +00:00
|
|
|
}
|
|
|
|
|
2016-10-18 17:52:37 +00:00
|
|
|
if err := unmounter.TearDown(); err != nil {
|
|
|
|
test.t.Errorf("Expected success, got: %v", err)
|
2015-02-20 05:36:23 +00:00
|
|
|
}
|
2016-10-18 17:52:37 +00:00
|
|
|
if _, err := os.Stat(test.volumePath); err == nil {
|
|
|
|
test.t.Errorf("TearDown() failed, volume path still exists: %s", test.volumePath)
|
|
|
|
} else if !os.IsNotExist(err) {
|
2017-10-25 17:30:33 +00:00
|
|
|
test.t.Errorf("TearDown() failed: %v", err)
|
2015-02-20 05:36:23 +00:00
|
|
|
}
|
2016-10-18 17:52:37 +00:00
|
|
|
os.RemoveAll(test.rootDir)
|
2015-02-20 05:36:23 +00:00
|
|
|
}
|
|
|
|
|
2016-10-18 17:52:37 +00:00
|
|
|
// testStep represents a named step of downwardAPITest.
|
|
|
|
// For steps that deal with files, step name also serves
|
|
|
|
// as the name of the file that's used by the step.
|
|
|
|
type testStep interface {
|
|
|
|
getName() string
|
|
|
|
run(*downwardAPITest)
|
|
|
|
}
|
2015-02-20 05:36:23 +00:00
|
|
|
|
2016-10-18 17:52:37 +00:00
|
|
|
type stepName struct {
|
|
|
|
name string
|
|
|
|
}
|
2015-02-20 05:36:23 +00:00
|
|
|
|
2016-10-18 17:52:37 +00:00
|
|
|
func (step stepName) getName() string { return step.name }
|
2015-02-20 05:36:23 +00:00
|
|
|
|
2016-10-18 17:52:37 +00:00
|
|
|
func doVerifyLinesInFile(t *testing.T, volumePath, filename string, expected string) {
|
|
|
|
data, err := ioutil.ReadFile(path.Join(volumePath, filename))
|
2015-02-20 05:36:23 +00:00
|
|
|
if err != nil {
|
|
|
|
t.Errorf(err.Error())
|
2016-10-18 17:52:37 +00:00
|
|
|
return
|
2015-02-20 05:36:23 +00:00
|
|
|
}
|
2018-07-09 19:44:03 +00:00
|
|
|
actualStr := string(data)
|
|
|
|
expectedStr := expected
|
2016-10-18 17:52:37 +00:00
|
|
|
if actualStr != expectedStr {
|
|
|
|
t.Errorf("Found `%s`, expected `%s`", actualStr, expectedStr)
|
2015-02-20 05:36:23 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-10-18 17:52:37 +00:00
|
|
|
type verifyLinesInFile struct {
|
|
|
|
stepName
|
|
|
|
expected string
|
2015-02-20 05:36:23 +00:00
|
|
|
}
|
2016-07-11 00:48:28 +00:00
|
|
|
|
2016-10-18 17:52:37 +00:00
|
|
|
func (step verifyLinesInFile) run(test *downwardAPITest) {
|
|
|
|
doVerifyLinesInFile(test.t, test.volumePath, step.name, step.expected)
|
|
|
|
}
|
2016-07-11 00:48:28 +00:00
|
|
|
|
2016-10-18 17:52:37 +00:00
|
|
|
type verifyMapInFile struct {
|
|
|
|
stepName
|
|
|
|
expected map[string]string
|
|
|
|
}
|
2016-07-11 00:48:28 +00:00
|
|
|
|
2016-10-18 17:52:37 +00:00
|
|
|
func (step verifyMapInFile) run(test *downwardAPITest) {
|
|
|
|
doVerifyLinesInFile(test.t, test.volumePath, step.name, fieldpath.FormatMap(step.expected))
|
|
|
|
}
|
2016-07-11 00:48:28 +00:00
|
|
|
|
2016-10-18 17:52:37 +00:00
|
|
|
type verifyMode struct {
|
|
|
|
stepName
|
|
|
|
expectedMode int32
|
|
|
|
}
|
2016-07-11 00:48:28 +00:00
|
|
|
|
2016-10-18 17:52:37 +00:00
|
|
|
func (step verifyMode) run(test *downwardAPITest) {
|
|
|
|
fileInfo, err := os.Stat(path.Join(test.volumePath, step.name))
|
2016-07-11 00:48:28 +00:00
|
|
|
if err != nil {
|
2016-10-18 17:52:37 +00:00
|
|
|
test.t.Errorf(err.Error())
|
|
|
|
return
|
2016-07-11 00:48:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
actualMode := fileInfo.Mode()
|
2016-10-18 17:52:37 +00:00
|
|
|
expectedMode := os.FileMode(step.expectedMode)
|
2016-07-11 00:48:28 +00:00
|
|
|
if actualMode != expectedMode {
|
2016-10-18 17:52:37 +00:00
|
|
|
test.t.Errorf("Found mode `%v` expected %v", actualMode, expectedMode)
|
2016-07-11 00:48:28 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-10-18 17:52:37 +00:00
|
|
|
type reSetUp struct {
|
|
|
|
stepName
|
|
|
|
linkShouldChange bool
|
|
|
|
newLabels map[string]string
|
|
|
|
}
|
2016-07-11 00:48:28 +00:00
|
|
|
|
2016-10-18 17:52:37 +00:00
|
|
|
func (step reSetUp) run(test *downwardAPITest) {
|
|
|
|
if step.newLabels != nil {
|
|
|
|
test.pod.ObjectMeta.Labels = step.newLabels
|
2016-07-11 00:48:28 +00:00
|
|
|
}
|
|
|
|
|
2016-10-18 17:52:37 +00:00
|
|
|
currentTarget, err := os.Readlink(path.Join(test.volumePath, downwardAPIDir))
|
2016-07-11 00:48:28 +00:00
|
|
|
if err != nil {
|
2016-10-18 17:52:37 +00:00
|
|
|
test.t.Errorf("labels file should be a link... %s\n", err.Error())
|
2016-07-11 00:48:28 +00:00
|
|
|
}
|
|
|
|
|
2016-10-18 17:52:37 +00:00
|
|
|
// now re-run Setup
|
|
|
|
if err = test.mounter.SetUp(nil); err != nil {
|
|
|
|
test.t.Errorf("Failed to re-setup volume: %v", err)
|
2016-07-11 00:48:28 +00:00
|
|
|
}
|
|
|
|
|
2016-10-18 17:52:37 +00:00
|
|
|
// get the link of the link
|
|
|
|
currentTarget2, err := os.Readlink(path.Join(test.volumePath, downwardAPIDir))
|
2016-07-11 00:48:28 +00:00
|
|
|
if err != nil {
|
2016-10-18 17:52:37 +00:00
|
|
|
test.t.Errorf(".current should be a link... %s\n", err.Error())
|
2016-07-11 00:48:28 +00:00
|
|
|
}
|
|
|
|
|
2016-10-18 17:52:37 +00:00
|
|
|
switch {
|
|
|
|
case step.linkShouldChange && currentTarget2 == currentTarget:
|
|
|
|
test.t.Errorf("Got and update between the two Setup... Target link should NOT be the same\n")
|
|
|
|
case !step.linkShouldChange && currentTarget2 != currentTarget:
|
|
|
|
test.t.Errorf("No update between the two Setup... Target link should be the same %s %s\n",
|
|
|
|
currentTarget, currentTarget2)
|
2016-07-11 00:48:28 +00:00
|
|
|
}
|
|
|
|
}
|