Skip to content

Commit

Permalink
Add e2e test for custom path patterns
Browse files Browse the repository at this point in the history
Signed-off-by: Derek Su <derek.su@suse.com>
  • Loading branch information
derekbit committed May 27, 2024
1 parent 6d22e44 commit ab80ed5
Show file tree
Hide file tree
Showing 6 changed files with 83 additions and 2 deletions.
11 changes: 9 additions & 2 deletions test/pod_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down Expand Up @@ -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)

Expand Down
14 changes: 14 additions & 0 deletions test/testdata/custom-path-pattern/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -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
19 changes: 19 additions & 0 deletions test/testdata/custom-path-pattern/local-path-config.yaml
Original file line number Diff line number Diff line change
@@ -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"]
}
]
}
}
}
18 changes: 18 additions & 0 deletions test/testdata/custom-path-pattern/pod.yaml
Original file line number Diff line number Diff line change
@@ -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
13 changes: 13 additions & 0 deletions test/testdata/custom-path-pattern/pvc.yaml
Original file line number Diff line number Diff line change
@@ -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
10 changes: 10 additions & 0 deletions test/testdata/custom-path-pattern/storage-class.yaml
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit ab80ed5

Please sign in to comment.