mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 11:50:44 +00:00
code cleanup for pkg volume csi
This commit is contained in:
parent
a55bd63172
commit
b3fea118dc
@ -35,9 +35,7 @@ import (
|
|||||||
authenticationv1 "k8s.io/api/authentication/v1"
|
authenticationv1 "k8s.io/api/authentication/v1"
|
||||||
api "k8s.io/api/core/v1"
|
api "k8s.io/api/core/v1"
|
||||||
storage "k8s.io/api/storage/v1"
|
storage "k8s.io/api/storage/v1"
|
||||||
storagev1 "k8s.io/api/storage/v1"
|
|
||||||
meta "k8s.io/apimachinery/pkg/apis/meta/v1"
|
meta "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
|
||||||
"k8s.io/apimachinery/pkg/runtime"
|
"k8s.io/apimachinery/pkg/runtime"
|
||||||
"k8s.io/apimachinery/pkg/types"
|
"k8s.io/apimachinery/pkg/types"
|
||||||
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
|
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
|
||||||
@ -225,7 +223,7 @@ func TestMounterSetUp(t *testing.T) {
|
|||||||
DetachError: nil,
|
DetachError: nil,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
_, err = csiMounter.k8s.StorageV1().VolumeAttachments().Create(context.TODO(), attachment, metav1.CreateOptions{})
|
_, err = csiMounter.k8s.StorageV1().VolumeAttachments().Create(context.TODO(), attachment, meta.CreateOptions{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("failed to setup VolumeAttachment: %v", err)
|
t.Fatalf("failed to setup VolumeAttachment: %v", err)
|
||||||
}
|
}
|
||||||
@ -352,7 +350,7 @@ func TestMounterSetUpSimple(t *testing.T) {
|
|||||||
|
|
||||||
attachID := getAttachmentName(csiMounter.volumeID, string(csiMounter.driverName), string(plug.host.GetNodeName()))
|
attachID := getAttachmentName(csiMounter.volumeID, string(csiMounter.driverName), string(plug.host.GetNodeName()))
|
||||||
attachment := makeTestAttachment(attachID, "test-node", csiMounter.spec.Name())
|
attachment := makeTestAttachment(attachID, "test-node", csiMounter.spec.Name())
|
||||||
_, err = csiMounter.k8s.StorageV1().VolumeAttachments().Create(context.TODO(), attachment, metav1.CreateOptions{})
|
_, err = csiMounter.k8s.StorageV1().VolumeAttachments().Create(context.TODO(), attachment, meta.CreateOptions{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("failed to setup VolumeAttachment: %v", err)
|
t.Fatalf("failed to setup VolumeAttachment: %v", err)
|
||||||
}
|
}
|
||||||
@ -480,7 +478,7 @@ func TestMounterSetupWithStatusTracking(t *testing.T) {
|
|||||||
if tc.createAttachment {
|
if tc.createAttachment {
|
||||||
attachID := getAttachmentName(csiMounter.volumeID, string(csiMounter.driverName), string(plug.host.GetNodeName()))
|
attachID := getAttachmentName(csiMounter.volumeID, string(csiMounter.driverName), string(plug.host.GetNodeName()))
|
||||||
attachment := makeTestAttachment(attachID, "test-node", csiMounter.spec.Name())
|
attachment := makeTestAttachment(attachID, "test-node", csiMounter.spec.Name())
|
||||||
_, err = csiMounter.k8s.StorageV1().VolumeAttachments().Create(context.TODO(), attachment, metav1.CreateOptions{})
|
_, err = csiMounter.k8s.StorageV1().VolumeAttachments().Create(context.TODO(), attachment, meta.CreateOptions{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("failed to setup VolumeAttachment: %v", err)
|
t.Fatalf("failed to setup VolumeAttachment: %v", err)
|
||||||
}
|
}
|
||||||
@ -594,7 +592,7 @@ func TestMounterSetUpWithInline(t *testing.T) {
|
|||||||
if csiMounter.volumeLifecycleMode == storage.VolumeLifecyclePersistent {
|
if csiMounter.volumeLifecycleMode == storage.VolumeLifecyclePersistent {
|
||||||
attachID := getAttachmentName(csiMounter.volumeID, string(csiMounter.driverName), string(plug.host.GetNodeName()))
|
attachID := getAttachmentName(csiMounter.volumeID, string(csiMounter.driverName), string(plug.host.GetNodeName()))
|
||||||
attachment := makeTestAttachment(attachID, "test-node", csiMounter.spec.Name())
|
attachment := makeTestAttachment(attachID, "test-node", csiMounter.spec.Name())
|
||||||
_, err = csiMounter.k8s.StorageV1().VolumeAttachments().Create(context.TODO(), attachment, metav1.CreateOptions{})
|
_, err = csiMounter.k8s.StorageV1().VolumeAttachments().Create(context.TODO(), attachment, meta.CreateOptions{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("failed to setup VolumeAttachment: %v", err)
|
t.Fatalf("failed to setup VolumeAttachment: %v", err)
|
||||||
}
|
}
|
||||||
@ -827,7 +825,7 @@ func TestMounterSetUpWithFSGroup(t *testing.T) {
|
|||||||
attachID := getAttachmentName(csiMounter.volumeID, string(csiMounter.driverName), string(plug.host.GetNodeName()))
|
attachID := getAttachmentName(csiMounter.volumeID, string(csiMounter.driverName), string(plug.host.GetNodeName()))
|
||||||
attachment := makeTestAttachment(attachID, "test-node", pvName)
|
attachment := makeTestAttachment(attachID, "test-node", pvName)
|
||||||
|
|
||||||
_, err = csiMounter.k8s.StorageV1().VolumeAttachments().Create(context.TODO(), attachment, metav1.CreateOptions{})
|
_, err = csiMounter.k8s.StorageV1().VolumeAttachments().Create(context.TODO(), attachment, meta.CreateOptions{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("failed to setup VolumeAttachment: %v", err)
|
t.Errorf("failed to setup VolumeAttachment: %v", err)
|
||||||
continue
|
continue
|
||||||
@ -950,28 +948,28 @@ func TestPodServiceAccountTokenAttrs(t *testing.T) {
|
|||||||
|
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
desc string
|
desc string
|
||||||
driver *storagev1.CSIDriver
|
driver *storage.CSIDriver
|
||||||
volumeContext map[string]string
|
volumeContext map[string]string
|
||||||
wantVolumeContext map[string]string
|
wantVolumeContext map[string]string
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
desc: "csi driver has no ServiceAccountToken",
|
desc: "csi driver has no ServiceAccountToken",
|
||||||
driver: &storagev1.CSIDriver{
|
driver: &storage.CSIDriver{
|
||||||
ObjectMeta: meta.ObjectMeta{
|
ObjectMeta: meta.ObjectMeta{
|
||||||
Name: testDriver,
|
Name: testDriver,
|
||||||
},
|
},
|
||||||
Spec: storagev1.CSIDriverSpec{},
|
Spec: storage.CSIDriverSpec{},
|
||||||
},
|
},
|
||||||
wantVolumeContext: nil,
|
wantVolumeContext: nil,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
desc: "one token with empty string as audience",
|
desc: "one token with empty string as audience",
|
||||||
driver: &storagev1.CSIDriver{
|
driver: &storage.CSIDriver{
|
||||||
ObjectMeta: meta.ObjectMeta{
|
ObjectMeta: meta.ObjectMeta{
|
||||||
Name: testDriver,
|
Name: testDriver,
|
||||||
},
|
},
|
||||||
Spec: storagev1.CSIDriverSpec{
|
Spec: storage.CSIDriverSpec{
|
||||||
TokenRequests: []storagev1.TokenRequest{
|
TokenRequests: []storage.TokenRequest{
|
||||||
{
|
{
|
||||||
Audience: "",
|
Audience: "",
|
||||||
},
|
},
|
||||||
@ -982,12 +980,12 @@ func TestPodServiceAccountTokenAttrs(t *testing.T) {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
desc: "one token with non-empty string as audience",
|
desc: "one token with non-empty string as audience",
|
||||||
driver: &storagev1.CSIDriver{
|
driver: &storage.CSIDriver{
|
||||||
ObjectMeta: meta.ObjectMeta{
|
ObjectMeta: meta.ObjectMeta{
|
||||||
Name: testDriver,
|
Name: testDriver,
|
||||||
},
|
},
|
||||||
Spec: storagev1.CSIDriverSpec{
|
Spec: storage.CSIDriverSpec{
|
||||||
TokenRequests: []storagev1.TokenRequest{
|
TokenRequests: []storage.TokenRequest{
|
||||||
{
|
{
|
||||||
Audience: gcp,
|
Audience: gcp,
|
||||||
},
|
},
|
||||||
@ -1017,7 +1015,7 @@ func TestPodServiceAccountTokenAttrs(t *testing.T) {
|
|||||||
tr.Spec.Audiences = []string{"api"}
|
tr.Spec.Audiences = []string{"api"}
|
||||||
}
|
}
|
||||||
tr.Status.Token = fmt.Sprintf("%v:%v:%d:%v", action.GetNamespace(), testAccount, *tr.Spec.ExpirationSeconds, tr.Spec.Audiences)
|
tr.Status.Token = fmt.Sprintf("%v:%v:%d:%v", action.GetNamespace(), testAccount, *tr.Spec.ExpirationSeconds, tr.Spec.Audiences)
|
||||||
tr.Status.ExpirationTimestamp = metav1.NewTime(time.Unix(1, 1))
|
tr.Status.ExpirationTimestamp = meta.NewTime(time.Unix(1, 1))
|
||||||
return true, tr, nil
|
return true, tr, nil
|
||||||
}))
|
}))
|
||||||
plug, tmpDir := newTestPlugin(t, client)
|
plug, tmpDir := newTestPlugin(t, client)
|
||||||
|
@ -27,9 +27,7 @@ import (
|
|||||||
api "k8s.io/api/core/v1"
|
api "k8s.io/api/core/v1"
|
||||||
v1 "k8s.io/api/core/v1"
|
v1 "k8s.io/api/core/v1"
|
||||||
storage "k8s.io/api/storage/v1"
|
storage "k8s.io/api/storage/v1"
|
||||||
storagev1 "k8s.io/api/storage/v1"
|
|
||||||
meta "k8s.io/apimachinery/pkg/apis/meta/v1"
|
meta "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
|
||||||
"k8s.io/apimachinery/pkg/types"
|
"k8s.io/apimachinery/pkg/types"
|
||||||
"k8s.io/apimachinery/pkg/util/wait"
|
"k8s.io/apimachinery/pkg/util/wait"
|
||||||
utilfeature "k8s.io/apiserver/pkg/util/feature"
|
utilfeature "k8s.io/apiserver/pkg/util/feature"
|
||||||
@ -68,7 +66,7 @@ func newTestPluginWithVolumeHost(t *testing.T, client *fakeclient.Clientset, hos
|
|||||||
}
|
}
|
||||||
|
|
||||||
client.Tracker().Add(&v1.Node{
|
client.Tracker().Add(&v1.Node{
|
||||||
ObjectMeta: metav1.ObjectMeta{
|
ObjectMeta: meta.ObjectMeta{
|
||||||
Name: "fakeNode",
|
Name: "fakeNode",
|
||||||
},
|
},
|
||||||
Spec: v1.NodeSpec{},
|
Spec: v1.NodeSpec{},
|
||||||
@ -284,8 +282,8 @@ func TestPluginGetVolumeName(t *testing.T) {
|
|||||||
func TestPluginGetVolumeNameWithInline(t *testing.T) {
|
func TestPluginGetVolumeNameWithInline(t *testing.T) {
|
||||||
defer featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, features.CSIInlineVolume, true)()
|
defer featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, features.CSIInlineVolume, true)()
|
||||||
|
|
||||||
modes := []storagev1.VolumeLifecycleMode{
|
modes := []storage.VolumeLifecycleMode{
|
||||||
storagev1.VolumeLifecyclePersistent,
|
storage.VolumeLifecyclePersistent,
|
||||||
}
|
}
|
||||||
driver := getTestCSIDriver(testDriver, nil, nil, modes)
|
driver := getTestCSIDriver(testDriver, nil, nil, modes)
|
||||||
client := fakeclient.NewSimpleClientset(driver)
|
client := fakeclient.NewSimpleClientset(driver)
|
||||||
@ -517,7 +515,7 @@ func TestPluginConstructVolumeSpecWithInline(t *testing.T) {
|
|||||||
volHandle string
|
volHandle string
|
||||||
podUID types.UID
|
podUID types.UID
|
||||||
shouldFail bool
|
shouldFail bool
|
||||||
modes []storagev1.VolumeLifecycleMode
|
modes []storage.VolumeLifecycleMode
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
name: "construct spec1 from persistent spec",
|
name: "construct spec1 from persistent spec",
|
||||||
@ -525,7 +523,7 @@ func TestPluginConstructVolumeSpecWithInline(t *testing.T) {
|
|||||||
volHandle: "testvol-handle1",
|
volHandle: "testvol-handle1",
|
||||||
originSpec: volume.NewSpecFromPersistentVolume(makeTestPV("test.vol.id", 20, testDriver, "testvol-handle1"), true),
|
originSpec: volume.NewSpecFromPersistentVolume(makeTestPV("test.vol.id", 20, testDriver, "testvol-handle1"), true),
|
||||||
podUID: types.UID(fmt.Sprintf("%08X", rand.Uint64())),
|
podUID: types.UID(fmt.Sprintf("%08X", rand.Uint64())),
|
||||||
modes: []storagev1.VolumeLifecycleMode{storagev1.VolumeLifecyclePersistent},
|
modes: []storage.VolumeLifecycleMode{storage.VolumeLifecyclePersistent},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "construct spec2 from persistent spec",
|
name: "construct spec2 from persistent spec",
|
||||||
@ -533,7 +531,7 @@ func TestPluginConstructVolumeSpecWithInline(t *testing.T) {
|
|||||||
volHandle: "handle2",
|
volHandle: "handle2",
|
||||||
originSpec: volume.NewSpecFromPersistentVolume(makeTestPV("spec2", 20, testDriver, "handle2"), true),
|
originSpec: volume.NewSpecFromPersistentVolume(makeTestPV("spec2", 20, testDriver, "handle2"), true),
|
||||||
podUID: types.UID(fmt.Sprintf("%08X", rand.Uint64())),
|
podUID: types.UID(fmt.Sprintf("%08X", rand.Uint64())),
|
||||||
modes: []storagev1.VolumeLifecycleMode{storagev1.VolumeLifecyclePersistent},
|
modes: []storage.VolumeLifecycleMode{storage.VolumeLifecyclePersistent},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "construct spec2 from persistent spec, missing mode",
|
name: "construct spec2 from persistent spec, missing mode",
|
||||||
@ -541,7 +539,7 @@ func TestPluginConstructVolumeSpecWithInline(t *testing.T) {
|
|||||||
volHandle: "handle2",
|
volHandle: "handle2",
|
||||||
originSpec: volume.NewSpecFromPersistentVolume(makeTestPV("spec2", 20, testDriver, "handle2"), true),
|
originSpec: volume.NewSpecFromPersistentVolume(makeTestPV("spec2", 20, testDriver, "handle2"), true),
|
||||||
podUID: types.UID(fmt.Sprintf("%08X", rand.Uint64())),
|
podUID: types.UID(fmt.Sprintf("%08X", rand.Uint64())),
|
||||||
modes: []storagev1.VolumeLifecycleMode{},
|
modes: []storage.VolumeLifecycleMode{},
|
||||||
shouldFail: true,
|
shouldFail: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -549,21 +547,21 @@ func TestPluginConstructVolumeSpecWithInline(t *testing.T) {
|
|||||||
specVolID: "volspec",
|
specVolID: "volspec",
|
||||||
originSpec: volume.NewSpecFromVolume(makeTestVol("volspec", testDriver)),
|
originSpec: volume.NewSpecFromVolume(makeTestVol("volspec", testDriver)),
|
||||||
podUID: types.UID(fmt.Sprintf("%08X", rand.Uint64())),
|
podUID: types.UID(fmt.Sprintf("%08X", rand.Uint64())),
|
||||||
modes: []storagev1.VolumeLifecycleMode{storagev1.VolumeLifecycleEphemeral},
|
modes: []storage.VolumeLifecycleMode{storage.VolumeLifecycleEphemeral},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "construct spec from volume spec2",
|
name: "construct spec from volume spec2",
|
||||||
specVolID: "volspec2",
|
specVolID: "volspec2",
|
||||||
originSpec: volume.NewSpecFromVolume(makeTestVol("volspec2", testDriver)),
|
originSpec: volume.NewSpecFromVolume(makeTestVol("volspec2", testDriver)),
|
||||||
podUID: types.UID(fmt.Sprintf("%08X", rand.Uint64())),
|
podUID: types.UID(fmt.Sprintf("%08X", rand.Uint64())),
|
||||||
modes: []storagev1.VolumeLifecycleMode{storagev1.VolumeLifecycleEphemeral},
|
modes: []storage.VolumeLifecycleMode{storage.VolumeLifecycleEphemeral},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "construct spec from volume spec2, missing mode",
|
name: "construct spec from volume spec2, missing mode",
|
||||||
specVolID: "volspec2",
|
specVolID: "volspec2",
|
||||||
originSpec: volume.NewSpecFromVolume(makeTestVol("volspec2", testDriver)),
|
originSpec: volume.NewSpecFromVolume(makeTestVol("volspec2", testDriver)),
|
||||||
podUID: types.UID(fmt.Sprintf("%08X", rand.Uint64())),
|
podUID: types.UID(fmt.Sprintf("%08X", rand.Uint64())),
|
||||||
modes: []storagev1.VolumeLifecycleMode{},
|
modes: []storage.VolumeLifecycleMode{},
|
||||||
shouldFail: true,
|
shouldFail: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -653,7 +651,7 @@ func TestPluginNewMounter(t *testing.T) {
|
|||||||
spec *volume.Spec
|
spec *volume.Spec
|
||||||
podUID types.UID
|
podUID types.UID
|
||||||
namespace string
|
namespace string
|
||||||
volumeLifecycleMode storagev1.VolumeLifecycleMode
|
volumeLifecycleMode storage.VolumeLifecycleMode
|
||||||
shouldFail bool
|
shouldFail bool
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
@ -661,14 +659,14 @@ func TestPluginNewMounter(t *testing.T) {
|
|||||||
spec: volume.NewSpecFromPersistentVolume(makeTestPV("test-pv1", 20, testDriver, testVol), true),
|
spec: volume.NewSpecFromPersistentVolume(makeTestPV("test-pv1", 20, testDriver, testVol), true),
|
||||||
podUID: types.UID(fmt.Sprintf("%08X", rand.Uint64())),
|
podUID: types.UID(fmt.Sprintf("%08X", rand.Uint64())),
|
||||||
namespace: "test-ns1",
|
namespace: "test-ns1",
|
||||||
volumeLifecycleMode: storagev1.VolumeLifecyclePersistent,
|
volumeLifecycleMode: storage.VolumeLifecyclePersistent,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "mounter from volume source",
|
name: "mounter from volume source",
|
||||||
spec: volume.NewSpecFromVolume(makeTestVol("test-vol1", testDriver)),
|
spec: volume.NewSpecFromVolume(makeTestVol("test-vol1", testDriver)),
|
||||||
podUID: types.UID(fmt.Sprintf("%08X", rand.Uint64())),
|
podUID: types.UID(fmt.Sprintf("%08X", rand.Uint64())),
|
||||||
namespace: "test-ns2",
|
namespace: "test-ns2",
|
||||||
volumeLifecycleMode: storagev1.VolumeLifecycleEphemeral,
|
volumeLifecycleMode: storage.VolumeLifecycleEphemeral,
|
||||||
shouldFail: true, // csi inline not enabled
|
shouldFail: true, // csi inline not enabled
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -760,22 +758,22 @@ func TestPluginNewMounter(t *testing.T) {
|
|||||||
|
|
||||||
func TestPluginNewMounterWithInline(t *testing.T) {
|
func TestPluginNewMounterWithInline(t *testing.T) {
|
||||||
defer featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, features.CSIInlineVolume, true)()
|
defer featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, features.CSIInlineVolume, true)()
|
||||||
bothModes := []storagev1.VolumeLifecycleMode{
|
bothModes := []storage.VolumeLifecycleMode{
|
||||||
storagev1.VolumeLifecycleEphemeral,
|
storage.VolumeLifecycleEphemeral,
|
||||||
storagev1.VolumeLifecyclePersistent,
|
storage.VolumeLifecyclePersistent,
|
||||||
}
|
}
|
||||||
persistentMode := []storagev1.VolumeLifecycleMode{
|
persistentMode := []storage.VolumeLifecycleMode{
|
||||||
storagev1.VolumeLifecyclePersistent,
|
storage.VolumeLifecyclePersistent,
|
||||||
}
|
}
|
||||||
ephemeralMode := []storagev1.VolumeLifecycleMode{
|
ephemeralMode := []storage.VolumeLifecycleMode{
|
||||||
storagev1.VolumeLifecycleEphemeral,
|
storage.VolumeLifecycleEphemeral,
|
||||||
}
|
}
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
name string
|
name string
|
||||||
spec *volume.Spec
|
spec *volume.Spec
|
||||||
podUID types.UID
|
podUID types.UID
|
||||||
namespace string
|
namespace string
|
||||||
volumeLifecycleMode storagev1.VolumeLifecycleMode
|
volumeLifecycleMode storage.VolumeLifecycleMode
|
||||||
shouldFail bool
|
shouldFail bool
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
@ -796,18 +794,18 @@ func TestPluginNewMounterWithInline(t *testing.T) {
|
|||||||
spec: volume.NewSpecFromPersistentVolume(makeTestPV("test-pv1", 20, testDriver, testVol), true),
|
spec: volume.NewSpecFromPersistentVolume(makeTestPV("test-pv1", 20, testDriver, testVol), true),
|
||||||
podUID: types.UID(fmt.Sprintf("%08X", rand.Uint64())),
|
podUID: types.UID(fmt.Sprintf("%08X", rand.Uint64())),
|
||||||
namespace: "test-ns1",
|
namespace: "test-ns1",
|
||||||
volumeLifecycleMode: storagev1.VolumeLifecyclePersistent,
|
volumeLifecycleMode: storage.VolumeLifecyclePersistent,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "mounter with volume source",
|
name: "mounter with volume source",
|
||||||
spec: volume.NewSpecFromVolume(makeTestVol("test-vol1", testDriver)),
|
spec: volume.NewSpecFromVolume(makeTestVol("test-vol1", testDriver)),
|
||||||
podUID: types.UID(fmt.Sprintf("%08X", rand.Uint64())),
|
podUID: types.UID(fmt.Sprintf("%08X", rand.Uint64())),
|
||||||
namespace: "test-ns2",
|
namespace: "test-ns2",
|
||||||
volumeLifecycleMode: storagev1.VolumeLifecycleEphemeral,
|
volumeLifecycleMode: storage.VolumeLifecycleEphemeral,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
runAll := func(t *testing.T, supported []storagev1.VolumeLifecycleMode) {
|
runAll := func(t *testing.T, supported []storage.VolumeLifecycleMode) {
|
||||||
for _, test := range tests {
|
for _, test := range tests {
|
||||||
t.Run(test.name, func(t *testing.T) {
|
t.Run(test.name, func(t *testing.T) {
|
||||||
driver := getTestCSIDriver(testDriver, nil, nil, supported)
|
driver := getTestCSIDriver(testDriver, nil, nil, supported)
|
||||||
@ -1097,7 +1095,7 @@ func TestPluginFindAttachablePlugin(t *testing.T) {
|
|||||||
client := fakeclient.NewSimpleClientset(
|
client := fakeclient.NewSimpleClientset(
|
||||||
getTestCSIDriver(test.driverName, nil, &test.canAttach, nil),
|
getTestCSIDriver(test.driverName, nil, &test.canAttach, nil),
|
||||||
&v1.Node{
|
&v1.Node{
|
||||||
ObjectMeta: metav1.ObjectMeta{
|
ObjectMeta: meta.ObjectMeta{
|
||||||
Name: "fakeNode",
|
Name: "fakeNode",
|
||||||
},
|
},
|
||||||
Spec: v1.NodeSpec{},
|
Spec: v1.NodeSpec{},
|
||||||
@ -1224,7 +1222,7 @@ func TestPluginFindDeviceMountablePluginBySpec(t *testing.T) {
|
|||||||
|
|
||||||
client := fakeclient.NewSimpleClientset(
|
client := fakeclient.NewSimpleClientset(
|
||||||
&v1.Node{
|
&v1.Node{
|
||||||
ObjectMeta: metav1.ObjectMeta{
|
ObjectMeta: meta.ObjectMeta{
|
||||||
Name: "fakeNode",
|
Name: "fakeNode",
|
||||||
},
|
},
|
||||||
Spec: v1.NodeSpec{},
|
Spec: v1.NodeSpec{},
|
||||||
|
@ -25,11 +25,8 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
api "k8s.io/api/core/v1"
|
api "k8s.io/api/core/v1"
|
||||||
v1 "k8s.io/api/core/v1"
|
|
||||||
storage "k8s.io/api/storage/v1"
|
storage "k8s.io/api/storage/v1"
|
||||||
storagev1 "k8s.io/api/storage/v1"
|
|
||||||
meta "k8s.io/apimachinery/pkg/apis/meta/v1"
|
meta "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
|
||||||
"k8s.io/apimachinery/pkg/runtime"
|
"k8s.io/apimachinery/pkg/runtime"
|
||||||
"k8s.io/apimachinery/pkg/types"
|
"k8s.io/apimachinery/pkg/types"
|
||||||
"k8s.io/apimachinery/pkg/util/wait"
|
"k8s.io/apimachinery/pkg/util/wait"
|
||||||
@ -47,7 +44,7 @@ import (
|
|||||||
// based on operations from the volume manager/reconciler/operation executor
|
// based on operations from the volume manager/reconciler/operation executor
|
||||||
func TestCSI_VolumeAll(t *testing.T) {
|
func TestCSI_VolumeAll(t *testing.T) {
|
||||||
defer featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, features.CSIInlineVolume, true)()
|
defer featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, features.CSIInlineVolume, true)()
|
||||||
defaultFSGroupPolicy := storagev1.ReadWriteOnceWithFSTypeFSGroupPolicy
|
defaultFSGroupPolicy := storage.ReadWriteOnceWithFSTypeFSGroupPolicy
|
||||||
|
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
name string
|
name string
|
||||||
@ -259,18 +256,18 @@ func TestCSI_VolumeAll(t *testing.T) {
|
|||||||
objs := []runtime.Object{}
|
objs := []runtime.Object{}
|
||||||
if test.driverSpec != nil {
|
if test.driverSpec != nil {
|
||||||
driverInfo = &storage.CSIDriver{
|
driverInfo = &storage.CSIDriver{
|
||||||
ObjectMeta: metav1.ObjectMeta{
|
ObjectMeta: meta.ObjectMeta{
|
||||||
Name: test.driver,
|
Name: test.driver,
|
||||||
},
|
},
|
||||||
Spec: *test.driverSpec,
|
Spec: *test.driverSpec,
|
||||||
}
|
}
|
||||||
objs = append(objs, driverInfo)
|
objs = append(objs, driverInfo)
|
||||||
}
|
}
|
||||||
objs = append(objs, &v1.Node{
|
objs = append(objs, &api.Node{
|
||||||
ObjectMeta: metav1.ObjectMeta{
|
ObjectMeta: meta.ObjectMeta{
|
||||||
Name: "fakeNode",
|
Name: "fakeNode",
|
||||||
},
|
},
|
||||||
Spec: v1.NodeSpec{},
|
Spec: api.NodeSpec{},
|
||||||
})
|
})
|
||||||
|
|
||||||
client := fakeclient.NewSimpleClientset(objs...)
|
client := fakeclient.NewSimpleClientset(objs...)
|
||||||
|
Loading…
Reference in New Issue
Block a user