|
| 1 | +// Copyright 2026 Google LLC |
| 2 | +// |
| 3 | +// Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +// you may not use this file except in compliance with the License. |
| 5 | +// You may obtain a copy of the License at |
| 6 | +// |
| 7 | +// http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +// |
| 9 | +// Unless required by applicable law or agreed to in writing, software |
| 10 | +// distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +// See the License for the specific language governing permissions and |
| 13 | +// limitations under the License. |
| 14 | + |
| 15 | +package e2e |
| 16 | + |
| 17 | +import ( |
| 18 | + "context" |
| 19 | + "sync" |
| 20 | + "testing" |
| 21 | + |
| 22 | + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" |
| 23 | +) |
| 24 | + |
| 25 | +var ( |
| 26 | + routerDataplaneOnce sync.Once |
| 27 | + routerIsAgentgateway bool |
| 28 | + routerDataplaneErr error |
| 29 | +) |
| 30 | + |
| 31 | +// RouterIsAgentgateway reports whether the atenet-router Deployment runs the |
| 32 | +// agentgateway dataplane. In that mode the pod has no Envoy and no |
| 33 | +// atenet-router ext_proc process, so router-internal surfaces — the statusz |
| 34 | +// page, atenet_router_* metrics, and Envoy's protocol mirroring to atunnel — |
| 35 | +// do not exist. Suites gate assertions on those surfaces with this instead of |
| 36 | +// a per-lane env knob: the deployed containers are the source of truth. |
| 37 | +func RouterIsAgentgateway(ctx context.Context, t *testing.T) bool { |
| 38 | + t.Helper() |
| 39 | + routerDataplaneOnce.Do(func() { |
| 40 | + deploy, err := GetClients().K8s.AppsV1().Deployments(routerNamespace).Get(ctx, routerService, metav1.GetOptions{}) |
| 41 | + if err != nil { |
| 42 | + routerDataplaneErr = err |
| 43 | + return |
| 44 | + } |
| 45 | + for _, c := range deploy.Spec.Template.Spec.Containers { |
| 46 | + if c.Name == "agentgateway" { |
| 47 | + routerIsAgentgateway = true |
| 48 | + return |
| 49 | + } |
| 50 | + } |
| 51 | + }) |
| 52 | + if routerDataplaneErr != nil { |
| 53 | + t.Fatalf("detecting the router dataplane: %v", routerDataplaneErr) |
| 54 | + } |
| 55 | + return routerIsAgentgateway |
| 56 | +} |
0 commit comments