Skip to content

Commit 3159617

Browse files
mathetakeAyushSawant18588
authored andcommitted
chore: removes envoy installation requirement for running extproc tests (envoyproxy#1385)
**Description** This removes one of the test requirement which is Envoy by leveraging func-e via go tool. Since Envoy v1.36 was released, so this also upgrades the envoy version used in the test to v1.36 --------- Signed-off-by: Takeshi Yoneda <[email protected]> Signed-off-by: ayush <[email protected]>
1 parent 6db2965 commit 3159617

File tree

6 files changed

+39
-34
lines changed

6 files changed

+39
-34
lines changed

.envoy-version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
1.36.2

.github/workflows/build_and_test.yaml

Lines changed: 4 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -136,20 +136,13 @@ jobs:
136136
test_extproc:
137137
needs: changes
138138
if: ${{ needs.changes.outputs.code == 'true' }}
139-
name: External Processor Test (Envoy v${{ matrix.version }} on ${{ matrix.os }})
139+
name: External Processor Test (${{ matrix.os }})
140140
strategy:
141141
fail-fast: false
142142
matrix:
143-
# Note: we cannot run the latest Envoy version on macOS due to https://github.com/tetratelabs/archive-envoy/issues/12.
144-
# Once it's supported, the following "binary installation" steps below can be just removed and
145-
# we can simply exec.Cmd with "go tool -modfile=tools/go.mod func-e run" with the envoy version configured via ENVOY_VERSION env var.
146-
include:
147-
- version: 1.35.0 # NOTE: when updating this, also update the comment in the CONTRIBUTING.md file.
148-
os: ubuntu-latest
149-
- version: 1.35.0 # NOTE: when updating this, also update the comment in the CONTRIBUTING.md file.
150-
os: macos-latest
151-
- version: latest
152-
os: ubuntu-latest
143+
os:
144+
- ubuntu-latest
145+
- macos-latest
153146
runs-on: ${{ matrix.os }}
154147
steps:
155148
- uses: actions/checkout@v4
@@ -164,19 +157,6 @@ jobs:
164157
~/go/pkg/mod
165158
~/go/bin
166159
key: extproc-tests-${{ hashFiles('**/go.mod', '**/go.sum', '**/Makefile') }}
167-
- name: Install stable Envoy via func-e
168-
if: matrix.version != 'latest'
169-
run: |
170-
go tool -modfile=tools/go.mod func-e use ${{ matrix.version }}
171-
echo $HOME/.func-e/versions/${{ matrix.version }}/bin >> $GITHUB_PATH
172-
- name: Install latest Envoy
173-
if: matrix.version == 'latest'
174-
run: |
175-
export ENVOY_BIN_DIR=$HOME/envoy/bin
176-
mkdir -p $ENVOY_BIN_DIR
177-
docker run -v $ENVOY_BIN_DIR:/tmp/ci -w /tmp/ci \
178-
--entrypoint /bin/cp envoyproxy/envoy-dev:latest /usr/local/bin/envoy .
179-
echo $ENVOY_BIN_DIR >> $GITHUB_PATH
180160
- env:
181161
TEST_AWS_ACCESS_KEY_ID: ${{ secrets.AWS_BEDROCK_USER_AWS_ACCESS_KEY_ID }}
182162
TEST_AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_BEDROCK_USER_AWS_SECRET_ACCESS_KEY }}

CONTRIBUTING.md

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,6 @@ For example,
4343

4444
- The latest `kubectl` binary for running `make test-e2e`.
4545
- See: https://kubernetes.io/docs/tasks/tools/
46-
- The latest `envoy` binary for running `make test-extproc`. The current required version is v1.35 or later.
47-
- On Linux, you can download the latest Envoy binary as described in https://www.envoyproxy.io/docs/envoy/latest/start/install.
48-
Alternatively, you can use `func-e` on Linux as well like on macOS below.
49-
- On macOS, since `brew envoy` tends to behind the latest version, it is recommended use `func-e` to run the latest Envoy. See https://func-e.io/.
50-
- `alias envoy='func-e run'` is a convenient way to run the latest Envoy binary via `func-e` on both macOS and Linux.
51-
For example, `func-e use 1.34` can be used to switch to a specific version of Envoy to be run with `func-e run`.
5246

5347
Other than that, everything will be automatically managed and installed via `make` targets,
5448
and you should not need to worry about the dependencies (tell us if you do).

Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,8 @@ test-crdcel: apigen ## Run the integration tests of CEL validation in CRD defini
155155
.PHONY: test-extproc # This requires the extproc binary to be built.
156156
test-extproc: build.extproc ## Run the integration tests for extproc without controller or k8s at all.
157157
@$(MAKE) build.testupstream CMD_PATH_PREFIX=tests/internal/testupstreamlib
158+
@echo "Ensure func-e is built and Envoy is installed"
159+
@@$(GO_TOOL) func-e run --version >/dev/null 2>&1
158160
@echo "Run ExtProc test"
159161
@EXTPROC_BIN=$(OUTPUT_DIR)/extproc-$(shell go env GOOS)-$(shell go env GOARCH) go test ./tests/extproc/... $(GO_TEST_E2E_ARGS)
160162

tests/extproc/extproc_test.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,7 @@ var (
5959
Region: "gcp-region",
6060
ProjectName: "gcp-project-name",
6161
}}}
62-
// This always failing backend is configured to have AWS Bedrock schema so that
63-
// we can test that the extproc can fallback to the different schema. E.g. Primary AWS and then OpenAI.
64-
alwaysFailingBackend = filterapi.Backend{Name: "always-failing-backend", Schema: awsBedrockSchema}
62+
alwaysFailingBackend = filterapi.Backend{Name: "always-failing-backend", Schema: openAISchema}
6563

6664
// envoyConfig is the embedded Envoy configuration template.
6765
//

tests/internal/testenvironment/test_environment.go

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import (
1313
"net"
1414
"os"
1515
"os/exec"
16+
"path/filepath"
1617
"runtime"
1718
"strconv"
1819
"strings"
@@ -24,6 +25,7 @@ import (
2425

2526
"github.com/envoyproxy/ai-gateway/cmd/extproc/mainlib"
2627
internaltesting "github.com/envoyproxy/ai-gateway/internal/testing"
28+
testsinternal "github.com/envoyproxy/ai-gateway/tests/internal"
2729
)
2830

2931
// TestEnvironment holds all the services needed for tests.
@@ -257,14 +259,42 @@ func requireEnvoy(t testing.TB,
257259
envoyYamlPath := t.TempDir() + "/envoy.yaml"
258260
require.NoError(t, os.WriteFile(envoyYamlPath, []byte(processedConfig), 0o600))
259261

260-
cmd := exec.CommandContext(t.Context(), "envoy",
262+
// Note: do not pass t.Context() to CommandContext, as it's canceled
263+
// *before* t.Cleanup functions are called.
264+
//
265+
// > Context returns a context that is canceled just before
266+
// > Cleanup-registered functions are called.
267+
//
268+
// That means the subprocess gets killed before we can send it an interrupt
269+
// signal for graceful shutdown, which results in orphaned subprocesses.
270+
ctx, cancel := context.WithCancel(context.Background())
271+
cmd := testsinternal.GoToolCmdContext(ctx, "func-e", "run",
261272
"-c", envoyYamlPath,
262273
"--concurrency", strconv.Itoa(max(runtime.NumCPU(), 2)),
263274
// This allows multiple Envoy instances to run in parallel.
264275
"--base-id", strconv.Itoa(time.Now().Nanosecond()),
265276
// Add debug logging for http.
266277
"--component-log-level", "http:debug",
267278
)
279+
// func-e will use the version specified in the project root's .envoy-version file.
280+
cmd.Dir = internaltesting.FindProjectRoot()
281+
version, err := os.ReadFile(filepath.Join(cmd.Dir, ".envoy-version"))
282+
require.NoError(t, err)
283+
t.Logf("Starting Envoy version %s", strings.TrimSpace(string(version)))
284+
cmd.WaitDelay = 3 * time.Second // auto-kill after 3 seconds.
285+
t.Cleanup(func() {
286+
defer cancel()
287+
// Graceful shutdown, should kill the Envoy subprocess, too.
288+
if err := cmd.Process.Signal(os.Interrupt); err != nil {
289+
t.Logf("Failed to send interrupt to aigw process: %v", err)
290+
}
291+
// Wait for the process to exit gracefully, in worst case this is
292+
// killed in 3 seconds by WaitDelay above. In that case, you may
293+
// have a zombie Envoy process left behind!
294+
if _, err := cmd.Process.Wait(); err != nil {
295+
t.Logf("Failed to wait for aigw process to exit: %v", err)
296+
}
297+
})
268298

269299
// wait for the ready message or exit.
270300
StartAndAwaitReady(t, cmd, stdout, stderr, "starting main dispatch loop")

0 commit comments

Comments
 (0)