Skip to content

Commit

Permalink
test: fix ut and refine examples
Browse files Browse the repository at this point in the history
fix
  • Loading branch information
andyzhangx committed Oct 13, 2024
1 parent 2275edd commit c788daa
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 166 deletions.
53 changes: 0 additions & 53 deletions deploy/example-cc/cc-deployment.yaml

This file was deleted.

24 changes: 0 additions & 24 deletions deploy/example-cc/cc-nginx-pod-azurefile.yaml

This file was deleted.

72 changes: 0 additions & 72 deletions deploy/example-cc/shared-pvc-across-runtimes.yaml

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ spec:
- metadata:
name: persistent-storage
spec:
storageClassName: azurefile-csi
storageClassName: azurefile-csi-kata-cc
accessModes: ["ReadWriteMany"]
resources:
requests:
Expand Down
20 changes: 20 additions & 0 deletions deploy/example/kata-cc/storageclass-azurefile-kata-cc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
name: azurefile-csi-kata-cc
provisioner: file.csi.azure.com
allowVolumeExpansion: true
parameters:
skuName: Premium_LRS # available values: Premium_LRS, Premium_ZRS, Standard_LRS, Standard_GRS, Standard_ZRS, Standard_RAGRS, Standard_RAGZRS
enableKataCCMount: "true"
reclaimPolicy: Delete
volumeBindingMode: Immediate
mountOptions:
- dir_mode=0777
- file_mode=0777
- mfsymlinks
- cache=strict # https://linux.die.net/man/8/mount.cifs
- nosharesock # reduce probability of reconnect race
- actimeo=30 # reduce latency for metadata-heavy workload
- nobrl # disable sending byte range lock requests to the server and for applications which have challenges with posix locks
14 changes: 5 additions & 9 deletions deploy/rbac-csi-azurefile-node.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,7 @@ roleRef:
kind: ClusterRole
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: csi-{{ .Values.rbac.name }}-node-katacc-role
labels:
{{- include "azurefile.labels" . | nindent 4 }}
name: csi-azurefile-node-katacc-role
rules:
- apiGroups: [""]
resources: ["pods"]
Expand All @@ -46,15 +44,13 @@ rules:
kind: ClusterRoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: csi-{{ .Values.rbac.name }}-node-katacc-binding
labels:
{{- include "azurefile.labels" . | nindent 4 }}
name: csi-azurefile-node-katacc-binding
subjects:
- kind: ServiceAccount
name: {{ .Values.serviceAccount.node }}
namespace: {{ .Release.Namespace }}
name: csi-azurefile-node-sa
namespace: kube-system
roleRef:
kind: ClusterRole
name: csi-{{ .Values.rbac.name }}-node-katacc-role
name: csi-azurefile-node-katacc-role
apiGroup: rbac.authorization.k8s.io
---
2 changes: 1 addition & 1 deletion hack/verify-yamllint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ fi
LOG=/tmp/yamllint.log
helmPath=charts/latest/azurefile-csi-driver/templates

for path in "deploy/*.yaml" "deploy/example/*.yaml" "deploy/example/snapshot/*.yaml" "deploy/example/disk/*.yaml" "deploy/example/windows/*.yaml" "deploy/example/metrics/*.yaml" "deploy/example/largeFileShares/*.yaml" "deploy/example/smb-provisioner/*.yaml" "deploy/example/cloning/*.yaml" "deploy/example-cc/*.yaml"
for path in "deploy/*.yaml" "deploy/example/*.yaml" "deploy/example/snapshot/*.yaml" "deploy/example/disk/*.yaml" "deploy/example/windows/*.yaml" "deploy/example/metrics/*.yaml" "deploy/example/largeFileShares/*.yaml" "deploy/example/smb-provisioner/*.yaml" "deploy/example/cloning/*.yaml" "deploy/example/kata-cc/*.yaml"
do
echo "checking yamllint under path: $path ..."
yamllint -f parsable $path | grep -v "line too long" > $LOG
Expand Down
18 changes: 12 additions & 6 deletions pkg/azurefile/nodeserver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -341,14 +341,17 @@ func TestNodeUnpublishVolume(t *testing.T) {
expectedErr: testutil.TestError{
DefaultError: status.Error(codes.Internal, fmt.Sprintf("failed to unmount target %s: fake IsLikelyNotMountPoint: fake error", errorTarget)),
},
setup: func() {
if runtime.GOOS == "windows" {
mockDirectVolume.EXPECT().Remove(errorTarget).Return(nil)
}
},
},
{
desc: "[Success] Valid request",
req: csi.NodeUnpublishVolumeRequest{TargetPath: targetFile, VolumeId: "vol_1"},
setup: func() {
if runtime.GOOS != "windows" {
mockDirectVolume.EXPECT().Remove(targetFile).Return(nil)
}
mockDirectVolume.EXPECT().Remove(targetFile).Return(nil)
},
expectedErr: testutil.TestError{},
},
Expand Down Expand Up @@ -888,14 +891,17 @@ func TestNodeUnstageVolume(t *testing.T) {
expectedErr: testutil.TestError{
DefaultError: status.Error(codes.Internal, fmt.Sprintf("failed to unmount staging target %v: fake IsLikelyNotMountPoint: fake error", errorTarget)),
},
setup: func() {
if runtime.GOOS == "windows" {
mockDirectVolume.EXPECT().Remove(errorTarget).Return(nil)
}
},
},
{
desc: "[Success] Valid request",
req: csi.NodeUnstageVolumeRequest{StagingTargetPath: targetFile, VolumeId: "vol_1"},
setup: func() {
if runtime.GOOS != "windows" {
mockDirectVolume.EXPECT().Remove(targetFile).Return(nil)
}
mockDirectVolume.EXPECT().Remove(targetFile).Return(nil)
},
expectedErr: testutil.TestError{},
},
Expand Down

0 comments on commit c788daa

Please sign in to comment.