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


##########
test/e2e/scaffold/scaffold.go:
##########
@@ -313,6 +313,43 @@ 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,

Review Comment:
   Implemented



##########
internal/adc/translator/httproute.go:
##########
@@ -524,6 +525,133 @@ func calculateHTTPRoutePriority(match 
*gatewayv1.HTTPRouteMatch, ruleIndex int,
        return priority
 }
 
+// translateBackendsToUpstreams processes the BackendRefs of an HTTPRouteRule,
+// builds upstreams, assigns them to the service (single upstream or 
traffic-split
+// plugin for multiple), and injects fault-injection on backend errors.
+func (t *Translator) translateBackendsToUpstreams(
+       tctx *provider.TranslateContext,
+       rule gatewayv1.HTTPRouteRule,
+       httpRoute *gatewayv1.HTTPRoute,
+       service *adctypes.Service,
+) (enableWebsocket *bool, backendErr error) {
+       upstreams := make([]*adctypes.Upstream, 0)
+       weightedUpstreams := 
make([]adctypes.TrafficSplitConfigRuleWeightedUpstream, 0)
+
+       for _, backend := range rule.BackendRefs {
+               if backend.Namespace == nil {
+                       namespace := gatewayv1.Namespace(httpRoute.Namespace)
+                       backend.Namespace = &namespace
+               }
+               upstream := adctypes.NewDefaultUpstream()
+               upNodes, protocol, err := t.translateBackendRef(tctx, 
backend.BackendRef, DefaultEndpointFilter)
+               if err != nil {
+                       backendErr = err
+                       continue
+               }
+               if len(upNodes) == 0 {
+                       continue
+               }
+               if protocol == internaltypes.AppProtocolWS || protocol == 
internaltypes.AppProtocolWSS {
+                       enableWebsocket = ptr.To(true)
+               }
+
+               t.AttachBackendTrafficPolicyToUpstream(backend.BackendRef, 
tctx.BackendTrafficPolicies, upstream)
+               upstream.Nodes = upNodes
+               upstream.Scheme = appProtocolToUpstreamScheme(protocol)

Review Comment:
   Implemented



-- 
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