Change:
<!-- Please only use this template for submitting enhancement requests --What would you like to be : Enable snapshot tests for gce-pd csi driver tests in k/k Why is this needed: Snapshot is moving to beta in 1.16. We should enable snapshot e2e tests with a real storage driver.
/assign cc
/sig storage
Issues go stale after 90d of inactivity. Mark the issue as fresh with . Stale issues rot after an additional 30d of inactivity and eventually close. If this issue is safe to close now please do so with . Send feedback to sig-testing, kubernetes/test-infra and/or . /lifecycle stale
/remove-lifecycle stale
cc
/assign
target 1.17 instead of 1.16

Discussion:
var _ testsuites.TestDriver = &gcePDCSIDriver{} var _ testsuites.DynamicPVTestDriver = &gcePDCSIDriver{} <ins> var _ testsuites.SnapshottableTestDriver = &gcePDCSIDriver{} </ins> // InitGcePDCSIDriver returns gcePDCSIDriver that implements TestDriver interface func InitGcePDCSIDriver() testsuites.TestDriver {

testsuites.CapTopology:            true, testsuites.CapControllerExpansion: true, testsuites.CapNodeExpansion:       true, <ins> testsuites.CapSnapshotDataSource:  true, </ins> }, RequiredAccessModes: []v1.PersistentVolumeAccessMode{v1.ReadWriteOnce}, TopologyKeys:        []string{GCEPDCSIZoneTopologyKey},

return testsuites.GetStorageClass(provisioner, parameters, &delayedBinding, ns, suffix) } <ins> 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) } </ins> func (g *gcePDCSIDriver) PrepareTest(f *framework.Framework) (*testsuites.PerTestConfig, func()) { ginkgo.By("deploying csi gce-pd driver") cancelLogging := testsuites.StartPodLogs(f)

"k8s.io/apimachinery/pkg/runtime/schema" "k8s.io/client-go/dynamic" "k8s.io/kubernetes/test/e2e/framework" <ins> e2epod "k8s.io/kubernetes/test/e2e/framework/pod" </ins> e2epv "k8s.io/kubernetes/test/e2e/framework/pv" "k8s.io/kubernetes/test/e2e/framework/volume" "k8s.io/kubernetes/test/e2e/storage/testpatterns"

framework.Failf("Error deleting claim %q. Error: %v", pvc.Name, err) } }() <ins> ginkgo.By("starting a pod") command := fmt.Sprintf("grep '%s' /mnt/test/initialData", pvc.Namespace) pod := StartInPodWithVolume(cs, pvc.Namespace, pvc.Name, "pvc-snapshottable-tester", command, e2epod.NodeSelection{Name: config.ClientNodeName}) defer StopPod(cs, pod) </ins> err = e2epv.WaitForPersistentVolumeClaimPhase(v1.ClaimBound, cs, pvc.Namespace, pvc.Name, framework.Poll, framework.ClaimProvisionTimeout) framework.ExpectNoError(err)

spec: serviceAccountName: csi-gce-pd-controller-sa containers: <ins> - 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 </ins> - name: csi-provisioner <del> image: gcr.io/gke-release/csi-provisioner:v1.4.0-gke.0 </del> <ins> image: quay.io/k8scsi/csi-provisioner:v1.5.0-rc1 </ins> args: - "--v=5" - "--csi-address=/csi/csi.sock"

- apiGroups: [""] resources: ["nodes"] verbs: ["get", "list", "watch"] <ins> - apiGroups: ["snapshot.storage.k8s.io"] resources: ["volumesnapshots"] verbs: ["get", "list"] - apiGroups: ["snapshot.storage.k8s.io"] resources: ["volumesnapshotcontents"] verbs: ["get", "list"] </ins> ---

kind: ClusterRole name: csi-gce-pd-provisioner-role apiGroup: rbac.authorization.k8s.io --- # xref: https://github.com/kubernetes-csi/external-attacher/blob/master/deploy/kubernetes/rbac.yaml kind: ClusterRole

apiGroup: rbac.authorization.k8s.io --- <ins> # 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 --- </ins> # priviledged Pod Security Policy, previously defined via PrivilegedTestPSPClusterRoleBinding() kind: ClusterRoleBinding apiVersion: rbac.authorization.k8s.io/v1

subjects: - kind: ServiceAccount name: csi-gce-pd-controller-sa <del> namespace: default </del> roleRef: kind: ClusterRole name: e2e-test-privileged-psp