@@ -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,16 @@ 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
+ require .NoError (GinkgoT (), err )
1324
+
1325
+ return checkDeploymentWithPodConfiguration (GinkgoT (), kubeClient , csv , podConfig .Env , podConfig .Volumes , podConfig .VolumeMounts , podConfig .Tolerations , podConfig .Resources )
1326
+ }).Should (Succeed ())
1324
1327
})
1325
1328
1326
1329
It ("creation with nodeSelector config" , func () {
@@ -2743,7 +2746,7 @@ func checkDeploymentHasPodConfigNodeSelector(t GinkgoTInterface, client operator
2743
2746
return nil
2744
2747
}
2745
2748
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 ) {
2749
+ 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 ) error {
2747
2750
resolver := install.StrategyResolver {}
2748
2751
2749
2752
strategy , err := resolver .UnmarshalStrategy (csv .Spec .InstallStrategy )
@@ -2813,48 +2816,58 @@ func checkDeploymentWithPodConfiguration(t GinkgoTInterface, client operatorclie
2813
2816
return
2814
2817
}
2815
2818
2816
- check := func (container * corev1.Container ) {
2819
+ check := func (container * corev1.Container ) error {
2817
2820
for _ , e := range envVar {
2818
2821
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 )
2822
+ if ! found || existing == nil {
2823
+ return errors .New (fmt .Sprintf ("env variable name=%s not injected" , e .Name ))
2824
+ }
2821
2825
require .Equalf (t , e .Value , existing .Value , "env variable value does not match %s=%s" , e .Name , e .Value )
2822
2826
}
2823
2827
2824
2828
for _ , v := range volumeMounts {
2825
2829
existing , found := findVolumeMount (container .VolumeMounts , v .Name )
2826
- require .Truef (t , found , "VolumeMount name=%s not injected" , v .Name )
2827
- require .NotNil (t , existing )
2830
+ if ! found || existing == nil {
2831
+ return errors .New (fmt .Sprintf ("VolumeMount name=%s not injected" , v .Name ))
2832
+ }
2828
2833
require .Equalf (t , v .MountPath , existing .MountPath , "VolumeMount MountPath does not match %s=%s" , v .Name , v .MountPath )
2829
2834
}
2830
2835
2831
2836
existing , found := findResources (& container .Resources , resources )
2832
- require .Truef (t , found , "Resources not injected. Resource=%v" , resources )
2833
- require .NotNil (t , existing )
2837
+ if ! found || existing == nil {
2838
+ return errors .New (fmt .Sprintf ("Resources not injected. Resource=%v" , resources ))
2839
+ }
2834
2840
require .Equalf (t , existing , resources , "Resource=%v does not match expected Resource=%v" , existing , resources )
2841
+ return nil
2835
2842
}
2836
2843
2837
2844
for _ , deploymentSpec := range strategyDetailsDeployment .DeploymentSpecs {
2838
2845
deployment , err := client .KubernetesInterface ().AppsV1 ().Deployments (csv .GetNamespace ()).Get (context .Background (), deploymentSpec .Name , metav1.GetOptions {})
2839
2846
require .NoError (t , err )
2840
2847
for _ , v := range volumes {
2841
2848
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 )
2849
+ if ! found || existing == nil {
2850
+ return errors .New (fmt .Sprintf ("Volume name=%s not injected" , v .Name ))
2851
+ }
2844
2852
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 )
2845
2853
}
2846
2854
2847
2855
for _ , toleration := range tolerations {
2848
2856
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 )
2857
+ if ! found || existing == nil {
2858
+ return errors .New (fmt .Sprintf ("Toleration not injected. Toleration=%v" , toleration ))
2859
+ }
2851
2860
require .Equalf (t , * existing , toleration , "Toleration=%v does not match expected Toleration=%v" , existing , toleration )
2852
2861
}
2853
2862
2854
2863
for i := range deployment .Spec .Template .Spec .Containers {
2855
- check (& deployment .Spec .Template .Spec .Containers [i ])
2864
+ err = check (& deployment .Spec .Template .Spec .Containers [i ])
2865
+ if err != nil {
2866
+ return err
2867
+ }
2856
2868
}
2857
2869
}
2870
+ return nil
2858
2871
}
2859
2872
2860
2873
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