@@ -1313,14 +1313,18 @@ var _ = Describe("Subscription", func() {
1313
1313
require .NoError (GinkgoT (), err )
1314
1314
require .NotNil (GinkgoT (), subscription )
1315
1315
1316
- csv , err := fetchCSV (crClient , subscription .Status .CurrentCSV , generatedNamespace .GetName (), buildCSVConditionChecker (operatorsv1alpha1 .CSVPhaseSucceeded ))
1317
- require .NoError (GinkgoT (), err )
1318
-
1319
1316
proxyEnv := proxyEnvVarFunc (GinkgoT (), config )
1320
1317
expected := podEnv
1321
1318
expected = append (expected , proxyEnv ... )
1322
1319
1323
- checkDeploymentWithPodConfiguration (GinkgoT (), kubeClient , csv , podConfig .Env , podConfig .Volumes , podConfig .VolumeMounts , podConfig .Tolerations , podConfig .Resources )
1320
+ Eventually (func () error {
1321
+ csv , err := fetchCSV (crClient , subscription .Status .CurrentCSV , generatedNamespace .GetName (), buildCSVConditionChecker (operatorsv1alpha1 .CSVPhaseSucceeded ))
1322
+ if err != nil {
1323
+ return err
1324
+ }
1325
+
1326
+ return checkDeploymentWithPodConfiguration (kubeClient , csv , podConfig .Env , podConfig .Volumes , podConfig .VolumeMounts , podConfig .Tolerations , podConfig .Resources )
1327
+ }).Should (Succeed ())
1324
1328
})
1325
1329
1326
1330
It ("creation with nodeSelector config" , func () {
@@ -2743,14 +2747,14 @@ func checkDeploymentHasPodConfigNodeSelector(t GinkgoTInterface, client operator
2743
2747
return nil
2744
2748
}
2745
2749
2746
- func checkDeploymentWithPodConfiguration (t GinkgoTInterface , client operatorclient.ClientInterface , csv * operatorsv1alpha1.ClusterServiceVersion , envVar []corev1.EnvVar , volumes []corev1.Volume , volumeMounts []corev1.VolumeMount , tolerations []corev1.Toleration , resources * corev1.ResourceRequirements ) {
2750
+ func checkDeploymentWithPodConfiguration (client operatorclient.ClientInterface , csv * operatorsv1alpha1.ClusterServiceVersion , envVar []corev1.EnvVar , volumes []corev1.Volume , volumeMounts []corev1.VolumeMount , tolerations []corev1.Toleration , resources * corev1.ResourceRequirements ) error {
2747
2751
resolver := install.StrategyResolver {}
2748
2752
2749
2753
strategy , err := resolver .UnmarshalStrategy (csv .Spec .InstallStrategy )
2750
- require . NoError ( t , err )
2754
+ Expect ( err ). NotTo ( HaveOccurred () )
2751
2755
2752
2756
strategyDetailsDeployment , ok := strategy .(* operatorsv1alpha1.StrategyDetailsDeployment )
2753
- require . Truef ( t , ok , "could not cast install strategy as type %T" , strategyDetailsDeployment )
2757
+ Expect ( ok ). To ( BeTrue () , "could not cast install strategy as type %T" , strategyDetailsDeployment )
2754
2758
2755
2759
findEnvVar := func (envVar []corev1.EnvVar , name string ) (foundEnvVar * corev1.EnvVar , found bool ) {
2756
2760
for i := range envVar {
@@ -2813,48 +2817,58 @@ func checkDeploymentWithPodConfiguration(t GinkgoTInterface, client operatorclie
2813
2817
return
2814
2818
}
2815
2819
2816
- check := func (container * corev1.Container ) {
2820
+ check := func (container * corev1.Container ) error {
2817
2821
for _ , e := range envVar {
2818
2822
existing , found := findEnvVar (container .Env , e .Name )
2819
- require .Truef (t , found , "env variable name=%s not injected" , e .Name )
2820
- require .NotNil (t , existing )
2821
- require .Equalf (t , e .Value , existing .Value , "env variable value does not match %s=%s" , e .Name , e .Value )
2823
+ if ! found || existing == nil {
2824
+ return fmt .Errorf ("env variable name=%s not injected" , e .Name )
2825
+ }
2826
+ Expect (e .Value ).Should (Equal (existing .Value ), "env variable value does not match %s=%s" , e .Name , e .Value )
2822
2827
}
2823
2828
2824
2829
for _ , v := range volumeMounts {
2825
2830
existing , found := findVolumeMount (container .VolumeMounts , v .Name )
2826
- require .Truef (t , found , "VolumeMount name=%s not injected" , v .Name )
2827
- require .NotNil (t , existing )
2828
- require .Equalf (t , v .MountPath , existing .MountPath , "VolumeMount MountPath does not match %s=%s" , v .Name , v .MountPath )
2831
+ if ! found || existing == nil {
2832
+ return fmt .Errorf ("VolumeMount name=%s not injected" , v .Name )
2833
+ }
2834
+ Expect (v .MountPath ).Should (Equal (existing .MountPath ), "VolumeMount MountPath does not match %s=%s" , v .Name , v .MountPath )
2829
2835
}
2830
2836
2831
2837
existing , found := findResources (& container .Resources , resources )
2832
- require .Truef (t , found , "Resources not injected. Resource=%v" , resources )
2833
- require .NotNil (t , existing )
2834
- require .Equalf (t , existing , resources , "Resource=%v does not match expected Resource=%v" , existing , resources )
2838
+ if ! found || existing == nil {
2839
+ return fmt .Errorf ("Resources not injected. Resource=%v" , resources )
2840
+ }
2841
+ Expect (existing ).Should (Equal (resources ), "Resource=%v does not match expected Resource=%v" , existing , resources )
2842
+ return nil
2835
2843
}
2836
2844
2837
2845
for _ , deploymentSpec := range strategyDetailsDeployment .DeploymentSpecs {
2838
2846
deployment , err := client .KubernetesInterface ().AppsV1 ().Deployments (csv .GetNamespace ()).Get (context .Background (), deploymentSpec .Name , metav1.GetOptions {})
2839
- require . NoError ( t , err )
2847
+ Expect ( err ). NotTo ( HaveOccurred () )
2840
2848
for _ , v := range volumes {
2841
2849
existing , found := findVolume (deployment .Spec .Template .Spec .Volumes , v .Name )
2842
- require .Truef (t , found , "Volume name=%s not injected" , v .Name )
2843
- require .NotNil (t , existing )
2844
- require .Equalf (t , v .ConfigMap .LocalObjectReference .Name , existing .ConfigMap .LocalObjectReference .Name , "volume ConfigMap Names does not match %s=%s" , v .Name , v .ConfigMap .LocalObjectReference .Name )
2850
+ if ! found || existing == nil {
2851
+ return fmt .Errorf ("Volume name=%s not injected" , v .Name )
2852
+ }
2853
+ Expect (v .ConfigMap .LocalObjectReference .Name ).Should (Equal (existing .ConfigMap .LocalObjectReference .Name ), "volume ConfigMap Names does not match %s=%s" , v .Name , v .ConfigMap .LocalObjectReference .Name )
2845
2854
}
2846
2855
2847
2856
for _ , toleration := range tolerations {
2848
2857
existing , found := findTolerations (deployment .Spec .Template .Spec .Tolerations , toleration )
2849
- require .Truef (t , found , "Toleration not injected. Toleration=%v" , toleration )
2850
- require .NotNil (t , existing )
2851
- require .Equalf (t , * existing , toleration , "Toleration=%v does not match expected Toleration=%v" , existing , toleration )
2858
+ if ! found || existing == nil {
2859
+ return fmt .Errorf ("Toleration not injected. Toleration=%v" , toleration )
2860
+ }
2861
+ Expect (* existing ).Should (Equal (toleration ), "Toleration=%v does not match expected Toleration=%v" , existing , toleration )
2852
2862
}
2853
2863
2854
2864
for i := range deployment .Spec .Template .Spec .Containers {
2855
- check (& deployment .Spec .Template .Spec .Containers [i ])
2865
+ err = check (& deployment .Spec .Template .Spec .Containers [i ])
2866
+ if err != nil {
2867
+ return err
2868
+ }
2856
2869
}
2857
2870
}
2871
+ return nil
2858
2872
}
2859
2873
2860
2874
func updateInternalCatalog (t GinkgoTInterface , c operatorclient.ClientInterface , crc versioned.Interface , catalogSourceName , namespace string , crds []apiextensions.CustomResourceDefinition , csvs []operatorsv1alpha1.ClusterServiceVersion , packages []registry.PackageManifest ) {
0 commit comments