@@ -17,6 +17,7 @@ import (
1717
1818 sailv1 "github.com/istio-ecosystem/sail-operator/api/v1"
1919 v1 "github.com/openshift/api/operatoringress/v1"
20+ "github.com/openshift/cluster-ingress-operator/pkg/operator/controller"
2021 operatorcontroller "github.com/openshift/cluster-ingress-operator/pkg/operator/controller"
2122 util "github.com/openshift/cluster-ingress-operator/pkg/util"
2223 operatorsv1alpha1 "github.com/operator-framework/api/pkg/operators/v1alpha1"
@@ -461,20 +462,30 @@ func assertOSSMOperator(t *testing.T) error {
461462 return true , nil
462463 })
463464 if err != nil {
464- return fmt .Errorf ("error finding deployment %v: %v " , ns , err )
465+ return fmt .Errorf ("error finding deployment %v: %w " , ns , err )
465466 }
466467
468+ pod := corev1.Pod {}
467469 // Get the istio-operator pod.
468- podlist , err := getPods (t , kclient , dep )
470+ err = wait .PollUntilContextTimeout (context .Background (), 1 * time .Second , 30 * time .Second , false , func (context context.Context ) (bool , error ) {
471+ podlist , err := getPods (t , kclient , dep )
472+ if err != nil {
473+ t .Logf ("error finding pod for deployment %v: %v, retrying..." , ns , err )
474+ return false , nil
475+ }
476+ if len (podlist .Items ) > 1 {
477+ t .Logf ("too many pods for deployment %v: %d, retrying..." , ns , len (podlist .Items ))
478+ return false , nil
479+ }
480+ pod = podlist .Items [0 ]
481+ if pod .Status .Phase != corev1 .PodRunning {
482+ t .Logf ("OSSM operator failure: pod %s is not running, it is %v, retrying..." , pod .Name , pod .Status .Phase )
483+ return false , nil
484+ }
485+ return true , nil
486+ })
469487 if err != nil {
470- return fmt .Errorf ("error finding pod for deployment %v: %v" , ns , err )
471- }
472- if len (podlist .Items ) > 1 {
473- return fmt .Errorf ("too many pods for deployment %v: %d" , ns , len (podlist .Items ))
474- }
475- pod := podlist .Items [0 ]
476- if pod .Status .Phase != corev1 .PodRunning {
477- return fmt .Errorf ("OSSM operator failure: pod %s is not running, it is %v" , pod .Name , pod .Status .Phase )
488+ return fmt .Errorf ("error finding OSSM operator pod %v: %w" , ns , err )
478489 }
479490
480491 t .Logf ("found OSSM operator pod %s/%s to be %s" , pod .Namespace , pod .Name , pod .Status .Phase )
@@ -771,6 +782,50 @@ func assertCatalogSource(t *testing.T, namespace, csName string) error {
771782 return err
772783}
773784
785+ func assertClusterServiceVersionSucceeded (t * testing.T ) error {
786+ t .Helper ()
787+ expectedVersion , err := expectedOSSMVersion (t )
788+ if err != nil {
789+ return fmt .Errorf ("Could not determine expected OSSM version: %w" , err )
790+ }
791+ err = wait .PollUntilContextTimeout (context .Background (), 5 * time .Second , 2 * time .Minute , false , func (context context.Context ) (bool , error ) {
792+ t .Log ("getting cluster service version..." )
793+ csv := & operatorsv1alpha1.ClusterServiceVersion {}
794+ if err := kclient .Get (context , types.NamespacedName {Namespace : controller .OpenshiftOperatorNamespace , Name : expectedVersion }, csv ); err != nil {
795+ t .Logf ("failed to get cluster service version %s/%s: %v" , controller .OpenshiftOperatorNamespace , expectedVersion , err )
796+ if kerrors .IsNotFound (err ) {
797+ return false , nil
798+ }
799+ return false , err
800+ }
801+ if csv .Status .Phase != operatorsv1alpha1 .CSVPhaseSucceeded {
802+ t .Logf ("found cluster service version %s, but phase is %s, expected Succeeded" , csv .Name , csv .Status .Phase )
803+ return false , nil
804+ }
805+ t .Logf ("found cluster service version %s, and phase is Succeeded" , csv .Name )
806+ return true , nil
807+ })
808+ return err
809+ }
810+
811+ func expectedOSSMVersion (t * testing.T ) (string , error ) {
812+ t .Helper ()
813+ deployment , err := getDeployment (t , kclient , types.NamespacedName {Namespace : controller .DefaultOperatorNamespace , Name : "ingress-operator" }, timeout )
814+ if err != nil {
815+ return "" , err
816+ }
817+ for _ , container := range deployment .Spec .Template .Spec .Containers {
818+ if container .Name == "ingress-operator" {
819+ for _ , envvar := range container .Env {
820+ if envvar .Name == "GATEWAY_API_OPERATOR_VERSION" {
821+ return envvar .Value , nil
822+ }
823+ }
824+ }
825+ }
826+ return "servicemeshoperator3.v3.0.0" , nil
827+ }
828+
774829// assertIstio checks if the Istio exists in a ready state,
775830// and returns an error if not.
776831func assertIstio (t * testing.T ) error {
@@ -846,7 +901,7 @@ func assertDNSRecord(t *testing.T, recordName types.NamespacedName) error {
846901 t .Helper ()
847902 dnsRecord := & v1.DNSRecord {}
848903
849- err := wait .PollUntilContextTimeout (context .Background (), 1 * time .Second , 1 * time .Minute , false , func (context context.Context ) (bool , error ) {
904+ err := wait .PollUntilContextTimeout (context .Background (), 5 * time .Second , 2 * time .Minute , false , func (context context.Context ) (bool , error ) {
850905 if err := kclient .Get (context , recordName , dnsRecord ); err != nil {
851906 t .Logf ("Failed to get DNSRecord %v: %v; retrying..." , recordName , err )
852907 return false , nil
0 commit comments