Skip to content

Commit 9b633be

Browse files
test: use aigw also for llm in goose e2e (#1354)
**Description** Before, our goose test only went through aigw for MCP instead of proving single agent origin works, by also using it for LLM. Now.. we're good. Signed-off-by: Adrian Cole <[email protected]>
1 parent fc5ca63 commit 9b633be

File tree

5 files changed

+35
-15
lines changed

5 files changed

+35
-15
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
module github.com/envoyproxy/ai-gateway
22

33
// Explicitly specify the Go patch version to be able to purge the CI cache correctly.
4-
go 1.25.1
4+
go 1.25.2
55

66
require (
77
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.19.1

tests/e2e-aigw/aigw_test.go

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -57,21 +57,19 @@ func buildAigwOnDemand() (string, error) {
5757
}
5858

5959
// startAIGWCLI starts the aigw CLI as a subprocess with the given config file.
60-
func startAIGWCLI(t *testing.T, aigwBin string, arg ...string) {
61-
// aigw has many fixed ports, some are in the envoy subprocess, such as
62-
// Envoy's gateway port, and its adminPort if in yaml configuration.
60+
func startAIGWCLI(t *testing.T, aigwBin string, env []string, arg ...string) {
61+
// aigw has many fixed ports: some are in the envoy subprocess
6362
gatewayPort := 1975
64-
envoyAdminPort := 9901
6563

6664
// Wait up to 10 seconds for both ports to be free.
6765
ctx, cancel := context.WithTimeout(t.Context(), 10*time.Second)
6866
defer cancel()
6967

70-
for isPortInUse(ctx, gatewayPort) || isPortInUse(ctx, envoyAdminPort) {
68+
for isPortInUse(ctx, gatewayPort) {
7169
select {
7270
case <-ctx.Done():
7371
require.FailNow(t, "Ports still in use after timeout",
74-
"Ports %d and/or %d are still in use", gatewayPort, envoyAdminPort)
72+
"Port %d is still in use", gatewayPort)
7573
case <-time.After(500 * time.Millisecond):
7674
// Retry after a short delay.
7775
}
@@ -92,6 +90,7 @@ func startAIGWCLI(t *testing.T, aigwBin string, arg ...string) {
9290
cmd := exec.CommandContext(cmdCtx, aigwBin, arg...)
9391
cmd.Stdout = buffers[0]
9492
cmd.Stderr = buffers[1]
93+
cmd.Env = append(os.Environ(), env...)
9594
cmd.WaitDelay = 3 * time.Second // auto-kill after 3 seconds.
9695

9796
require.NoError(t, cmd.Start())
@@ -120,10 +119,10 @@ func startAIGWCLI(t *testing.T, aigwBin string, arg ...string) {
120119
t.Logf("aigw process started with PID %d", cmd.Process.Pid)
121120

122121
// Wait for health check using RequireEventuallyNoError.
123-
t.Log("Waiting for aigw to start (Envoy admin endpoint)...")
124-
envoyAdmin, err := aigw.NewEnvoyAdminClient(t.Context(), 1, envoyAdminPort)
122+
envoyAdmin, err := aigw.NewEnvoyAdminClient(t.Context(), cmd.Process.Pid, 0)
125123
require.NoError(t, err)
126124

125+
t.Logf("Waiting for aigw to start (admin port %d)...", envoyAdmin.Port())
127126
internaltesting.RequireEventuallyNoError(t, func() error {
128127
return envoyAdmin.IsReady(t.Context())
129128
}, 180*time.Second, 2*time.Second,

tests/e2e-aigw/examples_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ func TestMCP_standalone(t *testing.T) {
8282
}
8383

8484
exampleYaml := path.Join(examplesDir, "mcp_example.yaml")
85-
startAIGWCLI(t, aigwBin, "run", "--debug", exampleYaml)
85+
startAIGWCLI(t, aigwBin, nil, "run", "--debug", exampleYaml)
8686

8787
url := fmt.Sprintf("http://localhost:%d/mcp", 1975)
8888
mcpClient := mcp.NewClient(&mcp.Implementation{Name: "public-mcp-client", Version: "0.1.0"}, &mcp.ClientOptions{})
@@ -187,7 +187,7 @@ func (t *authTransport) RoundTrip(req *http.Request) (*http.Response, error) {
187187
}
188188

189189
func TestMCP_standalone_oauth(t *testing.T) {
190-
startAIGWCLI(t, aigwBin, "run", "--debug", path.Join(examplesDir, "mcp_oauth_example.yaml"))
190+
startAIGWCLI(t, aigwBin, nil, "run", "--debug", path.Join(examplesDir, "mcp_oauth_example.yaml"))
191191

192192
url := fmt.Sprintf("http://localhost:%d/mcp", 1975)
193193

tests/e2e-aigw/goose_test.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ package e2emcp
88
import (
99
"encoding/json"
1010
"fmt"
11+
"os"
1112
"os/exec"
1213
"path/filepath"
1314
"strings"
@@ -18,7 +19,10 @@ import (
1819
)
1920

2021
func TestMCPGooseRecipe(t *testing.T) {
21-
startAIGWCLI(t, aigwBin, "run", "--debug", "aigw_config.yaml")
22+
startAIGWCLI(t, aigwBin, []string{
23+
"OPENAI_BASE_URL=http://127.0.0.1:11434/v1",
24+
"OPENAI_API_KEY=unused",
25+
}, "run", "--debug", "--mcp-json", `{"mcpServers":{"kiwi":{"type":"http","url":"https://mcp.kiwi.com"}}}`)
2226

2327
for _, tc := range []gooseRecipeTestCase{
2428
{
@@ -52,6 +56,12 @@ func TestMCPGooseRecipe(t *testing.T) {
5256
cmd := exec.CommandContext(t.Context(), "goose", args...)
5357
cmd.Stdout = buffers[0]
5458
cmd.Stderr = buffers[1]
59+
// Point Goose at aigw also for LLM access
60+
cmd.Env = append(os.Environ(),
61+
"OPENAI_HOST=http://127.0.0.1:1975",
62+
"OPENAI_BASE_PATH=v1/chat/completions",
63+
"OPENAI_API_KEY=test-key",
64+
)
5565

5666
if err := cmd.Run(); err != nil {
5767
return err

tests/e2e-aigw/testdata/kiwi_recipe.yaml

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,18 @@ prompt: |
3131
3232
***********ANY FLIGHT IS FINE. DO NOT CONSIDER ANY USER PREFERENCES.************
3333
34+
# Start aigw like this to use Ollama and Kiwi MCP backends:
35+
# OPENAI_BASE_URL=http://localhost:11434/v1 OPENAI_API_KEY=unused aigw run --mcp-json '{
36+
# "mcpServers": {
37+
# "kiwi": {
38+
# "type": "http",
39+
# "url": "https://mcp.kiwi.com"
40+
# }
41+
# }
42+
# }'
43+
#
44+
# Then, run goose like this to use Envoy AI Gateway for both LLM and MCP:
45+
# OPENAI_HOST=http://127.0.0.1:1975 OPENAI_API_KEY=test-key goose run --provider openai --model qwen3:1.7b --recipe kiwi_recipe.yaml --params flight_date=31/12/2025
3446
extensions:
3547
- name: mcp_gateway
3648
type: streamable_http
@@ -41,11 +53,10 @@ parameters:
4153
input_type: string
4254
requirement: required
4355
description: flight date in DD/MM/YYYY format
44-
default: "01/10/2025"
56+
default: "31/12/2025"
4557

4658
settings:
47-
goose_provider: ollama
48-
goose_model: qwen3:0.6b
59+
# Remove this if using GPT-5 series (e.g., gpt-5, gpt-5-mini, gpt-5-nano)
4960
temperature: 0.0
5061

5162
response:

0 commit comments

Comments
 (0)