johannes-engler-mw commented on code in PR #2703:
URL: 
https://github.com/apache/apisix-ingress-controller/pull/2703#discussion_r2919722018


##########
test/e2e/scaffold/scaffold.go:
##########
@@ -313,6 +313,46 @@ func (s *Scaffold) NewAPISIXClientWithTLSProxy(host 
string) *httpexpect.Expect {
        })
 }
 
+// NewAPISIXClientForPort creates an HTTP client for a specific APISIX port.
+// Uses existing tunnels if available, otherwise creates a new one.
+func (s *Scaffold) NewAPISIXClientForPort(port int) (*httpexpect.Expect, 
error) {
+       // Check if we can reuse existing tunnels
+       switch port {
+       case 80:
+               return s.NewAPISIXClient(), nil
+       case 443:
+               return s.NewAPISIXHttpsClient(""), nil
+       case 9100:
+               return s.NewAPISIXClientOnTCPPort(), nil
+       }
+
+       // Create new tunnel for custom port
+       serviceName := s.dataplaneService.Name
+       tunnel := k8s.NewTunnel(s.kubectlOptions, k8s.ResourceTypeService, 
serviceName, 0, port)
+       if err := tunnel.ForwardPortE(s.t); err != nil {
+               return nil, fmt.Errorf("failed to create tunnel for port %d: 
%w", port, err)
+       }
+       s.addFinalizers(tunnel.Close)
+
+       u := url.URL{
+               Scheme: "http",
+               Host:   tunnel.Endpoint(),
+       }
+       return httpexpect.WithConfig(httpexpect.Config{
+               BaseURL: u.String(),
+               Client: &http.Client{
+                       Transport: &http.Transport{TLSClientConfig: 
&tls.Config{InsecureSkipVerify: true}},
+                       Timeout:   3 * time.Second,
+                       CheckRedirect: func(req *http.Request, via 
[]*http.Request) error {
+                               return http.ErrUseLastResponse
+                       },
+               },
+               Reporter: httpexpect.NewAssertReporter(
+                       httpexpect.NewAssertReporter(GinkgoT()),
+               ),

Review Comment:
     > I verified this one locally and it is not a compile issue in this branch.
     > httpexpect.NewAssertReporter takes an assert.TestingT, and 
*httpexpect.AssertReporter satisfies that interface via Errorf, so the nested 
call is type-valid. This same pattern is already used in multiple existing 
scaffold
     > helpers, so NewAPISIXClientForPort is consistent with the surrounding 
test scaffolding rather than introducing a new regression.
     > I’m leaving it unchanged in this PR to avoid unrelated churn; if we want 
to simplify that reporter wiring, it should be done consistently across the 
scaffold in a separate cleanup.
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to