mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 03:41:45 +00:00
Merge pull request #85371 from boylee1111/enable_snapshot_e2e_test_for_pd
Enable snapshottable e2e test for csi pd driver
This commit is contained in:
commit
038f645f12
@ -352,6 +352,7 @@ type gcePDCSIDriver struct {
|
|||||||
|
|
||||||
var _ testsuites.TestDriver = &gcePDCSIDriver{}
|
var _ testsuites.TestDriver = &gcePDCSIDriver{}
|
||||||
var _ testsuites.DynamicPVTestDriver = &gcePDCSIDriver{}
|
var _ testsuites.DynamicPVTestDriver = &gcePDCSIDriver{}
|
||||||
|
var _ testsuites.SnapshottableTestDriver = &gcePDCSIDriver{}
|
||||||
|
|
||||||
// InitGcePDCSIDriver returns gcePDCSIDriver that implements TestDriver interface
|
// InitGcePDCSIDriver returns gcePDCSIDriver that implements TestDriver interface
|
||||||
func InitGcePDCSIDriver() testsuites.TestDriver {
|
func InitGcePDCSIDriver() testsuites.TestDriver {
|
||||||
@ -383,6 +384,7 @@ func InitGcePDCSIDriver() testsuites.TestDriver {
|
|||||||
testsuites.CapTopology: true,
|
testsuites.CapTopology: true,
|
||||||
testsuites.CapControllerExpansion: true,
|
testsuites.CapControllerExpansion: true,
|
||||||
testsuites.CapNodeExpansion: true,
|
testsuites.CapNodeExpansion: true,
|
||||||
|
testsuites.CapSnapshotDataSource: true,
|
||||||
},
|
},
|
||||||
RequiredAccessModes: []v1.PersistentVolumeAccessMode{v1.ReadWriteOnce},
|
RequiredAccessModes: []v1.PersistentVolumeAccessMode{v1.ReadWriteOnce},
|
||||||
TopologyKeys: []string{GCEPDCSIZoneTopologyKey},
|
TopologyKeys: []string{GCEPDCSIZoneTopologyKey},
|
||||||
@ -418,6 +420,15 @@ func (g *gcePDCSIDriver) GetDynamicProvisionStorageClass(config *testsuites.PerT
|
|||||||
return testsuites.GetStorageClass(provisioner, parameters, &delayedBinding, ns, suffix)
|
return testsuites.GetStorageClass(provisioner, parameters, &delayedBinding, ns, suffix)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (g *gcePDCSIDriver) GetSnapshotClass(config *testsuites.PerTestConfig) *unstructured.Unstructured {
|
||||||
|
parameters := map[string]string{}
|
||||||
|
snapshotter := g.driverInfo.Name
|
||||||
|
ns := config.Framework.Namespace.Name
|
||||||
|
suffix := fmt.Sprintf("%s-vsc", snapshotter)
|
||||||
|
|
||||||
|
return testsuites.GetSnapshotClass(snapshotter, parameters, ns, suffix)
|
||||||
|
}
|
||||||
|
|
||||||
func (g *gcePDCSIDriver) PrepareTest(f *framework.Framework) (*testsuites.PerTestConfig, func()) {
|
func (g *gcePDCSIDriver) PrepareTest(f *framework.Framework) (*testsuites.PerTestConfig, func()) {
|
||||||
ginkgo.By("deploying csi gce-pd driver")
|
ginkgo.By("deploying csi gce-pd driver")
|
||||||
cancelLogging := testsuites.StartPodLogs(f)
|
cancelLogging := testsuites.StartPodLogs(f)
|
||||||
|
@ -631,6 +631,12 @@ func prepareSnapshotDataSourceForProvisioning(
|
|||||||
ginkgo.By("[Initialize dataSource]creating a initClaim")
|
ginkgo.By("[Initialize dataSource]creating a initClaim")
|
||||||
updatedClaim, err := client.CoreV1().PersistentVolumeClaims(initClaim.Namespace).Create(initClaim)
|
updatedClaim, err := client.CoreV1().PersistentVolumeClaims(initClaim.Namespace).Create(initClaim)
|
||||||
framework.ExpectNoError(err)
|
framework.ExpectNoError(err)
|
||||||
|
|
||||||
|
// write namespace to the /mnt/test (= the volume).
|
||||||
|
ginkgo.By("[Initialize dataSource]write data to volume")
|
||||||
|
command := fmt.Sprintf("echo '%s' > /mnt/test/initialData", updatedClaim.GetNamespace())
|
||||||
|
RunInPodWithVolume(client, updatedClaim.Namespace, updatedClaim.Name, "pvc-snapshot-writer", command, node)
|
||||||
|
|
||||||
err = e2epv.WaitForPersistentVolumeClaimPhase(v1.ClaimBound, client, updatedClaim.Namespace, updatedClaim.Name, framework.Poll, framework.ClaimProvisionTimeout)
|
err = e2epv.WaitForPersistentVolumeClaimPhase(v1.ClaimBound, client, updatedClaim.Namespace, updatedClaim.Name, framework.Poll, framework.ClaimProvisionTimeout)
|
||||||
framework.ExpectNoError(err)
|
framework.ExpectNoError(err)
|
||||||
|
|
||||||
@ -639,11 +645,6 @@ func prepareSnapshotDataSourceForProvisioning(
|
|||||||
_, err = client.CoreV1().PersistentVolumeClaims(updatedClaim.Namespace).Get(updatedClaim.Name, metav1.GetOptions{})
|
_, err = client.CoreV1().PersistentVolumeClaims(updatedClaim.Namespace).Get(updatedClaim.Name, metav1.GetOptions{})
|
||||||
framework.ExpectNoError(err)
|
framework.ExpectNoError(err)
|
||||||
|
|
||||||
// write namespace to the /mnt/test (= the volume).
|
|
||||||
ginkgo.By("[Initialize dataSource]write data to volume")
|
|
||||||
command := fmt.Sprintf("echo '%s' > /mnt/test/initialData", updatedClaim.GetNamespace())
|
|
||||||
RunInPodWithVolume(client, updatedClaim.Namespace, updatedClaim.Name, "pvc-snapshot-writer", command, node)
|
|
||||||
|
|
||||||
ginkgo.By("[Initialize dataSource]creating a SnapshotClass")
|
ginkgo.By("[Initialize dataSource]creating a SnapshotClass")
|
||||||
snapshotClass, err = dynamicClient.Resource(snapshotClassGVR).Create(snapshotClass, metav1.CreateOptions{})
|
snapshotClass, err = dynamicClient.Resource(snapshotClassGVR).Create(snapshotClass, metav1.CreateOptions{})
|
||||||
|
|
||||||
|
@ -28,6 +28,7 @@ import (
|
|||||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||||
"k8s.io/client-go/dynamic"
|
"k8s.io/client-go/dynamic"
|
||||||
"k8s.io/kubernetes/test/e2e/framework"
|
"k8s.io/kubernetes/test/e2e/framework"
|
||||||
|
e2epod "k8s.io/kubernetes/test/e2e/framework/pod"
|
||||||
e2epv "k8s.io/kubernetes/test/e2e/framework/pv"
|
e2epv "k8s.io/kubernetes/test/e2e/framework/pv"
|
||||||
"k8s.io/kubernetes/test/e2e/framework/volume"
|
"k8s.io/kubernetes/test/e2e/framework/volume"
|
||||||
"k8s.io/kubernetes/test/e2e/storage/testpatterns"
|
"k8s.io/kubernetes/test/e2e/storage/testpatterns"
|
||||||
@ -146,6 +147,12 @@ func (s *snapshottableTestSuite) defineTests(driver TestDriver, pattern testpatt
|
|||||||
framework.Failf("Error deleting claim %q. Error: %v", pvc.Name, err)
|
framework.Failf("Error deleting claim %q. Error: %v", pvc.Name, err)
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
|
ginkgo.By("starting a pod to use the claim")
|
||||||
|
command := "echo 'hello world' > /mnt/test/data"
|
||||||
|
pod := StartInPodWithVolume(cs, pvc.Namespace, pvc.Name, "pvc-snapshottable-tester", command, e2epod.NodeSelection{Name: config.ClientNodeName})
|
||||||
|
defer StopPod(cs, pod)
|
||||||
|
|
||||||
err = e2epv.WaitForPersistentVolumeClaimPhase(v1.ClaimBound, cs, pvc.Namespace, pvc.Name, framework.Poll, framework.ClaimProvisionTimeout)
|
err = e2epv.WaitForPersistentVolumeClaimPhase(v1.ClaimBound, cs, pvc.Namespace, pvc.Name, framework.Poll, framework.ClaimProvisionTimeout)
|
||||||
framework.ExpectNoError(err)
|
framework.ExpectNoError(err)
|
||||||
|
|
||||||
|
@ -15,8 +15,18 @@ spec:
|
|||||||
spec:
|
spec:
|
||||||
serviceAccountName: csi-gce-pd-controller-sa
|
serviceAccountName: csi-gce-pd-controller-sa
|
||||||
containers:
|
containers:
|
||||||
|
- name: csi-snapshotter
|
||||||
|
# TODO: replace with official 2.0.0 release when ready
|
||||||
|
image: quay.io/k8scsi/csi-snapshotter:v2.0.0-rc2
|
||||||
|
args:
|
||||||
|
- "--v=5"
|
||||||
|
- "--csi-address=/csi/csi.sock"
|
||||||
|
imagePullPolicy: Always
|
||||||
|
volumeMounts:
|
||||||
|
- name: socket-dir
|
||||||
|
mountPath: /csi
|
||||||
- name: csi-provisioner
|
- name: csi-provisioner
|
||||||
image: gcr.io/gke-release/csi-provisioner:v1.4.0-gke.0
|
image: quay.io/k8scsi/csi-provisioner:v1.5.0-rc1
|
||||||
args:
|
args:
|
||||||
- "--v=5"
|
- "--v=5"
|
||||||
- "--csi-address=/csi/csi.sock"
|
- "--csi-address=/csi/csi.sock"
|
||||||
|
@ -29,6 +29,12 @@ rules:
|
|||||||
- apiGroups: [""]
|
- apiGroups: [""]
|
||||||
resources: ["nodes"]
|
resources: ["nodes"]
|
||||||
verbs: ["get", "list", "watch"]
|
verbs: ["get", "list", "watch"]
|
||||||
|
- apiGroups: ["snapshot.storage.k8s.io"]
|
||||||
|
resources: ["volumesnapshots"]
|
||||||
|
verbs: ["get", "list"]
|
||||||
|
- apiGroups: ["snapshot.storage.k8s.io"]
|
||||||
|
resources: ["volumesnapshotcontents"]
|
||||||
|
verbs: ["get", "list"]
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
@ -112,6 +118,39 @@ roleRef:
|
|||||||
name: csi-gce-pd-resizer-role
|
name: csi-gce-pd-resizer-role
|
||||||
apiGroup: rbac.authorization.k8s.io
|
apiGroup: rbac.authorization.k8s.io
|
||||||
|
|
||||||
|
---
|
||||||
|
# xref: https://github.com/kubernetes-csi/external-snapshotter/blob/master/deploy/kubernetes/csi-snapshotter/rbac-csi-snapshotter.yaml
|
||||||
|
kind: ClusterRole
|
||||||
|
apiVersion: rbac.authorization.k8s.io/v1
|
||||||
|
metadata:
|
||||||
|
name: csi-gce-pd-snapshotter-role
|
||||||
|
rules:
|
||||||
|
- apiGroups: [""]
|
||||||
|
resources: ["events"]
|
||||||
|
verbs: ["list", "watch", "create", "update", "patch"]
|
||||||
|
- apiGroups: ["snapshot.storage.k8s.io"]
|
||||||
|
resources: ["volumesnapshotclasses"]
|
||||||
|
verbs: ["get", "list", "watch"]
|
||||||
|
- apiGroups: ["snapshot.storage.k8s.io"]
|
||||||
|
resources: ["volumesnapshotcontents"]
|
||||||
|
verbs: ["get", "list", "watch", "update", "delete", "patch"]
|
||||||
|
- apiGroups: ["snapshot.storage.k8s.io"]
|
||||||
|
resources: ["volumesnapshotcontents/status"]
|
||||||
|
verbs: ["update", "patch"]
|
||||||
|
|
||||||
|
---
|
||||||
|
kind: ClusterRoleBinding
|
||||||
|
apiVersion: rbac.authorization.k8s.io/v1
|
||||||
|
metadata:
|
||||||
|
name: csi-gce-pd-controller-snapshotter-binding
|
||||||
|
subjects:
|
||||||
|
- kind: ServiceAccount
|
||||||
|
name: csi-gce-pd-controller-sa
|
||||||
|
roleRef:
|
||||||
|
kind: ClusterRole
|
||||||
|
name: csi-gce-pd-snapshotter-role
|
||||||
|
apiGroup: rbac.authorization.k8s.io
|
||||||
|
|
||||||
---
|
---
|
||||||
# priviledged Pod Security Policy, previously defined via PrivilegedTestPSPClusterRoleBinding()
|
# priviledged Pod Security Policy, previously defined via PrivilegedTestPSPClusterRoleBinding()
|
||||||
kind: ClusterRoleBinding
|
kind: ClusterRoleBinding
|
||||||
@ -121,7 +160,6 @@ metadata:
|
|||||||
subjects:
|
subjects:
|
||||||
- kind: ServiceAccount
|
- kind: ServiceAccount
|
||||||
name: csi-gce-pd-controller-sa
|
name: csi-gce-pd-controller-sa
|
||||||
namespace: default
|
|
||||||
roleRef:
|
roleRef:
|
||||||
kind: ClusterRole
|
kind: ClusterRole
|
||||||
name: e2e-test-privileged-psp
|
name: e2e-test-privileged-psp
|
||||||
|
Loading…
Reference in New Issue
Block a user