diff --git a/test/pod_test.go b/test/pod_test.go index 3d129ebb0fe7eab979989894446a2e69a127b0cf..5a69d7e7ec6f4fdca6b3d94d1ab73dd0b009e1e9 100644 --- a/test/pod_test.go +++ b/test/pod_test.go @@ -5,11 +5,12 @@ package test import ( "fmt" - "github.com/kelseyhightower/envconfig" - "github.com/stretchr/testify/suite" "strings" "testing" "time" + + "github.com/kelseyhightower/envconfig" + "github.com/stretchr/testify/suite" ) const ( @@ -150,6 +151,12 @@ func (p *PodTestSuite) TestPodWithMultipleStorageClasses() { runTest(p, []string{p.config.IMAGE}, "ready", hostPathVolumeType) } +func (p *PodTestSuite) TestPodWithCustomPathPatternStorageClasses() { + p.kustomizeDir = "custom-path-pattern" + + runTest(p, []string{p.config.IMAGE}, "ready", hostPathVolumeType) +} + func runTest(p *PodTestSuite, images []string, waitCondition, volumeType string) { kustomizeDir := testdataFile(p.kustomizeDir) diff --git a/test/testdata/custom-path-pattern/kustomization.yaml b/test/testdata/custom-path-pattern/kustomization.yaml new file mode 100644 index 0000000000000000000000000000000000000000..df458be4f73a1e062153bd90435f6ea0ee6e8bca --- /dev/null +++ b/test/testdata/custom-path-pattern/kustomization.yaml @@ -0,0 +1,14 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +resources: +- ../../../deploy +- storage-class.yaml +- pod.yaml +- pvc.yaml +patchesStrategicMerge: +- local-path-config.yaml +commonLabels: + app: local-path-provisioner +images: +- name: rancher/local-path-provisioner + newTag: dev \ No newline at end of file diff --git a/test/testdata/custom-path-pattern/local-path-config.yaml b/test/testdata/custom-path-pattern/local-path-config.yaml new file mode 100644 index 0000000000000000000000000000000000000000..ee2087c0cd332f0dc18aea91c50651631266527d --- /dev/null +++ b/test/testdata/custom-path-pattern/local-path-config.yaml @@ -0,0 +1,19 @@ +kind: ConfigMap +apiVersion: v1 +metadata: + name: local-path-config + namespace: local-path-storage +data: + config.json: |- + { + "storageClassConfigs":{ + "local-path-custom-path-pattern": { + "nodePathMap": [ + { + "node":"DEFAULT_PATH_FOR_NON_LISTED_NODES", + "paths":["/opt/local-path-provisioner"] + } + ] + } + } + } \ No newline at end of file diff --git a/test/testdata/custom-path-pattern/pod.yaml b/test/testdata/custom-path-pattern/pod.yaml new file mode 100644 index 0000000000000000000000000000000000000000..087251166bffec9fab2817fc3782f50d23b93249 --- /dev/null +++ b/test/testdata/custom-path-pattern/pod.yaml @@ -0,0 +1,18 @@ +apiVersion: v1 +kind: Pod +metadata: + name: volume-test +spec: + containers: + - name: volume-test + image: nginx:stable-alpine + imagePullPolicy: IfNotPresent + volumeMounts: + - name: volv + mountPath: /data + ports: + - containerPort: 80 + volumes: + - name: volv + persistentVolumeClaim: + claimName: local-path-pvc \ No newline at end of file diff --git a/test/testdata/custom-path-pattern/pvc.yaml b/test/testdata/custom-path-pattern/pvc.yaml new file mode 100644 index 0000000000000000000000000000000000000000..67f46a2cf455eebabbd15b051055ee17764f7e93 --- /dev/null +++ b/test/testdata/custom-path-pattern/pvc.yaml @@ -0,0 +1,13 @@ +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + labels: + app: test + name: local-path-pvc +spec: + storageClassName: local-path-custom-path-pattern + accessModes: + - ReadWriteOnce + resources: + requests: + storage: 100Mi \ No newline at end of file diff --git a/test/testdata/custom-path-pattern/storage-class.yaml b/test/testdata/custom-path-pattern/storage-class.yaml new file mode 100644 index 0000000000000000000000000000000000000000..7656afc3b7c66089969383a98ea1ab30f19bbcc8 --- /dev/null +++ b/test/testdata/custom-path-pattern/storage-class.yaml @@ -0,0 +1,10 @@ +apiVersion: storage.k8s.io/v1 +kind: StorageClass +metadata: + name: local-path-custom-path-pattern +provisioner: rancher.io/local-path +parameters: + nodePath: /opt/local-path-provisioner + pathPattern: "{{ .PVC.Namespace }}/{{ .PVC.Name }}" +volumeBindingMode: WaitForFirstConsumer +reclaimPolicy: Retain \ No newline at end of file