@@ -4,13 +4,8 @@ import (
44 "context"
55 "fmt"
66 "os"
7- "strings"
8- "time"
97
108 . "github.com/onsi/gomega"
11- "google.golang.org/grpc"
12- "google.golang.org/grpc/connectivity"
13- "google.golang.org/grpc/credentials/insecure"
149
1510 "github.com/operator-framework/api/pkg/operators/v1alpha1"
1611 corev1 "k8s.io/api/core/v1"
@@ -154,48 +149,46 @@ func createTestRegistryService(ctx context.Context, cli client.Client, namespace
154149 TargetPort : intstr .FromInt (50051 ),
155150 },
156151 },
157- Type : corev1 .ServiceTypeNodePort ,
158152 Selector : map [string ]string {"catalogsource" : "prometheus-index" },
159153 },
160154 }
161155 err := c .Create (ctx , svc )
162156 Expect (err ).To (BeNil ())
163157
164- conn , err := grpc .Dial (getServiceAddress (ctx , cli , namespace , svc .Name ), []grpc.DialOption {grpc .WithTransportCredentials (insecure .NewCredentials ())}... )
165- Expect (err ).ToNot (HaveOccurred ())
166-
167- defer conn .Close ()
168- oldState := conn .GetState ()
169- Eventually (func (g Gomega ) {
170- state := conn .GetState ()
171- if state != connectivity .Ready {
172- if conn .WaitForStateChange (ctx , conn .GetState ()) {
173- state = conn .GetState ()
174- if oldState != state {
175- oldState = state
176- if state == connectivity .Idle {
177- conn .Connect ()
178- }
179- }
180- }
181- }
182- g .Expect (conn .GetState ()).To (Equal (connectivity .Ready ))
183- }).WithTimeout (2 * time .Minute ).Should (Succeed ())
158+ // svcAddress := getServiceAddress(ctx, cli, namespace, svc.Name)
159+
160+ // conn, err := grpc.Dial(svcAddress, grpc.WithInsecure())
161+ // Expect(err).ToNot(HaveOccurred())
162+
163+ // fmt.Println("svcAddress", svcAddress)
164+ // connectionContext, cancel := context.WithTimeout(context.Background(), 30*time.Second)
165+ // defer cancel()
166+
167+ // defer conn.Close()
168+ // oldState := conn.GetState()
169+ // Eventually(func(g Gomega) {
170+ // state := conn.GetState()
171+ // if state != connectivity.Ready {
172+ // if conn.WaitForStateChange(connectionContext, conn.GetState()) {
173+ // state = conn.GetState()
174+ // if oldState != state {
175+ // oldState = state
176+ // if state == connectivity.Idle {
177+ // conn.Connect()
178+ // }
179+ // }
180+ // }
181+ // }
182+ // g.Expect(conn.GetState()).To(Equal(connectivity.Ready))
183+ // }).WithTimeout(2 * time.Minute).Should(Succeed())
184184 return svc .Name
185185}
186186
187187func getServiceAddress (ctx context.Context , cli client.Client , namespace , name string ) string {
188188 svc := corev1.Service {}
189189 err := cli .Get (ctx , types.NamespacedName {Name : name , Namespace : namespace }, & svc )
190190 Expect (err ).To (BeNil ())
191- c := config .GetConfigOrDie ()
192- parts := strings .Split (c .Host , ":" )
193- address := parts [0 ]
194- if len (parts ) == 3 {
195- address = strings .TrimLeft (parts [1 ], "/" )
196- }
197- // TODO: not required on-cluster, fix Dockerfile and use fmt.Sprintf("%s.%s.svc:%d", svc.Name, svc.Namespace, svc.Spec.Ports[0].Port)
198- return fmt .Sprintf ("%s:%d" , address , svc .Spec .Ports [0 ].NodePort )
191+ return fmt .Sprintf ("%s.%s.svc:%d" , svc .Name , svc .Namespace , svc .Spec .Ports [0 ].Port )
199192}
200193
201194func applyCRDifNotPresent (ctx context.Context ) func () {
0 commit comments