Skip to content
Snippets Groups Projects
Commit ab80ed5b authored by Derek Su's avatar Derek Su
Browse files

Add e2e test for custom path patterns


Signed-off-by: default avatarDerek Su <derek.su@suse.com>
parent 6d22e44d
No related branches found
No related tags found
No related merge requests found
...@@ -5,11 +5,12 @@ package test ...@@ -5,11 +5,12 @@ package test
import ( import (
"fmt" "fmt"
"github.com/kelseyhightower/envconfig"
"github.com/stretchr/testify/suite"
"strings" "strings"
"testing" "testing"
"time" "time"
"github.com/kelseyhightower/envconfig"
"github.com/stretchr/testify/suite"
) )
const ( const (
...@@ -150,6 +151,12 @@ func (p *PodTestSuite) TestPodWithMultipleStorageClasses() { ...@@ -150,6 +151,12 @@ func (p *PodTestSuite) TestPodWithMultipleStorageClasses() {
runTest(p, []string{p.config.IMAGE}, "ready", hostPathVolumeType) 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) { func runTest(p *PodTestSuite, images []string, waitCondition, volumeType string) {
kustomizeDir := testdataFile(p.kustomizeDir) kustomizeDir := testdataFile(p.kustomizeDir)
......
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
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
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
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
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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment