@@ -134,37 +134,25 @@ var _ = Describe("Test AutoScalingListener controller", func() {
134134 autoscalingListenerTestTimeout ,
135135 autoscalingListenerTestInterval ).Should (BeEquivalentTo (autoscalingListenerFinalizerName ), "AutoScalingListener should have a finalizer" )
136136
137- // Check if secret is created
138- mirrorSecret := new (corev1.Secret )
139- Eventually (
140- func () (string , error ) {
141- err := k8sClient .Get (ctx , client.ObjectKey {Name : scaleSetListenerSecretMirrorName (autoscalingListener ), Namespace : autoscalingListener .Namespace }, mirrorSecret )
142- if err != nil {
143- return "" , err
144- }
145- return string (mirrorSecret .Data ["github_token" ]), nil
146- },
147- autoscalingListenerTestTimeout ,
148- autoscalingListenerTestInterval ).Should (BeEquivalentTo (autoscalingListenerTestGitHubToken ), "Mirror secret should be created" )
149-
150137 // Check if service account is created
151138 serviceAccount := new (corev1.ServiceAccount )
152139 Eventually (
153140 func () (string , error ) {
154- err := k8sClient .Get (ctx , client.ObjectKey {Name : scaleSetListenerServiceAccountName ( autoscalingListener ) , Namespace : autoscalingListener .Namespace }, serviceAccount )
141+ err := k8sClient .Get (ctx , client.ObjectKey {Name : autoscalingListener . Name , Namespace : autoscalingListener .Namespace }, serviceAccount )
155142 if err != nil {
156143 return "" , err
157144 }
158145 return serviceAccount .Name , nil
159146 },
160147 autoscalingListenerTestTimeout ,
161- autoscalingListenerTestInterval ).Should (BeEquivalentTo (scaleSetListenerServiceAccountName (autoscalingListener )), "Service account should be created" )
148+ autoscalingListenerTestInterval ,
149+ ).Should (BeEquivalentTo (autoscalingListener .Name ), "Service account should be created" )
162150
163151 // Check if role is created
164152 role := new (rbacv1.Role )
165153 Eventually (
166154 func () ([]rbacv1.PolicyRule , error ) {
167- err := k8sClient .Get (ctx , client.ObjectKey {Name : scaleSetListenerRoleName ( autoscalingListener ) , Namespace : autoscalingListener .Spec .AutoscalingRunnerSetNamespace }, role )
155+ err := k8sClient .Get (ctx , client.ObjectKey {Name : autoscalingListener . Name , Namespace : autoscalingListener .Spec .AutoscalingRunnerSetNamespace }, role )
168156 if err != nil {
169157 return nil , err
170158 }
@@ -178,15 +166,15 @@ var _ = Describe("Test AutoScalingListener controller", func() {
178166 roleBinding := new (rbacv1.RoleBinding )
179167 Eventually (
180168 func () (string , error ) {
181- err := k8sClient .Get (ctx , client.ObjectKey {Name : scaleSetListenerRoleName ( autoscalingListener ) , Namespace : autoscalingListener .Spec .AutoscalingRunnerSetNamespace }, roleBinding )
169+ err := k8sClient .Get (ctx , client.ObjectKey {Name : autoscalingListener . Name , Namespace : autoscalingListener .Spec .AutoscalingRunnerSetNamespace }, roleBinding )
182170 if err != nil {
183171 return "" , err
184172 }
185173
186174 return roleBinding .RoleRef .Name , nil
187175 },
188176 autoscalingListenerTestTimeout ,
189- autoscalingListenerTestInterval ).Should (BeEquivalentTo (scaleSetListenerRoleName ( autoscalingListener ) ), "Rolebinding should be created" )
177+ autoscalingListenerTestInterval ).Should (BeEquivalentTo (autoscalingListener . Name ), "Rolebinding should be created" )
190178
191179 // Check if pod is created
192180 pod := new (corev1.Pod )
@@ -248,7 +236,7 @@ var _ = Describe("Test AutoScalingListener controller", func() {
248236 Eventually (
249237 func () bool {
250238 roleBinding := new (rbacv1.RoleBinding )
251- err := k8sClient .Get (ctx , client.ObjectKey {Name : scaleSetListenerRoleName ( autoscalingListener ) , Namespace : autoscalingListener .Spec .AutoscalingRunnerSetNamespace }, roleBinding )
239+ err := k8sClient .Get (ctx , client.ObjectKey {Name : autoscalingListener . Name , Namespace : autoscalingListener .Spec .AutoscalingRunnerSetNamespace }, roleBinding )
252240 return kerrors .IsNotFound (err )
253241 },
254242 autoscalingListenerTestTimeout ,
@@ -259,7 +247,7 @@ var _ = Describe("Test AutoScalingListener controller", func() {
259247 Eventually (
260248 func () bool {
261249 role := new (rbacv1.Role )
262- err := k8sClient .Get (ctx , client.ObjectKey {Name : scaleSetListenerRoleName ( autoscalingListener ) , Namespace : autoscalingListener .Spec .AutoscalingRunnerSetNamespace }, role )
250+ err := k8sClient .Get (ctx , client.ObjectKey {Name : autoscalingListener . Name , Namespace : autoscalingListener .Spec .AutoscalingRunnerSetNamespace }, role )
263251 return kerrors .IsNotFound (err )
264252 },
265253 autoscalingListenerTestTimeout ,
@@ -340,7 +328,7 @@ var _ = Describe("Test AutoScalingListener controller", func() {
340328 role := new (rbacv1.Role )
341329 Eventually (
342330 func () ([]rbacv1.PolicyRule , error ) {
343- err := k8sClient .Get (ctx , client.ObjectKey {Name : scaleSetListenerRoleName ( autoscalingListener ) , Namespace : autoscalingListener .Spec .AutoscalingRunnerSetNamespace }, role )
331+ err := k8sClient .Get (ctx , client.ObjectKey {Name : autoscalingListener . Name , Namespace : autoscalingListener .Spec .AutoscalingRunnerSetNamespace }, role )
344332 if err != nil {
345333 return nil , err
346334 }
@@ -397,75 +385,6 @@ var _ = Describe("Test AutoScalingListener controller", func() {
397385 autoscalingListenerTestInterval ,
398386 ).ShouldNot (BeEquivalentTo (oldPodUID ), "Pod should be re-created" )
399387 })
400-
401- It ("It should update mirror secrets to match secret used by AutoScalingRunnerSet" , func () {
402- // Waiting for the pod is created
403- pod := new (corev1.Pod )
404- Eventually (
405- func () (string , error ) {
406- err := k8sClient .Get (ctx , client.ObjectKey {Name : autoscalingListener .Name , Namespace : autoscalingListener .Namespace }, pod )
407- if err != nil {
408- return "" , err
409- }
410-
411- return pod .Name , nil
412- },
413- autoscalingListenerTestTimeout ,
414- autoscalingListenerTestInterval ).Should (BeEquivalentTo (autoscalingListener .Name ), "Pod should be created" )
415-
416- // Update the secret
417- updatedSecret := configSecret .DeepCopy ()
418- updatedSecret .Data ["github_token" ] = []byte (autoscalingListenerTestGitHubToken + "_updated" )
419- err := k8sClient .Update (ctx , updatedSecret )
420- Expect (err ).NotTo (HaveOccurred (), "failed to update test secret" )
421-
422- updatedPod := pod .DeepCopy ()
423- // Ignore status running and consult the container state
424- updatedPod .Status .Phase = corev1 .PodRunning
425- updatedPod .Status .ContainerStatuses = []corev1.ContainerStatus {
426- {
427- Name : autoscalingListenerContainerName ,
428- State : corev1.ContainerState {
429- Terminated : & corev1.ContainerStateTerminated {
430- ExitCode : 1 ,
431- },
432- },
433- },
434- }
435- err = k8sClient .Status ().Update (ctx , updatedPod )
436- Expect (err ).NotTo (HaveOccurred (), "failed to update test pod to failed" )
437-
438- // Check if mirror secret is updated with right data
439- mirrorSecret := new (corev1.Secret )
440- Eventually (
441- func () (map [string ][]byte , error ) {
442- err := k8sClient .Get (ctx , client.ObjectKey {Name : scaleSetListenerSecretMirrorName (autoscalingListener ), Namespace : autoscalingListener .Namespace }, mirrorSecret )
443- if err != nil {
444- return nil , err
445- }
446-
447- return mirrorSecret .Data , nil
448- },
449- autoscalingListenerTestTimeout ,
450- autoscalingListenerTestInterval ).Should (BeEquivalentTo (updatedSecret .Data ), "Mirror secret should be updated" )
451-
452- // Check if we re-created a new pod
453- Eventually (
454- func () error {
455- latestPod := new (corev1.Pod )
456- err := k8sClient .Get (ctx , client.ObjectKey {Name : autoscalingListener .Name , Namespace : autoscalingListener .Namespace }, latestPod )
457- if err != nil {
458- return err
459- }
460- if latestPod .UID == pod .UID {
461- return fmt .Errorf ("Pod should be recreated" )
462- }
463-
464- return nil
465- },
466- autoscalingListenerTestTimeout ,
467- autoscalingListenerTestInterval ).Should (Succeed (), "Pod should be recreated" )
468- })
469388 })
470389})
471390
0 commit comments