@@ -640,6 +640,63 @@ func deleteExistingSubscription(t *testing.T, namespace, subName string) error {
640640
641641}
642642
643+ // assertInstallPlan checks if the InstallPlan with given ClusterServiceVersion exists and installed.
644+ func assertInstallPlan (t * testing.T , namespace , csvName string ) error {
645+ t .Helper ()
646+
647+ ips := & operatorsv1alpha1.InstallPlanList {}
648+ var ip * operatorsv1alpha1.InstallPlan
649+ ipHasCSV := func (ip operatorsv1alpha1.InstallPlan ) bool {
650+ for _ , c := range ip .Spec .ClusterServiceVersionNames {
651+ if c == csvName {
652+ return true
653+ }
654+ }
655+ return false
656+ }
657+
658+ err := wait .PollUntilContextTimeout (context .Background (), 2 * time .Second , 2 * time .Minute , false , func (context context.Context ) (bool , error ) {
659+ if err := kclient .List (context , ips ); err != nil {
660+ t .Logf ("Failed to list install plans: %v, retrying..." , err )
661+ return false , nil
662+ }
663+
664+ for i := range ips .Items {
665+ if ipHasCSV (ips .Items [i ]) {
666+ ip = & ips .Items [i ]
667+ break
668+ }
669+ }
670+
671+ if ip == nil {
672+ t .Logf ("Failed to find install plan for clusterserviceversion %q, retrying..." , csvName )
673+ return false , nil
674+ }
675+
676+ t .Logf ("Found install plan %q" , ip .Name )
677+ for _ , c := range ip .Status .Conditions {
678+ if c .Type == operatorsv1alpha1 .InstallPlanInstalled {
679+ if c .Status == corev1 .ConditionTrue {
680+ t .Logf ("Installed condition is false for install plan %q, retrying..." , ip .Name )
681+ return false , nil
682+ }
683+ break
684+ }
685+ }
686+ t .Logf ("Install plan %q successfully installed" , ip .Name )
687+ return true , nil
688+ })
689+ if err != nil {
690+ if ip != nil {
691+ t .Logf ("Last observed state of install plan %q:\n %s" , ip .Name , util .ToYaml (ip ))
692+ } else {
693+ t .Logf ("Last observed state of all install plans:\n %s" , util .ToYaml (ips ))
694+ }
695+ }
696+
697+ return err
698+ }
699+
643700// assertOSSMOperator checks if the OSSM operator gets successfully installed
644701// and returns an error if not. It uses configurable parameters such as the expected OSSM version, polling interval, and timeout.
645702func assertOSSMOperator (t * testing.T ) error {
0 commit comments