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