@@ -4,11 +4,13 @@ package cmd
44
55import (
66 "fmt"
7+ "strings"
78 "testing"
89 "time"
910
1011 "github.com/stretchr/testify/assert"
1112 "go.uber.org/mock/gomock"
13+ storagev1 "k8s.io/api/storage/v1"
1214 v1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
1315 "k8s.io/apimachinery/pkg/types"
1416
@@ -236,29 +238,31 @@ func TestValidateInstallationArguments(t *testing.T) {
236238 imagePullPolicy string
237239 cloudProvider string
238240 cloudIdentity string
241+ fsGroupPolicy string
239242 nodePrep []string
240243 assertValid assert.ErrorAssertionFunc
241244 }{
242245 // Valid arguments
243- {"default namespace" , "default" , "text" , "IfNotPresent" , "" , "" , nil , assert .NoError },
244- {"test namespace" , "test-namespace" , "text" , "IfNotPresent" , "" , "" , []string {}, assert .NoError },
245- {"image pull never" , "test-namespace" , "json" , "Never" , "" , "" , []string {"iscsi" }, assert .NoError },
246- {"cloud provider azure" , "test-namespace" , "json" , "Never" , k8sclient .CloudProviderAzure , "" , []string {"iscsi" }, assert .NoError },
247- {"azure cloud identity key" , "test" , "text" , "Always" , k8sclient .CloudProviderAzure , k8sclient .AzureCloudIdentityKey + " a8rry78r8-7733-49bd-6656582" , []string {}, assert .NoError },
248- {"image pull always" , "test" , "text" , "Always" , k8sclient .CloudProviderAzure , "" , []string {}, assert .NoError },
246+ {"default namespace" , "default" , "text" , "IfNotPresent" , "" , "" , "" , nil , assert .NoError },
247+ {"test namespace" , "test-namespace" , "text" , "IfNotPresent" , "" , "" , string ( storagev1 . ReadWriteOnceWithFSTypeFSGroupPolicy ), []string {}, assert .NoError },
248+ {"image pull never" , "test-namespace" , "json" , "Never" , "" , "" , strings . ToLower ( string ( storagev1 . ReadWriteOnceWithFSTypeFSGroupPolicy )), []string {"iscsi" }, assert .NoError },
249+ {"cloud provider azure" , "test-namespace" , "json" , "Never" , k8sclient .CloudProviderAzure , "" , string ( storagev1 . FileFSGroupPolicy ), []string {"iscsi" }, assert .NoError },
250+ {"azure cloud identity key" , "test" , "text" , "Always" , k8sclient .CloudProviderAzure , k8sclient .AzureCloudIdentityKey + " a8rry78r8-7733-49bd-6656582" , string ( storagev1 . NoneFSGroupPolicy ), []string {}, assert .NoError },
251+ {"image pull always" , "test" , "text" , "Always" , k8sclient .CloudProviderAzure , "" , string ( storagev1 . ReadWriteOnceWithFSTypeFSGroupPolicy ), []string {}, assert .NoError },
249252
250253 // Invalid arguments
251- {"invalid namespace" , "" , "" , "" , "" , "" , []string {}, assert .Error },
252- {"invalid log format" , "test" , "html" , "" , "" , "" , []string {}, assert .Error },
253- {"invalid image pull policy" , "test" , "text" , "Anyways" , "" , "" , []string {}, assert .Error },
254- {"invalid cloud provider" , "test" , "json" , "Never" , "Docker" , "" , []string {}, assert .Error },
255- {"invalid cloud provider with azure key" , "test" , "json" , "Never" , "Docker" , k8sclient .AzureCloudIdentityKey + " a8rry78r8-7733-49bd-6656582" , []string {}, assert .Error },
256- {"invalid blank cloud identity" , "test" , "text" , "IfNotPresent" , k8sclient .CloudProviderAWS , "" , []string {}, assert .Error },
257- {"invalid blank cloud provider" , "test" , "text" , "IfNotPresent" , "" , k8sclient .AzureCloudIdentityKey + " a8rry78r8-7733-49bd-6656582" , []string {}, assert .Error },
258- {"invalid cloud identity" , "test" , "text" , "Always" , k8sclient .CloudProviderAzure , "a8rry78r8-7733-49bd-6656582" , []string {}, assert .Error },
259- {"invalid blank node prep" , "default" , "text" , "IfNotPresent" , "" , "" , []string {"" }, assert .Error },
260- {"invalid only node prep" , "default" , "text" , "IfNotPresent" , "" , "" , []string {"NVME" }, assert .Error },
261- {"invalid node prep in list" , "default" , "text" , "IfNotPresent" , "" , "" , []string {"iscsi" , "nvme" }, assert .Error },
254+ {"invalid namespace" , "" , "" , "" , "" , "" , "" , []string {}, assert .Error },
255+ {"invalid log format" , "test" , "html" , "" , "" , "" , "" , []string {}, assert .Error },
256+ {"invalid image pull policy" , "test" , "text" , "Anyways" , "" , "" , "" , []string {}, assert .Error },
257+ {"invalid cloud provider" , "test" , "json" , "Never" , "Docker" , "" , "" , []string {}, assert .Error },
258+ {"invalid cloud provider with azure key" , "test" , "json" , "Never" , "Docker" , k8sclient .AzureCloudIdentityKey + " a8rry78r8-7733-49bd-6656582" , "" , []string {}, assert .Error },
259+ {"invalid blank cloud identity" , "test" , "text" , "IfNotPresent" , k8sclient .CloudProviderAWS , "" , "" , []string {}, assert .Error },
260+ {"invalid blank cloud provider" , "test" , "text" , "IfNotPresent" , "" , k8sclient .AzureCloudIdentityKey + " a8rry78r8-7733-49bd-6656582" , "" , []string {}, assert .Error },
261+ {"invalid cloud identity" , "test" , "text" , "Always" , k8sclient .CloudProviderAzure , "a8rry78r8-7733-49bd-6656582" , "" , []string {}, assert .Error },
262+ {"invalid fsGroupPolicy" , "default" , "text" , "IfNotPresent" , "" , "" , "invalid" , nil , assert .Error },
263+ {"invalid blank node prep" , "default" , "text" , "IfNotPresent" , "" , "" , "" , []string {"" }, assert .Error },
264+ {"invalid only node prep" , "default" , "text" , "IfNotPresent" , "" , "" , "" , []string {"NVME" }, assert .Error },
265+ {"invalid node prep in list" , "default" , "text" , "IfNotPresent" , "" , "" , "" , []string {"iscsi" , "nvme" }, assert .Error },
262266 }
263267
264268 for _ , test := range tests {
@@ -269,6 +273,7 @@ func TestValidateInstallationArguments(t *testing.T) {
269273 imagePullPolicy = test .imagePullPolicy
270274 cloudProvider = test .cloudProvider
271275 cloudIdentity = test .cloudIdentity
276+ fsGroupPolicy = test .fsGroupPolicy
272277 nodePrep = test .nodePrep
273278 err := validateInstallationArguments ()
274279 test .assertValid (t , err )
0 commit comments