@@ -62,6 +62,23 @@ var _ = Describe("Storage controller medium tests", func() {
6262 })
6363
6464 It ("Checking field propagation to objects" , func () {
65+ getStatefulSet := func (objName string ) (appsv1.StatefulSet , error ) {
66+ foundStatefulSets := appsv1.StatefulSetList {}
67+ err := k8sClient .List (ctx , & foundStatefulSets , client .InNamespace (
68+ testobjects .YdbNamespace ,
69+ ))
70+ if err != nil {
71+ return appsv1.StatefulSet {}, err
72+ }
73+ for _ , statefulSet := range foundStatefulSets .Items {
74+ if statefulSet .Name == objName {
75+ return statefulSet , nil
76+ }
77+ }
78+
79+ return appsv1.StatefulSet {}, fmt .Errorf ("Statefulset with name %s was not found" , objName )
80+ }
81+
6582 storageSample := testobjects .DefaultStorage (filepath .Join (".." , ".." , ".." , "tests" , "data" , "storage-mirror-3-dc-config.yaml" ))
6683
6784 tmpFilesDir := "/tmp/mounted_volume"
@@ -227,5 +244,66 @@ var _ = Describe("Storage controller medium tests", func() {
227244 return len (foundStatefulSets .Items )
228245 }, test .Timeout , test .Interval ).Should (Equal (1 ))
229246 })
247+
248+ By ("check --auth-token-file arg in StatefulSet..." , func () {
249+ By ("create auth-token Secret with default name..." )
250+ defaultAuthTokenSecret := & corev1.Secret {
251+ ObjectMeta : metav1.ObjectMeta {
252+ Name : v1alpha1 .AuthTokenSecretName ,
253+ Namespace : testobjects .YdbNamespace ,
254+ },
255+ StringData : map [string ]string {
256+ v1alpha1 .AuthTokenSecretKey : "StaffApiUserToken: 'default-token'" ,
257+ },
258+ }
259+ Expect (k8sClient .Create (ctx , defaultAuthTokenSecret ))
260+
261+ By ("append auth-token Secret inside Storage manifest..." )
262+ Eventually (func () error {
263+ foundStorage := v1alpha1.Storage {}
264+ Expect (k8sClient .Get (ctx , types.NamespacedName {
265+ Name : testobjects .StorageName ,
266+ Namespace : testobjects .YdbNamespace ,
267+ }, & foundStorage ))
268+ foundStorage .Spec .Secrets = []* corev1.LocalObjectReference {
269+ {
270+ Name : v1alpha1 .AuthTokenSecretName ,
271+ },
272+ }
273+ return k8sClient .Update (ctx , & foundStorage )
274+ }, test .Timeout , test .Interval ).ShouldNot (HaveOccurred ())
275+
276+ checkAuthTokenArgs := func () error {
277+ statefulSet , err := getStatefulSet (testobjects .StorageName )
278+ if err != nil {
279+ return err
280+ }
281+ podContainerArgs := statefulSet .Spec .Template .Spec .Containers [0 ].Args
282+ var argExist bool
283+ var currentArgValue string
284+ authTokenFileArgValue := fmt .Sprintf ("%s/%s/%s" ,
285+ v1alpha1 .AdditionalSecretsDir ,
286+ v1alpha1 .AuthTokenSecretName ,
287+ v1alpha1 .AuthTokenSecretKey ,
288+ )
289+ for idx , arg := range podContainerArgs {
290+ if arg == v1alpha1 .AuthTokenFileArg {
291+ argExist = true
292+ currentArgValue = podContainerArgs [idx + 1 ]
293+ break
294+ }
295+ }
296+ if ! argExist {
297+ return fmt .Errorf ("arg `%s` did not found in StatefulSet podTemplate args: %v" , v1alpha1 .AuthTokenFileArg , podContainerArgs )
298+ }
299+ if authTokenFileArgValue != currentArgValue {
300+ return fmt .Errorf ("current arg `%s` value `%s` did not match with expected: %s" , v1alpha1 .AuthTokenFileArg , currentArgValue , authTokenFileArgValue )
301+ }
302+ return nil
303+ }
304+
305+ By ("check that --auth-token-file arg was added to Statefulset template..." )
306+ Eventually (checkAuthTokenArgs , test .Timeout , test .Interval ).ShouldNot (HaveOccurred ())
307+ })
230308 })
231309})
0 commit comments