Skip to content

Commit 693db6e

Browse files
authored
Merge pull request kubernetes#85169 from boylee1111/enable_snapshot_e2e_test_for_pd
Enable snapshot e2e test for csi pd driver
2 parents c213196 + 9b95628 commit 693db6e

File tree

4 files changed

+69
-3
lines changed

4 files changed

+69
-3
lines changed

test/e2e/storage/drivers/csi.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,7 @@ type gcePDCSIDriver struct {
352352

353353
var _ testsuites.TestDriver = &gcePDCSIDriver{}
354354
var _ testsuites.DynamicPVTestDriver = &gcePDCSIDriver{}
355+
var _ testsuites.SnapshottableTestDriver = &gcePDCSIDriver{}
355356

356357
// InitGcePDCSIDriver returns gcePDCSIDriver that implements TestDriver interface
357358
func InitGcePDCSIDriver() testsuites.TestDriver {
@@ -383,6 +384,7 @@ func InitGcePDCSIDriver() testsuites.TestDriver {
383384
testsuites.CapTopology: true,
384385
testsuites.CapControllerExpansion: true,
385386
testsuites.CapNodeExpansion: true,
387+
testsuites.CapSnapshotDataSource: true,
386388
},
387389
RequiredAccessModes: []v1.PersistentVolumeAccessMode{v1.ReadWriteOnce},
388390
TopologyKeys: []string{GCEPDCSIZoneTopologyKey},
@@ -418,6 +420,15 @@ func (g *gcePDCSIDriver) GetDynamicProvisionStorageClass(config *testsuites.PerT
418420
return testsuites.GetStorageClass(provisioner, parameters, &delayedBinding, ns, suffix)
419421
}
420422

423+
func (g *gcePDCSIDriver) GetSnapshotClass(config *testsuites.PerTestConfig) *unstructured.Unstructured {
424+
parameters := map[string]string{}
425+
snapshotter := g.driverInfo.Name
426+
ns := config.Framework.Namespace.Name
427+
suffix := fmt.Sprintf("%s-vsc", snapshotter)
428+
429+
return testsuites.GetSnapshotClass(snapshotter, parameters, ns, suffix)
430+
}
431+
421432
func (g *gcePDCSIDriver) PrepareTest(f *framework.Framework) (*testsuites.PerTestConfig, func()) {
422433
ginkgo.By("deploying csi gce-pd driver")
423434
cancelLogging := testsuites.StartPodLogs(f)

test/e2e/storage/testsuites/snapshottable.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import (
2828
"k8s.io/apimachinery/pkg/runtime/schema"
2929
"k8s.io/client-go/dynamic"
3030
"k8s.io/kubernetes/test/e2e/framework"
31+
e2epod "k8s.io/kubernetes/test/e2e/framework/pod"
3132
e2epv "k8s.io/kubernetes/test/e2e/framework/pv"
3233
"k8s.io/kubernetes/test/e2e/framework/volume"
3334
"k8s.io/kubernetes/test/e2e/storage/testpatterns"
@@ -146,6 +147,12 @@ func (s *snapshottableTestSuite) defineTests(driver TestDriver, pattern testpatt
146147
framework.Failf("Error deleting claim %q. Error: %v", pvc.Name, err)
147148
}
148149
}()
150+
151+
ginkgo.By("starting a pod")
152+
command := fmt.Sprintf("grep '%s' /mnt/test/initialData", pvc.Namespace)
153+
pod := StartInPodWithVolume(cs, pvc.Namespace, pvc.Name, "pvc-snapshottable-tester", command, e2epod.NodeSelection{Name: config.ClientNodeName})
154+
defer StopPod(cs, pod)
155+
149156
err = e2epv.WaitForPersistentVolumeClaimPhase(v1.ClaimBound, cs, pvc.Namespace, pvc.Name, framework.Poll, framework.ClaimProvisionTimeout)
150157
framework.ExpectNoError(err)
151158

test/e2e/testing-manifests/storage-csi/gce-pd/controller_ss.yaml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,18 @@ spec:
1515
spec:
1616
serviceAccountName: csi-gce-pd-controller-sa
1717
containers:
18+
- name: csi-snapshotter
19+
# TODO: replace with official 2.0.0 release when ready
20+
image: quay.io/k8scsi/csi-snapshotter:v2.0.0-rc2
21+
args:
22+
- "--v=5"
23+
- "--csi-address=/csi/csi.sock"
24+
imagePullPolicy: Always
25+
volumeMounts:
26+
- name: socket-dir
27+
mountPath: /csi
1828
- name: csi-provisioner
19-
image: gcr.io/gke-release/csi-provisioner:v1.4.0-gke.0
29+
image: quay.io/k8scsi/csi-provisioner:v1.5.0-rc1
2030
args:
2131
- "--v=5"
2232
- "--csi-address=/csi/csi.sock"

test/e2e/testing-manifests/storage-csi/gce-pd/csi-controller-rbac.yaml

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,12 @@ rules:
2929
- apiGroups: [""]
3030
resources: ["nodes"]
3131
verbs: ["get", "list", "watch"]
32+
- apiGroups: ["snapshot.storage.k8s.io"]
33+
resources: ["volumesnapshots"]
34+
verbs: ["get", "list"]
35+
- apiGroups: ["snapshot.storage.k8s.io"]
36+
resources: ["volumesnapshotcontents"]
37+
verbs: ["get", "list"]
3238

3339
---
3440

@@ -43,7 +49,7 @@ roleRef:
4349
kind: ClusterRole
4450
name: csi-gce-pd-provisioner-role
4551
apiGroup: rbac.authorization.k8s.io
46-
52+
4753
---
4854
# xref: https://github.com/kubernetes-csi/external-attacher/blob/master/deploy/kubernetes/rbac.yaml
4955
kind: ClusterRole
@@ -112,6 +118,39 @@ roleRef:
112118
name: csi-gce-pd-resizer-role
113119
apiGroup: rbac.authorization.k8s.io
114120

121+
---
122+
# xref: https://github.com/kubernetes-csi/external-snapshotter/blob/master/deploy/kubernetes/csi-snapshotter/rbac-csi-snapshotter.yaml
123+
kind: ClusterRole
124+
apiVersion: rbac.authorization.k8s.io/v1
125+
metadata:
126+
name: csi-gce-pd-snapshotter-role
127+
rules:
128+
- apiGroups: [""]
129+
resources: ["events"]
130+
verbs: ["list", "watch", "create", "update", "patch"]
131+
- apiGroups: ["snapshot.storage.k8s.io"]
132+
resources: ["volumesnapshotclasses"]
133+
verbs: ["get", "list", "watch"]
134+
- apiGroups: ["snapshot.storage.k8s.io"]
135+
resources: ["volumesnapshotcontents"]
136+
verbs: ["get", "list", "watch", "update", "delete", "patch"]
137+
- apiGroups: ["snapshot.storage.k8s.io"]
138+
resources: ["volumesnapshotcontents/status"]
139+
verbs: ["update", "patch"]
140+
141+
---
142+
kind: ClusterRoleBinding
143+
apiVersion: rbac.authorization.k8s.io/v1
144+
metadata:
145+
name: csi-gce-pd-controller-snapshotter-binding
146+
subjects:
147+
- kind: ServiceAccount
148+
name: csi-gce-pd-controller-sa
149+
roleRef:
150+
kind: ClusterRole
151+
name: csi-gce-pd-snapshotter-role
152+
apiGroup: rbac.authorization.k8s.io
153+
115154
---
116155
# priviledged Pod Security Policy, previously defined via PrivilegedTestPSPClusterRoleBinding()
117156
kind: ClusterRoleBinding
@@ -121,7 +160,6 @@ metadata:
121160
subjects:
122161
- kind: ServiceAccount
123162
name: csi-gce-pd-controller-sa
124-
namespace: default
125163
roleRef:
126164
kind: ClusterRole
127165
name: e2e-test-privileged-psp

0 commit comments

Comments
 (0)