Repository: envoyproxy/ai-gateway
Pull request #329 (2025-02-12 17:11:25)

build: use Go 1.24
**Commit Message**

This upgrades the Go version to v1.24. There are a few things to note:
* Starts utilizing testing.T.Context() in various places.
* Adds `make clean` target in case local setup goes wrong. 




Patch:
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 6e6a55f..5289c3b 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -26,6 +26,8 @@ the list of commands that you can run to build, test, and run the project.
 
 For example, `make precommit test` will run the precommit checks and the unit tests.
 These are the must-run commands before you submit or pushing commits to a PR.
+If anything goes wrong, please try to run `make clean` and then run the command again.
+
 All test targets are prefixed with `test-*` and can be run via `make test-<target>`.
 
 Some test commands might require additional dependencies to be installed on your machine.
diff --git a/Makefile b/Makefile
index 584f8ba..30437f8 100644
--- a/Makefile
+++ b/Makefile
@@ -31,6 +31,7 @@ help:
 	@echo ""
 	@echo "All core targets needed for contributing:"
 	@echo "  precommit       	 Run all necessary steps to prepare for a commit."
+	@echo "  clean           	 Clears all cached files and built artifacts. Whenever you run into issues with the target like 'precommit' or 'test', try running this target."
 	@echo "  test            	 Run the unit tests for the codebase."
 	@echo "  test-coverage		 Run the unit tests for the codebase with coverage check."
 	@echo "  test-crdcel      	 Run the integration tests of CEL validation in CRD definitions with envtest."
@@ -171,6 +172,14 @@ test-coverage: go-test-coverage
 	@$(MAKE) test GO_TEST_ARGS="-coverprofile=$(OUTPUT_DIR)/go-test-coverage.out -covermode=atomic -coverpkg=./... $(GO_TEST_ARGS)"
 	@${GO_TEST_COVERAGE} --config=.testcoverage.yml
 
+# This clears all cached files and built artifacts.
+#
+# Whenever you run into issues with the target like `precommit` or `test`, try running this target.
+.PHONY: clean
+clean:
+	rm -rf $(OUTPUT_DIR)
+	go clean -modcache
+
 # This builds a binary for the given command under the internal/cmd directory.
 #
 # Example:
diff --git a/Makefile.tools.mk b/Makefile.tools.mk
index f4b0076..4895811 100644
--- a/Makefile.tools.mk
+++ b/Makefile.tools.mk
@@ -23,7 +23,7 @@ CONTROLLER_TOOLS_VERSION ?= v0.17.1
 # https://github.com/kubernetes-sigs/controller-runtime/releases Note: this needs to point to a release branch.
 ENVTEST_VERSION ?= release-0.20
 # https://github.com/golangci/golangci-lint/releases
-GOLANGCI_LINT_VERSION ?= v1.63.4
+GOLANGCI_LINT_VERSION ?= v1.64.2
 # https://github.com/mvdan/gofumpt/releases
 GO_FUMPT_VERSION ?= v0.7.0
 # https://github.com/daixiang0/gci/releases
diff --git a/go.mod b/go.mod
index 72d608d..dd83f09 100644
--- a/go.mod
+++ b/go.mod
@@ -1,6 +1,6 @@
 module github.com/envoyproxy/ai-gateway
 
-go 1.23.6
+go 1.24.0
 
 require (
 	github.com/aws/aws-sdk-go-v2 v1.36.1
@@ -70,6 +70,8 @@ require (
 	github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
 	github.com/modern-go/reflect2 v1.0.2 // indirect
 	github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
+	github.com/onsi/ginkgo/v2 v2.22.2 // indirect
+	github.com/onsi/gomega v1.36.2 // indirect
 	github.com/pkg/errors v0.9.1 // indirect
 	github.com/planetscale/vtprotobuf v0.6.1-0.20240319094008-0393e58bdf10 // indirect
 	github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
@@ -86,13 +88,14 @@ require (
 	github.com/tidwall/sjson v1.2.5 // indirect
 	github.com/x448/float16 v0.8.4 // indirect
 	go.uber.org/multierr v1.11.0 // indirect
-	golang.org/x/net v0.34.0 // indirect
-	golang.org/x/oauth2 v0.25.0 // indirect
-	golang.org/x/sync v0.10.0 // indirect
-	golang.org/x/sys v0.29.0 // indirect
-	golang.org/x/term v0.28.0 // indirect
-	golang.org/x/text v0.21.0 // indirect
+	golang.org/x/net v0.35.0 // indirect
+	golang.org/x/oauth2 v0.26.0 // indirect
+	golang.org/x/sync v0.11.0 // indirect
+	golang.org/x/sys v0.30.0 // indirect
+	golang.org/x/term v0.29.0 // indirect
+	golang.org/x/text v0.22.0 // indirect
 	golang.org/x/time v0.9.0 // indirect
+	golang.org/x/tools v0.30.0 // indirect
 	gomodules.xyz/jsonpatch/v2 v2.4.0 // indirect
 	google.golang.org/genproto/googleapis/api v0.0.0-20250127172529-29210b9bc287 // indirect
 	google.golang.org/genproto/googleapis/rpc v0.0.0-20250127172529-29210b9bc287 // indirect
diff --git a/go.sum b/go.sum
index bb89539..55dd267 100644
--- a/go.sum
+++ b/go.sum
@@ -86,8 +86,8 @@ github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeN
 github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
 github.com/google/gofuzz v1.2.0 h1:xRy4A+RhZaiKjJ1bPfwQ8sedCA+YS2YcCHW6ec7JMi0=
 github.com/google/gofuzz v1.2.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
-github.com/google/pprof v0.0.0-20241029153458-d1b30febd7db h1:097atOisP2aRj7vFgYQBbFN4U4JNXUNYpxael3UzMyo=
-github.com/google/pprof v0.0.0-20241029153458-d1b30febd7db/go.mod h1:vavhavw2zAxS5dIdcRluK6cSGGPlZynqzFM8NdvU144=
+github.com/google/pprof v0.0.0-20241210010833-40e02aabc2ad h1:a6HEuzUHeKH6hwfN/ZoQgRgVIWFJljSWa/zetS2WTvg=
+github.com/google/pprof v0.0.0-20241210010833-40e02aabc2ad/go.mod h1:vavhavw2zAxS5dIdcRluK6cSGGPlZynqzFM8NdvU144=
 github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
 github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
 github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY=
@@ -113,10 +113,10 @@ github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9G
 github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
 github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA=
 github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ=
-github.com/onsi/ginkgo/v2 v2.21.0 h1:7rg/4f3rB88pb5obDgNZrNHrQ4e6WpjonchcpuBRnZM=
-github.com/onsi/ginkgo/v2 v2.21.0/go.mod h1:7Du3c42kxCUegi0IImZ1wUQzMBVecgIHjR1C+NkhLQo=
-github.com/onsi/gomega v1.35.1 h1:Cwbd75ZBPxFSuZ6T+rN/WCb/gOc6YgFBXLlZLhC7Ds4=
-github.com/onsi/gomega v1.35.1/go.mod h1:PvZbdDc8J6XJEpDK4HCuRBm8a6Fzp9/DmhC9C7yFlog=
+github.com/onsi/ginkgo/v2 v2.22.2 h1:/3X8Panh8/WwhU/3Ssa6rCKqPLuAkVY2I0RoyDLySlU=
+github.com/onsi/ginkgo/v2 v2.22.2/go.mod h1:oeMosUL+8LtarXBHu/c0bx2D/K9zyQ6uX3cTyztHwsk=
+github.com/onsi/gomega v1.36.2 h1:koNYke6TVk6ZmnyHrCXba/T/MoLBXFjeC1PtvYgw0A8=
+github.com/onsi/gomega v1.36.2/go.mod h1:DdwyADRjrc825LhMEkD76cHR5+pUnjhUN8GlHlRPHzY=
 github.com/openai/openai-go v0.1.0-alpha.56 h1:wKKsyVUi6ppZ8WRL+PC+tOB67alvJjfEWkC3Lc9YnqU=
 github.com/openai/openai-go v0.1.0-alpha.56/go.mod h1:3SdE6BffOX9HPEQv8IL/fi3LYZ5TUpRYaqGQZbyk11A=
 github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
@@ -192,34 +192,34 @@ golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn
 golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
 golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
 golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
-golang.org/x/net v0.34.0 h1:Mb7Mrk043xzHgnRM88suvJFwzVrRfHEHJEl5/71CKw0=
-golang.org/x/net v0.34.0/go.mod h1:di0qlW3YNM5oh6GqDGQr92MyTozJPmybPK4Ev/Gm31k=
-golang.org/x/oauth2 v0.25.0 h1:CY4y7XT9v0cRI9oupztF8AgiIu99L/ksR/Xp/6jrZ70=
-golang.org/x/oauth2 v0.25.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI=
+golang.org/x/net v0.35.0 h1:T5GQRQb2y08kTAByq9L4/bz8cipCdA8FbRTXewonqY8=
+golang.org/x/net v0.35.0/go.mod h1:EglIi67kWsHKlRzzVMUD93VMSWGFOMSZgxFjparz1Qk=
+golang.org/x/oauth2 v0.26.0 h1:afQXWNNaeC4nvZ0Ed9XvCCzXM6UHJG7iCg0W4fPqSBE=
+golang.org/x/oauth2 v0.26.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI=
 golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
 golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
 golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
-golang.org/x/sync v0.10.0 h1:3NQrjDixjgGwUOCaF8w2+VYHv0Ve/vGYSbdkTa98gmQ=
-golang.org/x/sync v0.10.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
+golang.org/x/sync v0.11.0 h1:GGz8+XQP4FvTTrjZPzNKTMFtSXH80RAzG+5ghFPgK9w=
+golang.org/x/sync v0.11.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
 golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
 golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
 golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
-golang.org/x/sys v0.29.0 h1:TPYlXGxvx1MGTn2GiZDhnjPA9wZzZeGKHHmKhHYvgaU=
-golang.org/x/sys v0.29.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
-golang.org/x/term v0.28.0 h1:/Ts8HFuMR2E6IP/jlo7QVLZHggjKQbhu/7H0LJFr3Gg=
-golang.org/x/term v0.28.0/go.mod h1:Sw/lC2IAUZ92udQNf3WodGtn4k/XoLyZoh8v/8uiwek=
+golang.org/x/sys v0.30.0 h1:QjkSwP/36a20jFYWkSue1YwXzLmsV5Gfq7Eiy72C1uc=
+golang.org/x/sys v0.30.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
+golang.org/x/term v0.29.0 h1:L6pJp37ocefwRRtYPKSWOWzOtWSxVajvz2ldH/xi3iU=
+golang.org/x/term v0.29.0/go.mod h1:6bl4lRlvVuDgSf3179VpIxBF0o10JUpXWOnI7nErv7s=
 golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
 golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
-golang.org/x/text v0.21.0 h1:zyQAAkrwaneQ066sspRyJaG9VNi/YJ1NfzcGB3hZ/qo=
-golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ=
+golang.org/x/text v0.22.0 h1:bofq7m3/HAFvbF51jz3Q9wLg3jkvSPuiZu/pD1XwgtM=
+golang.org/x/text v0.22.0/go.mod h1:YRoo4H8PVmsu+E3Ou7cqLVH8oXWIHVoX0jqUWALQhfY=
 golang.org/x/time v0.9.0 h1:EsRrnYcQiGH+5FfbgvV4AP7qEZstoyrHB0DzarOQ4ZY=
 golang.org/x/time v0.9.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM=
 golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
 golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
 golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
 golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
-golang.org/x/tools v0.29.0 h1:Xx0h3TtM9rzQpQuR4dKLrdglAmCEN5Oi+P74JdhdzXE=
-golang.org/x/tools v0.29.0/go.mod h1:KMQVMRsVxU6nHCFXrBPhDB8XncLNLM0lIy/F14RP588=
+golang.org/x/tools v0.30.0 h1:BgcpHewrV5AUp2G9MebG4XPFI1E2W41zU1SaqVA9vJY=
+golang.org/x/tools v0.30.0/go.mod h1:c347cR/OJfw5TI+GfX7RUPNMdDRRbjvYTS0jPyvsVtY=
 golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
 golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
 golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=


Test patch:
diff --git a/filterapi/filterconfig_test.go b/filterapi/filterconfig_test.go
index 411c698..826528a 100644
--- a/filterapi/filterconfig_test.go
+++ b/filterapi/filterconfig_test.go
@@ -1,7 +1,6 @@
 package filterapi_test
 
 import (
-	"context"
 	"log/slog"
 	"os"
 	"path"
@@ -23,7 +22,7 @@ func TestDefaultConfig(t *testing.T) {
 	err = yaml.Unmarshal([]byte(filterapi.DefaultConfig), &cfg)
 	require.NoError(t, err)
 
-	err = server.LoadConfig(context.Background(), &cfg)
+	err = server.LoadConfig(t.Context(), &cfg)
 	require.NoError(t, err)
 }
 
diff --git a/internal/controller/ai_gateway_route_test.go b/internal/controller/ai_gateway_route_test.go
index 5fe2f2c..04229e6 100644
--- a/internal/controller/ai_gateway_route_test.go
+++ b/internal/controller/ai_gateway_route_test.go
@@ -1,7 +1,6 @@
 package controller
 
 import (
-	"context"
 	"testing"
 
 	egv1a1 "github.com/envoyproxy/gateway/api/v1alpha1"
@@ -28,9 +27,9 @@ func TestAIGatewayRouteController_Reconcile(t *testing.T) {
 	cl := fake.NewClientBuilder().WithScheme(scheme).Build()
 	c := NewAIGatewayRouteController(cl, fake2.NewClientset(), ctrl.Log, ch)
 
-	err := cl.Create(context.Background(), &aigv1a1.AIGatewayRoute{ObjectMeta: metav1.ObjectMeta{Name: "myroute", Namespace: "default"}})
+	err := cl.Create(t.Context(), &aigv1a1.AIGatewayRoute{ObjectMeta: metav1.ObjectMeta{Name: "myroute", Namespace: "default"}})
 	require.NoError(t, err)
-	_, err = c.Reconcile(context.Background(), reconcile.Request{NamespacedName: types.NamespacedName{Namespace: "default", Name: "myroute"}})
+	_, err = c.Reconcile(t.Context(), reconcile.Request{NamespacedName: types.NamespacedName{Namespace: "default", Name: "myroute"}})
 	require.NoError(t, err)
 	item, ok := <-ch
 	require.True(t, ok)
@@ -43,9 +42,9 @@ func TestAIGatewayRouteController_Reconcile(t *testing.T) {
 	current.Spec.TargetRefs = []gwapiv1a2.LocalPolicyTargetReferenceWithSectionName{
 		{LocalPolicyTargetReference: gwapiv1a2.LocalPolicyTargetReference{Name: "mytarget"}},
 	}
-	err = cl.Update(context.Background(), current)
+	err = cl.Update(t.Context(), current)
 	require.NoError(t, err)
-	_, err = c.Reconcile(context.Background(), reconcile.Request{NamespacedName: types.NamespacedName{Namespace: "default", Name: "myroute"}})
+	_, err = c.Reconcile(t.Context(), reconcile.Request{NamespacedName: types.NamespacedName{Namespace: "default", Name: "myroute"}})
 	require.NoError(t, err)
 	item, ok = <-ch
 	require.True(t, ok)
@@ -57,9 +56,9 @@ func TestAIGatewayRouteController_Reconcile(t *testing.T) {
 	require.Equal(t, "mytarget", string(r.Spec.TargetRefs[0].Name))
 
 	// Test the case where the AIGatewayRoute is being deleted.
-	err = cl.Delete(context.Background(), &aigv1a1.AIGatewayRoute{ObjectMeta: metav1.ObjectMeta{Name: "myroute", Namespace: "default"}})
+	err = cl.Delete(t.Context(), &aigv1a1.AIGatewayRoute{ObjectMeta: metav1.ObjectMeta{Name: "myroute", Namespace: "default"}})
 	require.NoError(t, err)
-	_, err = c.Reconcile(context.Background(), reconcile.Request{NamespacedName: types.NamespacedName{Namespace: "default", Name: "myroute"}})
+	_, err = c.Reconcile(t.Context(), reconcile.Request{NamespacedName: types.NamespacedName{Namespace: "default", Name: "myroute"}})
 	require.NoError(t, err)
 }
 
@@ -77,10 +76,10 @@ func TestAIGatewayRouteController_ensuresExtProcConfigMapExists(t *testing.T) {
 	}
 	aiGatewayRoute := &aigv1a1.AIGatewayRoute{ObjectMeta: metav1.ObjectMeta{Name: name, Namespace: "default"}}
 
-	err := c.ensuresExtProcConfigMapExists(context.Background(), aiGatewayRoute)
+	err := c.ensuresExtProcConfigMapExists(t.Context(), aiGatewayRoute)
 	require.NoError(t, err)
 
-	configMap, err := c.kube.CoreV1().ConfigMaps("default").Get(context.Background(), extProcName(aiGatewayRoute), metav1.GetOptions{})
+	configMap, err := c.kube.CoreV1().ConfigMaps("default").Get(t.Context(), extProcName(aiGatewayRoute), metav1.GetOptions{})
 	require.NoError(t, err)
 	require.Equal(t, extProcName(aiGatewayRoute), configMap.Name)
 	require.Equal(t, "default", configMap.Namespace)
@@ -88,7 +87,7 @@ func TestAIGatewayRouteController_ensuresExtProcConfigMapExists(t *testing.T) {
 	require.Equal(t, filterapi.DefaultConfig, configMap.Data[expProcConfigFileName])
 
 	// Doing it again should not fail.
-	err = c.ensuresExtProcConfigMapExists(context.Background(), aiGatewayRoute)
+	err = c.ensuresExtProcConfigMapExists(t.Context(), aiGatewayRoute)
 	require.NoError(t, err)
 }
 
@@ -110,10 +109,10 @@ func TestAIGatewayRouteController_reconcileExtProcExtensionPolicy(t *testing.T)
 			},
 		},
 	}
-	err := c.reconcileExtProcExtensionPolicy(context.Background(), aiGatewayRoute)
+	err := c.reconcileExtProcExtensionPolicy(t.Context(), aiGatewayRoute)
 	require.NoError(t, err)
 	var extPolicy egv1a1.EnvoyExtensionPolicy
-	err = c.client.Get(context.Background(), client.ObjectKey{Name: extProcName(aiGatewayRoute), Namespace: "default"}, &extPolicy)
+	err = c.client.Get(t.Context(), client.ObjectKey{Name: extProcName(aiGatewayRoute), Namespace: "default"}, &extPolicy)
 	require.NoError(t, err)
 
 	require.Equal(t, len(aiGatewayRoute.Spec.TargetRefs), len(extPolicy.Spec.TargetRefs))
@@ -137,10 +136,10 @@ func TestAIGatewayRouteController_reconcileExtProcExtensionPolicy(t *testing.T)
 		{LocalPolicyTargetReference: gwapiv1a2.LocalPolicyTargetReference{Name: "cat"}},
 		{LocalPolicyTargetReference: gwapiv1a2.LocalPolicyTargetReference{Name: "bird"}},
 	}
-	err = c.reconcileExtProcExtensionPolicy(context.Background(), aiGatewayRoute)
+	err = c.reconcileExtProcExtensionPolicy(t.Context(), aiGatewayRoute)
 	require.NoError(t, err)
 
-	err = c.client.Get(context.Background(), client.ObjectKey{Name: extProcName(aiGatewayRoute), Namespace: "default"}, &extPolicy)
+	err = c.client.Get(t.Context(), client.ObjectKey{Name: extProcName(aiGatewayRoute), Namespace: "default"}, &extPolicy)
 	require.NoError(t, err)
 
 	require.Len(t, extPolicy.Spec.TargetRefs, 3)
diff --git a/internal/controller/ai_service_backend_test.go b/internal/controller/ai_service_backend_test.go
index 575abb3..63ddf75 100644
--- a/internal/controller/ai_service_backend_test.go
+++ b/internal/controller/ai_service_backend_test.go
@@ -1,7 +1,6 @@
 package controller
 
 import (
-	"context"
 	"testing"
 
 	"github.com/stretchr/testify/require"
@@ -23,9 +22,9 @@ func TestAIServiceBackendController_Reconcile(t *testing.T) {
 	cl := fake.NewClientBuilder().WithScheme(scheme).Build()
 	c := NewAIServiceBackendController(cl, fake2.NewClientset(), ctrl.Log, ch)
 
-	err := cl.Create(context.Background(), &aigv1a1.AIServiceBackend{ObjectMeta: metav1.ObjectMeta{Name: "mybackend", Namespace: "default"}})
+	err := cl.Create(t.Context(), &aigv1a1.AIServiceBackend{ObjectMeta: metav1.ObjectMeta{Name: "mybackend", Namespace: "default"}})
 	require.NoError(t, err)
-	_, err = c.Reconcile(context.Background(), reconcile.Request{NamespacedName: types.NamespacedName{Namespace: "default", Name: "mybackend"}})
+	_, err = c.Reconcile(t.Context(), reconcile.Request{NamespacedName: types.NamespacedName{Namespace: "default", Name: "mybackend"}})
 	require.NoError(t, err)
 	item, ok := <-ch
 	require.True(t, ok)
@@ -34,9 +33,9 @@ func TestAIServiceBackendController_Reconcile(t *testing.T) {
 	require.Equal(t, "default", item.(*aigv1a1.AIServiceBackend).Namespace)
 
 	// Test the case where the AIServiceBackend is being deleted.
-	err = cl.Delete(context.Background(), &aigv1a1.AIServiceBackend{ObjectMeta: metav1.ObjectMeta{Name: "mybackend", Namespace: "default"}})
+	err = cl.Delete(t.Context(), &aigv1a1.AIServiceBackend{ObjectMeta: metav1.ObjectMeta{Name: "mybackend", Namespace: "default"}})
 	require.NoError(t, err)
-	_, err = c.Reconcile(context.Background(), reconcile.Request{NamespacedName: types.NamespacedName{Namespace: "default", Name: "mybackend"}})
+	_, err = c.Reconcile(t.Context(), reconcile.Request{NamespacedName: types.NamespacedName{Namespace: "default", Name: "mybackend"}})
 	require.NoError(t, err)
 }
 
@@ -67,7 +66,7 @@ func Test_AiServiceBackendIndexFunc(t *testing.T) {
 			},
 		},
 	} {
-		require.NoError(t, c.Create(context.Background(), bsp, &client.CreateOptions{}))
+		require.NoError(t, c.Create(t.Context(), bsp, &client.CreateOptions{}))
 	}
 
 	// Create AI Service Backends.
@@ -100,21 +99,21 @@ func Test_AiServiceBackendIndexFunc(t *testing.T) {
 			},
 		},
 	} {
-		require.NoError(t, c.Create(context.Background(), backend, &client.CreateOptions{}))
+		require.NoError(t, c.Create(t.Context(), backend, &client.CreateOptions{}))
 	}
 
 	var aiServiceBackend aigv1a1.AIServiceBackendList
-	require.NoError(t, c.List(context.Background(), &aiServiceBackend,
+	require.NoError(t, c.List(t.Context(), &aiServiceBackend,
 		client.MatchingFields{k8sClientIndexBackendSecurityPolicyToReferencingAIServiceBackend: "some-backend-security-policy-1.ns"}))
 	require.Len(t, aiServiceBackend.Items, 2)
 	require.Equal(t, "one", aiServiceBackend.Items[0].Name)
 	require.Equal(t, "two", aiServiceBackend.Items[1].Name)
 
-	require.NoError(t, c.List(context.Background(), &aiServiceBackend,
+	require.NoError(t, c.List(t.Context(), &aiServiceBackend,
 		client.MatchingFields{k8sClientIndexBackendSecurityPolicyToReferencingAIServiceBackend: "some-backend-security-policy-2.ns"}))
 	require.Empty(t, aiServiceBackend.Items)
 
-	require.NoError(t, c.List(context.Background(), &aiServiceBackend,
+	require.NoError(t, c.List(t.Context(), &aiServiceBackend,
 		client.MatchingFields{k8sClientIndexBackendSecurityPolicyToReferencingAIServiceBackend: "some-backend-security-policy-3.ns"}))
 	require.Len(t, aiServiceBackend.Items, 1)
 	require.Equal(t, "three", aiServiceBackend.Items[0].Name)
diff --git a/internal/controller/backend_security_policy_test.go b/internal/controller/backend_security_policy_test.go
index 0f8d861..7f955da 100644
--- a/internal/controller/backend_security_policy_test.go
+++ b/internal/controller/backend_security_policy_test.go
@@ -1,7 +1,6 @@
 package controller
 
 import (
-	"context"
 	"testing"
 
 	"github.com/stretchr/testify/require"
@@ -22,9 +21,9 @@ func TestBackendSecurityController_Reconcile(t *testing.T) {
 	backendSecurityPolicyName := "mybackendSecurityPolicy"
 	namespace := "default"
 
-	err := cl.Create(context.Background(), &aigv1a1.BackendSecurityPolicy{ObjectMeta: metav1.ObjectMeta{Name: backendSecurityPolicyName, Namespace: namespace}})
+	err := cl.Create(t.Context(), &aigv1a1.BackendSecurityPolicy{ObjectMeta: metav1.ObjectMeta{Name: backendSecurityPolicyName, Namespace: namespace}})
 	require.NoError(t, err)
-	_, err = c.Reconcile(context.Background(), reconcile.Request{NamespacedName: types.NamespacedName{Namespace: namespace, Name: backendSecurityPolicyName}})
+	_, err = c.Reconcile(t.Context(), reconcile.Request{NamespacedName: types.NamespacedName{Namespace: namespace, Name: backendSecurityPolicyName}})
 	require.NoError(t, err)
 	item, ok := <-ch
 	require.True(t, ok)
@@ -33,8 +32,8 @@ func TestBackendSecurityController_Reconcile(t *testing.T) {
 	require.Equal(t, namespace, item.(*aigv1a1.BackendSecurityPolicy).Namespace)
 
 	// Test the case where the BackendSecurityPolicy is being deleted.
-	err = cl.Delete(context.Background(), &aigv1a1.BackendSecurityPolicy{ObjectMeta: metav1.ObjectMeta{Name: backendSecurityPolicyName, Namespace: namespace}})
+	err = cl.Delete(t.Context(), &aigv1a1.BackendSecurityPolicy{ObjectMeta: metav1.ObjectMeta{Name: backendSecurityPolicyName, Namespace: namespace}})
 	require.NoError(t, err)
-	_, err = c.Reconcile(context.Background(), reconcile.Request{NamespacedName: types.NamespacedName{Namespace: namespace, Name: backendSecurityPolicyName}})
+	_, err = c.Reconcile(t.Context(), reconcile.Request{NamespacedName: types.NamespacedName{Namespace: namespace, Name: backendSecurityPolicyName}})
 	require.NoError(t, err)
 }
diff --git a/internal/controller/controller_test.go b/internal/controller/controller_test.go
index 4cc0b5c..24a4b66 100644
--- a/internal/controller/controller_test.go
+++ b/internal/controller/controller_test.go
@@ -1,7 +1,6 @@
 package controller
 
 import (
-	"context"
 	"testing"
 
 	"github.com/stretchr/testify/require"
@@ -48,16 +47,16 @@ func Test_aiGatewayRouteIndexFunc(t *testing.T) {
 			},
 		},
 	}
-	require.NoError(t, c.Create(context.Background(), aiGatewayRoute))
+	require.NoError(t, c.Create(t.Context(), aiGatewayRoute))
 
 	var aiGatewayRoutes aigv1a1.AIGatewayRouteList
-	err := c.List(context.Background(), &aiGatewayRoutes,
+	err := c.List(t.Context(), &aiGatewayRoutes,
 		client.MatchingFields{k8sClientIndexBackendToReferencingAIGatewayRoute: "backend1.default"})
 	require.NoError(t, err)
 	require.Len(t, aiGatewayRoutes.Items, 1)
 	require.Equal(t, aiGatewayRoute.Name, aiGatewayRoutes.Items[0].Name)
 
-	err = c.List(context.Background(), &aiGatewayRoutes,
+	err = c.List(t.Context(), &aiGatewayRoutes,
 		client.MatchingFields{k8sClientIndexBackendToReferencingAIGatewayRoute: "backend2.default"})
 	require.NoError(t, err)
 	require.Len(t, aiGatewayRoutes.Items, 1)
@@ -138,10 +137,10 @@ func Test_backendSecurityPolicyIndexFunc(t *testing.T) {
 				WithIndex(&aigv1a1.BackendSecurityPolicy{}, k8sClientIndexSecretToReferencingBackendSecurityPolicy, backendSecurityPolicyIndexFunc).
 				Build()
 
-			require.NoError(t, c.Create(context.Background(), bsp.backendSecurityPolicy))
+			require.NoError(t, c.Create(t.Context(), bsp.backendSecurityPolicy))
 
 			var backendSecurityPolicies aigv1a1.BackendSecurityPolicyList
-			err := c.List(context.Background(), &backendSecurityPolicies,
+			err := c.List(t.Context(), &backendSecurityPolicies,
 				client.MatchingFields{k8sClientIndexSecretToReferencingBackendSecurityPolicy: bsp.expKey})
 			require.NoError(t, err)
 
diff --git a/internal/controller/secret_test.go b/internal/controller/secret_test.go
index 086dd6d..48b566b 100644
--- a/internal/controller/secret_test.go
+++ b/internal/controller/secret_test.go
@@ -1,7 +1,6 @@
 package controller
 
 import (
-	"context"
 	"testing"
 
 	"github.com/stretchr/testify/require"
@@ -19,13 +18,13 @@ func TestSecretController_Reconcile(t *testing.T) {
 	cl := fake.NewClientBuilder().WithScheme(scheme).Build()
 	c := NewSecretController(cl, fake2.NewClientset(), ctrl.Log, ch)
 
-	err := cl.Create(context.Background(), &corev1.Secret{
+	err := cl.Create(t.Context(), &corev1.Secret{
 		ObjectMeta: metav1.ObjectMeta{Name: "mysecret", Namespace: "default"},
 		StringData: map[string]string{"key": "value"},
 	})
 	require.NoError(t, err)
 
-	_, err = c.Reconcile(context.Background(), reconcile.Request{NamespacedName: types.NamespacedName{
+	_, err = c.Reconcile(t.Context(), reconcile.Request{NamespacedName: types.NamespacedName{
 		Namespace: "default", Name: "mysecret",
 	}})
 	require.NoError(t, err)
@@ -35,11 +34,11 @@ func TestSecretController_Reconcile(t *testing.T) {
 	require.Equal(t, ConfigSinkEventSecretUpdate{Namespace: "default", Name: "mysecret"}, item)
 
 	// Test the case where the Secret is being deleted.
-	err = cl.Delete(context.Background(), &corev1.Secret{
+	err = cl.Delete(t.Context(), &corev1.Secret{
 		ObjectMeta: metav1.ObjectMeta{Name: "mysecret", Namespace: "default"},
 	})
 	require.NoError(t, err)
-	_, err = c.Reconcile(context.Background(), reconcile.Request{NamespacedName: types.NamespacedName{
+	_, err = c.Reconcile(t.Context(), reconcile.Request{NamespacedName: types.NamespacedName{
 		Namespace: "default", Name: "mysecret",
 	}})
 	require.NoError(t, err)
diff --git a/internal/controller/sink_test.go b/internal/controller/sink_test.go
index a35d221..aa93a5d 100644
--- a/internal/controller/sink_test.go
+++ b/internal/controller/sink_test.go
@@ -30,7 +30,7 @@ import (
 
 func requireNewFakeClientWithIndexes(t *testing.T) client.Client {
 	builder := fake.NewClientBuilder().WithScheme(scheme)
-	err := applyIndexing(context.Background(), func(_ context.Context, obj client.Object, field string, extractValue client.IndexerFunc) error {
+	err := applyIndexing(t.Context(), func(_ context.Context, obj client.Object, field string, extractValue client.IndexerFunc) error {
 		builder = builder.WithIndex(obj, field, extractValue)
 		return nil
 	})
@@ -46,15 +46,15 @@ func TestConfigSink_handleEvent(t *testing.T) {
 	s := newConfigSink(fakeClient, kube, logr.Discard(), eventChan, "defaultExtProcImage", "debug")
 	require.NotNil(t, s)
 
-	_, err := kube.CoreV1().ConfigMaps("ns").Create(context.Background(), &corev1.ConfigMap{
+	_, err := kube.CoreV1().ConfigMaps("ns").Create(t.Context(), &corev1.ConfigMap{
 		ObjectMeta: metav1.ObjectMeta{Name: "ai-eg-route-extproc-apple", Namespace: "ns"},
 	}, metav1.CreateOptions{})
 	require.NoError(t, err)
 
-	s.handleEvent(context.Background(), ConfigSinkEventSecretUpdate{Namespace: "ns", Name: "some-secret"})
-	s.handleEvent(context.Background(), &aigv1a1.AIServiceBackend{ObjectMeta: metav1.ObjectMeta{Name: "apple", Namespace: "ns"}})
-	s.handleEvent(context.Background(), &aigv1a1.BackendSecurityPolicy{ObjectMeta: metav1.ObjectMeta{Name: "apple", Namespace: "ns"}})
-	s.handleEvent(context.Background(), &aigv1a1.AIGatewayRoute{ObjectMeta: metav1.ObjectMeta{Name: "apple", Namespace: "ns"}})
+	s.handleEvent(t.Context(), ConfigSinkEventSecretUpdate{Namespace: "ns", Name: "some-secret"})
+	s.handleEvent(t.Context(), &aigv1a1.AIServiceBackend{ObjectMeta: metav1.ObjectMeta{Name: "apple", Namespace: "ns"}})
+	s.handleEvent(t.Context(), &aigv1a1.BackendSecurityPolicy{ObjectMeta: metav1.ObjectMeta{Name: "apple", Namespace: "ns"}})
+	s.handleEvent(t.Context(), &aigv1a1.AIGatewayRoute{ObjectMeta: metav1.ObjectMeta{Name: "apple", Namespace: "ns"}})
 }
 
 func TestConfigSink_syncAIGatewayRoute(t *testing.T) {
@@ -73,7 +73,7 @@ func TestConfigSink_syncAIGatewayRoute(t *testing.T) {
 			BackendRef: gwapiv1.BackendObjectReference{Name: "some-backend2", Namespace: ptr.To[gwapiv1.Namespace]("ns1")},
 		}},
 	} {
-		err := fakeClient.Create(context.Background(), backend, &client.CreateOptions{})
+		err := fakeClient.Create(t.Context(), backend, &client.CreateOptions{})
 		require.NoError(t, err)
 	}
 
@@ -89,25 +89,25 @@ func TestConfigSink_syncAIGatewayRoute(t *testing.T) {
 				APISchema: aigv1a1.VersionedAPISchema{Name: aigv1a1.APISchemaOpenAI, Version: "v123"},
 			},
 		}
-		err := fakeClient.Create(context.Background(), route, &client.CreateOptions{})
+		err := fakeClient.Create(t.Context(), route, &client.CreateOptions{})
 		require.NoError(t, err)
 		httpRoute := &gwapiv1.HTTPRoute{
 			ObjectMeta: metav1.ObjectMeta{Name: "route1", Namespace: "ns1", Labels: map[string]string{managedByLabel: "envoy-ai-gateway"}},
 			Spec:       gwapiv1.HTTPRouteSpec{},
 		}
-		err = fakeClient.Create(context.Background(), httpRoute, &client.CreateOptions{})
+		err = fakeClient.Create(t.Context(), httpRoute, &client.CreateOptions{})
 		require.NoError(t, err)
 
 		// Create the initial configmap.
-		_, err = kube.CoreV1().ConfigMaps(route.Namespace).Create(context.Background(), &corev1.ConfigMap{
+		_, err = kube.CoreV1().ConfigMaps(route.Namespace).Create(t.Context(), &corev1.ConfigMap{
 			ObjectMeta: metav1.ObjectMeta{Name: extProcName(route), Namespace: route.Namespace},
 		}, metav1.CreateOptions{})
 		require.NoError(t, err)
 
 		// Then sync, which should update the HTTPRoute.
-		s.syncAIGatewayRoute(context.Background(), route)
+		s.syncAIGatewayRoute(t.Context(), route)
 		var updatedHTTPRoute gwapiv1.HTTPRoute
-		err = fakeClient.Get(context.Background(), client.ObjectKey{Name: "route1", Namespace: "ns1"}, &updatedHTTPRoute)
+		err = fakeClient.Get(t.Context(), client.ObjectKey{Name: "route1", Namespace: "ns1"}, &updatedHTTPRoute)
 		require.NoError(t, err)
 		require.Len(t, updatedHTTPRoute.Spec.Rules, 3) // 2 backends + 1 for the default rule.
 		require.Len(t, updatedHTTPRoute.Spec.Rules[0].BackendRefs, 1)
@@ -122,7 +122,7 @@ func TestConfigSink_syncAIGatewayRoute(t *testing.T) {
 
 	// Check the namespace has the default host rewrite filter.
 	var f egv1a1.HTTPRouteFilter
-	err := s.client.Get(context.Background(), client.ObjectKey{Name: hostRewriteHTTPFilterName, Namespace: "ns1"}, &f)
+	err := s.client.Get(t.Context(), client.ObjectKey{Name: hostRewriteHTTPFilterName, Namespace: "ns1"}, &f)
 	require.NoError(t, err)
 	require.Equal(t, hostRewriteHTTPFilterName, f.Name)
 }
@@ -141,10 +141,10 @@ func TestConfigSink_syncAIServiceBackend(t *testing.T) {
 			},
 		},
 	}
-	require.NoError(t, fakeClient.Create(context.Background(), route, &client.CreateOptions{}))
+	require.NoError(t, fakeClient.Create(t.Context(), route, &client.CreateOptions{}))
 
 	s := newConfigSink(fakeClient, nil, logr.Discard(), eventChan, "defaultExtProcImage", "debug")
-	s.syncAIServiceBackend(context.Background(), &aigv1a1.AIServiceBackend{
+	s.syncAIServiceBackend(t.Context(), &aigv1a1.AIServiceBackend{
 		ObjectMeta: metav1.ObjectMeta{Name: "apple", Namespace: "ns1"},
 		Spec: aigv1a1.AIServiceBackendSpec{
 			BackendRef: gwapiv1.BackendObjectReference{Name: "some-backend", Namespace: ptr.To[gwapiv1.Namespace]("ns1")},
@@ -163,10 +163,10 @@ func TestConfigSink_syncBackendSecurityPolicy(t *testing.T) {
 			BackendSecurityPolicyRef: &gwapiv1.LocalObjectReference{Name: "apple"},
 		},
 	}
-	require.NoError(t, fakeClient.Create(context.Background(), &backend, &client.CreateOptions{}))
+	require.NoError(t, fakeClient.Create(t.Context(), &backend, &client.CreateOptions{}))
 
 	s := newConfigSink(fakeClient, nil, logr.Discard(), eventChan, "defaultExtProcImage", "debug")
-	s.syncBackendSecurityPolicy(context.Background(), &aigv1a1.BackendSecurityPolicy{
+	s.syncBackendSecurityPolicy(t.Context(), &aigv1a1.BackendSecurityPolicy{
 		ObjectMeta: metav1.ObjectMeta{Name: "apple", Namespace: "ns"},
 	})
 }
@@ -232,10 +232,10 @@ func Test_newHTTPRoute(t *testing.T) {
 			},
 		},
 	} {
-		err := s.client.Create(context.Background(), backend, &client.CreateOptions{})
+		err := s.client.Create(t.Context(), backend, &client.CreateOptions{})
 		require.NoError(t, err)
 	}
-	err := s.newHTTPRoute(context.Background(), httpRoute, aiGatewayRoute)
+	err := s.newHTTPRoute(t.Context(), httpRoute, aiGatewayRoute)
 	require.NoError(t, err)
 
 	expRules := []gwapiv1.HTTPRouteRule{
@@ -291,8 +291,8 @@ func Test_updateExtProcConfigMap(t *testing.T) {
 
 	eventChan := make(chan ConfigSinkEvent)
 	s := newConfigSink(fakeClient, kube, logr.Discard(), eventChan, "defaultExtProcImage", "debug")
-	require.NoError(t, fakeClient.Create(context.Background(), &corev1.Secret{ObjectMeta: metav1.ObjectMeta{Name: "some-secret-policy"}}))
-	require.NoError(t, fakeClient.Create(context.Background(), &corev1.Secret{ObjectMeta: metav1.ObjectMeta{Name: "some-secret-policy-2"}}))
+	require.NoError(t, fakeClient.Create(t.Context(), &corev1.Secret{ObjectMeta: metav1.ObjectMeta{Name: "some-secret-policy"}}))
+	require.NoError(t, fakeClient.Create(t.Context(), &corev1.Secret{ObjectMeta: metav1.ObjectMeta{Name: "some-secret-policy-2"}}))
 
 	for _, bsp := range []*aigv1a1.BackendSecurityPolicy{
 		{
@@ -318,7 +318,7 @@ func Test_updateExtProcConfigMap(t *testing.T) {
 			},
 		},
 	} {
-		err := fakeClient.Create(context.Background(), bsp, &client.CreateOptions{})
+		err := fakeClient.Create(t.Context(), bsp, &client.CreateOptions{})
 		require.NoError(t, err)
 	}
 
@@ -354,7 +354,7 @@ func Test_updateExtProcConfigMap(t *testing.T) {
 			},
 		},
 	} {
-		err := fakeClient.Create(context.Background(), b, &client.CreateOptions{})
+		err := fakeClient.Create(t.Context(), b, &client.CreateOptions{})
 		require.NoError(t, err)
 	}
 	require.NotNil(t, s)
@@ -461,15 +461,15 @@ func Test_updateExtProcConfigMap(t *testing.T) {
 		},
 	} {
 		t.Run(tc.name, func(t *testing.T) {
-			_, err := s.kube.CoreV1().ConfigMaps(tc.route.Namespace).Create(context.Background(), &corev1.ConfigMap{
+			_, err := s.kube.CoreV1().ConfigMaps(tc.route.Namespace).Create(t.Context(), &corev1.ConfigMap{
 				ObjectMeta: metav1.ObjectMeta{Name: extProcName(tc.route), Namespace: tc.route.Namespace},
 			}, metav1.CreateOptions{})
 			require.NoError(t, err)
 
-			err = s.updateExtProcConfigMap(context.Background(), tc.route, tc.exp.UUID)
+			err = s.updateExtProcConfigMap(t.Context(), tc.route, tc.exp.UUID)
 			require.NoError(t, err)
 
-			cm, err := s.kube.CoreV1().ConfigMaps(tc.route.Namespace).Get(context.Background(), extProcName(tc.route), metav1.GetOptions{})
+			cm, err := s.kube.CoreV1().ConfigMaps(tc.route.Namespace).Get(t.Context(), extProcName(tc.route), metav1.GetOptions{})
 			require.NoError(t, err)
 			require.NotNil(t, cm)
 
@@ -487,7 +487,7 @@ func TestConfigSink_SyncExtprocDeployment(t *testing.T) {
 
 	eventChan := make(chan ConfigSinkEvent)
 	s := newConfigSink(fakeClient, kube, logr.Discard(), eventChan, "envoyproxy/ai-gateway-extproc:foo", "debug")
-	err := fakeClient.Create(context.Background(), &corev1.Secret{ObjectMeta: metav1.ObjectMeta{Name: "some-secret-policy"}})
+	err := fakeClient.Create(t.Context(), &corev1.Secret{ObjectMeta: metav1.ObjectMeta{Name: "some-secret-policy"}})
 	require.NoError(t, err)
 
 	for _, bsp := range []*aigv1a1.BackendSecurityPolicy{
@@ -501,7 +501,7 @@ func TestConfigSink_SyncExtprocDeployment(t *testing.T) {
 			},
 		},
 	} {
-		require.NoError(t, fakeClient.Create(context.Background(), bsp, &client.CreateOptions{}))
+		require.NoError(t, fakeClient.Create(t.Context(), bsp, &client.CreateOptions{}))
 	}
 
 	for _, b := range []*aigv1a1.AIServiceBackend{
@@ -529,7 +529,7 @@ func TestConfigSink_SyncExtprocDeployment(t *testing.T) {
 			},
 		},
 	} {
-		require.NoError(t, fakeClient.Create(context.Background(), b, &client.CreateOptions{}))
+		require.NoError(t, fakeClient.Create(t.Context(), b, &client.CreateOptions{}))
 	}
 	require.NotNil(t, s)
 
@@ -579,10 +579,10 @@ func TestConfigSink_SyncExtprocDeployment(t *testing.T) {
 		},
 	}
 
-	require.NoError(t, fakeClient.Create(context.Background(), aiGatewayRoute, &client.CreateOptions{}))
+	require.NoError(t, fakeClient.Create(t.Context(), aiGatewayRoute, &client.CreateOptions{}))
 
 	t.Run("create", func(t *testing.T) {
-		err = s.syncExtProcDeployment(context.Background(), aiGatewayRoute)
+		err = s.syncExtProcDeployment(t.Context(), aiGatewayRoute)
 		require.NoError(t, err)
 
 		resourceLimits := &corev1.ResourceRequirements{
@@ -592,7 +592,7 @@ func TestConfigSink_SyncExtprocDeployment(t *testing.T) {
 			},
 		}
 		require.Eventually(t, func() bool {
-			extProcDeployment, err := s.kube.AppsV1().Deployments("ns").Get(context.Background(), extProcName(aiGatewayRoute), metav1.GetOptions{})
+			extProcDeployment, err := s.kube.AppsV1().Deployments("ns").Get(t.Context(), extProcName(aiGatewayRoute), metav1.GetOptions{})
 			if err != nil {
 				t.Logf("failed to get deployment %s: %v", extProcName(aiGatewayRoute), err)
 				return false
@@ -606,7 +606,7 @@ func TestConfigSink_SyncExtprocDeployment(t *testing.T) {
 			return true
 		}, 30*time.Second, 200*time.Millisecond)
 
-		service, err := s.kube.CoreV1().Services("ns").Get(context.Background(), extProcName(aiGatewayRoute), metav1.GetOptions{})
+		service, err := s.kube.CoreV1().Services("ns").Get(t.Context(), extProcName(aiGatewayRoute), metav1.GetOptions{})
 		require.NoError(t, err)
 		require.Equal(t, extProcName(aiGatewayRoute), service.Name)
 	})
@@ -623,10 +623,10 @@ func TestConfigSink_SyncExtprocDeployment(t *testing.T) {
 		aiGatewayRoute.Spec.FilterConfig.ExternalProcess.Resources = newResourceLimits
 		aiGatewayRoute.Spec.FilterConfig.ExternalProcess.Replicas = ptr.To[int32](456)
 
-		require.NoError(t, s.syncExtProcDeployment(context.Background(), aiGatewayRoute))
+		require.NoError(t, s.syncExtProcDeployment(t.Context(), aiGatewayRoute))
 		// Check the deployment is updated.
 		require.Eventually(t, func() bool {
-			extProcDeployment, err := s.kube.AppsV1().Deployments("ns").Get(context.Background(), extProcName(aiGatewayRoute), metav1.GetOptions{})
+			extProcDeployment, err := s.kube.AppsV1().Deployments("ns").Get(t.Context(), extProcName(aiGatewayRoute), metav1.GetOptions{})
 			if err != nil {
 				t.Logf("failed to get deployment %s: %v", extProcName(aiGatewayRoute), err)
 				return false
@@ -653,18 +653,18 @@ func TestConfigSink_MountBackendSecurityPolicySecrets(t *testing.T) {
 
 	eventChan := make(chan ConfigSinkEvent)
 	s := newConfigSink(fakeClient, kube, logr.Discard(), eventChan, "defaultExtProcImage", "debug")
-	ctx, cancel := context.WithCancel(context.Background())
+	ctx, cancel := context.WithCancel(t.Context())
 	defer cancel()
 	err := s.init(ctx)
 	require.NoError(t, err)
-	require.NoError(t, fakeClient.Create(context.Background(), &corev1.Secret{ObjectMeta: metav1.ObjectMeta{Name: "some-secret-policy"}}))
+	require.NoError(t, fakeClient.Create(t.Context(), &corev1.Secret{ObjectMeta: metav1.ObjectMeta{Name: "some-secret-policy"}}))
 
 	for _, secret := range []*corev1.Secret{
 		{ObjectMeta: metav1.ObjectMeta{Name: "some-secret-policy-1"}},
 		{ObjectMeta: metav1.ObjectMeta{Name: "some-secret-policy-2"}},
 		{ObjectMeta: metav1.ObjectMeta{Name: "some-secret-policy-3"}},
 	} {
-		require.NoError(t, fakeClient.Create(context.Background(), secret, &client.CreateOptions{}))
+		require.NoError(t, fakeClient.Create(t.Context(), secret, &client.CreateOptions{}))
 	}
 
 	for _, bsp := range []*aigv1a1.BackendSecurityPolicy{
@@ -700,7 +700,7 @@ func TestConfigSink_MountBackendSecurityPolicySecrets(t *testing.T) {
 			},
 		},
 	} {
-		require.NoError(t, fakeClient.Create(context.Background(), bsp, &client.CreateOptions{}))
+		require.NoError(t, fakeClient.Create(t.Context(), bsp, &client.CreateOptions{}))
 	}
 
 	for _, backend := range []*aigv1a1.AIServiceBackend{
@@ -726,7 +726,7 @@ func TestConfigSink_MountBackendSecurityPolicySecrets(t *testing.T) {
 			},
 		},
 	} {
-		require.NoError(t, fakeClient.Create(context.Background(), backend, &client.CreateOptions{}))
+		require.NoError(t, fakeClient.Create(t.Context(), backend, &client.CreateOptions{}))
 		require.NotNil(t, s)
 	}
 
@@ -772,9 +772,9 @@ func TestConfigSink_MountBackendSecurityPolicySecrets(t *testing.T) {
 		},
 	}
 
-	require.NoError(t, fakeClient.Create(context.Background(), &aiGateway, &client.CreateOptions{}))
+	require.NoError(t, fakeClient.Create(t.Context(), &aiGateway, &client.CreateOptions{}))
 
-	updatedSpec, err := s.mountBackendSecurityPolicySecrets(context.Background(), &spec, &aiGateway)
+	updatedSpec, err := s.mountBackendSecurityPolicySecrets(t.Context(), &spec, &aiGateway)
 	require.NoError(t, err)
 
 	require.Len(t, updatedSpec.Volumes, 3)
@@ -790,7 +790,7 @@ func TestConfigSink_MountBackendSecurityPolicySecrets(t *testing.T) {
 	require.Equal(t, "rule1-backref0-some-other-backend-security-policy-aws", updatedSpec.Containers[0].VolumeMounts[2].Name)
 	require.Equal(t, "/etc/backend_security_policy/rule1-backref0-some-other-backend-security-policy-aws", updatedSpec.Containers[0].VolumeMounts[2].MountPath)
 
-	require.NoError(t, fakeClient.Delete(context.Background(), &aigv1a1.AIServiceBackend{ObjectMeta: metav1.ObjectMeta{Name: "apple", Namespace: "ns"}}, &client.DeleteOptions{}))
+	require.NoError(t, fakeClient.Delete(t.Context(), &aigv1a1.AIServiceBackend{ObjectMeta: metav1.ObjectMeta{Name: "apple", Namespace: "ns"}}, &client.DeleteOptions{}))
 
 	// Update to new security policy.
 	backend := aigv1a1.AIServiceBackend{
@@ -804,10 +804,10 @@ func TestConfigSink_MountBackendSecurityPolicySecrets(t *testing.T) {
 		},
 	}
 
-	require.NoError(t, fakeClient.Create(context.Background(), &backend, &client.CreateOptions{}))
+	require.NoError(t, fakeClient.Create(t.Context(), &backend, &client.CreateOptions{}))
 	require.NotNil(t, s)
 
-	updatedSpec, err = s.mountBackendSecurityPolicySecrets(context.Background(), &spec, &aiGateway)
+	updatedSpec, err = s.mountBackendSecurityPolicySecrets(t.Context(), &spec, &aiGateway)
 	require.NoError(t, err)
 
 	require.Len(t, updatedSpec.Volumes, 3)
@@ -847,17 +847,17 @@ func Test_annotateExtProcPods(t *testing.T) {
 			},
 			Spec: corev1.PodSpec{Containers: []corev1.Container{{Name: "someapp"}}},
 		}
-		_, err := kube.CoreV1().Pods("foons").Create(context.Background(), pod, metav1.CreateOptions{})
+		_, err := kube.CoreV1().Pods("foons").Create(t.Context(), pod, metav1.CreateOptions{})
 		require.NoError(t, err)
 	}
 
 	uuid := string(uuid2.NewUUID())
-	err := s.annotateExtProcPods(context.Background(), aiGatewayRoute, uuid)
+	err := s.annotateExtProcPods(t.Context(), aiGatewayRoute, uuid)
 	require.NoError(t, err)
 
 	// Check that all pods have been annotated.
 	for i := range 5 {
-		pod, err := kube.CoreV1().Pods("foons").Get(context.Background(), "somepod"+strconv.Itoa(i), metav1.GetOptions{})
+		pod, err := kube.CoreV1().Pods("foons").Get(t.Context(), "somepod"+strconv.Itoa(i), metav1.GetOptions{})
 		require.NoError(t, err)
 		require.Equal(t, uuid, pod.Annotations[extProcConfigAnnotationKey])
 	}
@@ -870,10 +870,10 @@ func Test_syncSecret(t *testing.T) {
 	eventChan := make(chan ConfigSinkEvent)
 	s := newConfigSink(fakeClient, kube, logr.Discard(), eventChan, "defaultExtProcImage", "debug")
 
-	_, err := kube.CoreV1().Secrets("ns").Create(context.Background(), &corev1.Secret{
+	_, err := kube.CoreV1().Secrets("ns").Create(t.Context(), &corev1.Secret{
 		ObjectMeta: metav1.ObjectMeta{Name: "some-secret", Namespace: "ns"},
 		Data:       map[string][]byte{"key": []byte("value")},
 	}, metav1.CreateOptions{})
 	require.NoError(t, err)
-	s.syncSecret(context.Background(), "ns", "some-secret")
+	s.syncSecret(t.Context(), "ns", "some-secret")
 }
diff --git a/internal/extensionserver/extension_server_test.go b/internal/extensionserver/extension_server_test.go
index 8066bb8..3cff6c7 100644
--- a/internal/extensionserver/extension_server_test.go
+++ b/internal/extensionserver/extension_server_test.go
@@ -1,7 +1,6 @@
 package extensionserver
 
 import (
-	"context"
 	"testing"
 
 	"github.com/go-logr/logr"
@@ -17,7 +16,7 @@ func TestNew(t *testing.T) {
 func TestCheck(t *testing.T) {
 	logger := logr.Discard()
 	s := New(logger)
-	_, err := s.Check(context.Background(), nil)
+	_, err := s.Check(t.Context(), nil)
 	require.NoError(t, err)
 }
 
diff --git a/internal/extproc/backendauth/api_key_test.go b/internal/extproc/backendauth/api_key_test.go
index 6f08f38..e58afeb 100644
--- a/internal/extproc/backendauth/api_key_test.go
+++ b/internal/extproc/backendauth/api_key_test.go
@@ -1,7 +1,6 @@
 package backendauth
 
 import (
-	"context"
 	"os"
 	"testing"
 
@@ -63,7 +62,7 @@ func TestApiKeyHandler_Do(t *testing.T) {
 			Body: []byte(`{"messages": [{"role": "user", "content": [{"text": "Say this is a test!"}]}]}`),
 		},
 	}
-	err = handler.Do(context.Background(), requestHeaders, headerMut, bodyMut)
+	err = handler.Do(t.Context(), requestHeaders, headerMut, bodyMut)
 	require.NoError(t, err)
 
 	bearerToken, ok := requestHeaders["Authorization"]
diff --git a/internal/extproc/backendauth/auth_test.go b/internal/extproc/backendauth/auth_test.go
index 3e24dd9..9827d4f 100644
--- a/internal/extproc/backendauth/auth_test.go
+++ b/internal/extproc/backendauth/auth_test.go
@@ -1,7 +1,6 @@
 package backendauth
 
 import (
-	"context"
 	"os"
 	"testing"
 
@@ -41,7 +40,7 @@ aws_secret_access_key = test
 		},
 	} {
 		t.Run(tt.name, func(t *testing.T) {
-			_, err := NewHandler(context.Background(), tt.config)
+			_, err := NewHandler(t.Context(), tt.config)
 			require.NoError(t, err)
 		})
 	}
diff --git a/internal/extproc/backendauth/aws_test.go b/internal/extproc/backendauth/aws_test.go
index 0fffcde..4e96f3f 100644
--- a/internal/extproc/backendauth/aws_test.go
+++ b/internal/extproc/backendauth/aws_test.go
@@ -1,7 +1,6 @@
 package backendauth
 
 import (
-	"context"
 	"os"
 	"sync"
 	"testing"
@@ -17,7 +16,7 @@ func TestNewAWSHandler(t *testing.T) {
 	t.Setenv("AWS_ACCESS_KEY_ID", "test")
 	t.Setenv("AWS_SECRET_ACCESS_KEY", "secret")
 
-	handler, err := newAWSHandler(context.Background(), &filterapi.AWSAuth{})
+	handler, err := newAWSHandler(t.Context(), &filterapi.AWSAuth{})
 	require.NoError(t, err)
 	require.NotNil(t, handler)
 }
@@ -37,7 +36,7 @@ func TestAWSHandler_Do(t *testing.T) {
 	require.NoError(t, err)
 	require.NoError(t, file.Sync())
 
-	credentialFileHandler, err := newAWSHandler(context.Background(), &filterapi.AWSAuth{
+	credentialFileHandler, err := newAWSHandler(t.Context(), &filterapi.AWSAuth{
 		CredentialFileName: awsCredentialFile,
 		Region:             "us-east-1",
 	})
@@ -63,7 +62,7 @@ func TestAWSHandler_Do(t *testing.T) {
 					Body: []byte(`{"messages": [{"role": "user", "content": [{"text": "Say this is a test!"}]}]}`),
 				},
 			}
-			err := credentialFileHandler.Do(context.Background(), requestHeaders, headerMut, bodyMut)
+			err := credentialFileHandler.Do(t.Context(), requestHeaders, headerMut, bodyMut)
 			require.NoError(t, err)
 
 			// Ensures that the headers are set.
diff --git a/internal/extproc/processor_test.go b/internal/extproc/processor_test.go
index 23ece77..dbb4174 100644
--- a/internal/extproc/processor_test.go
+++ b/internal/extproc/processor_test.go
@@ -1,7 +1,6 @@
 package extproc
 
 import (
-	"context"
 	"errors"
 	"io"
 	"log/slog"
@@ -19,7 +18,7 @@ import (
 
 func TestProcessor_ProcessRequestHeaders(t *testing.T) {
 	p := &Processor{}
-	res, err := p.ProcessRequestHeaders(context.Background(), &corev3.HeaderMap{
+	res, err := p.ProcessRequestHeaders(t.Context(), &corev3.HeaderMap{
 		Headers: []*corev3.HeaderValue{{Key: "foo", Value: "bar"}},
 	})
 	require.NoError(t, err)
@@ -33,7 +32,7 @@ func TestProcessor_ProcessResponseHeaders(t *testing.T) {
 		mt := &mockTranslator{t: t, expHeaders: make(map[string]string)}
 		p := &Processor{translator: mt}
 		mt.retErr = errors.New("test error")
-		_, err := p.ProcessResponseHeaders(context.Background(), nil)
+		_, err := p.ProcessResponseHeaders(t.Context(), nil)
 		require.ErrorContains(t, err, "test error")
 	})
 	t.Run("ok", func(t *testing.T) {
@@ -43,7 +42,7 @@ func TestProcessor_ProcessResponseHeaders(t *testing.T) {
 		expHeaders := map[string]string{"foo": "bar", "dog": "cat"}
 		mt := &mockTranslator{t: t, expHeaders: expHeaders}
 		p := &Processor{translator: mt}
-		res, err := p.ProcessResponseHeaders(context.Background(), inHeaders)
+		res, err := p.ProcessResponseHeaders(t.Context(), inHeaders)
 		require.NoError(t, err)
 		commonRes := res.Response.(*extprocv3.ProcessingResponse_ResponseHeaders).ResponseHeaders.Response
 		require.Equal(t, mt.retHeaderMutation, commonRes.HeaderMutation)
@@ -55,7 +54,7 @@ func TestProcessor_ProcessResponseBody(t *testing.T) {
 		mt := &mockTranslator{t: t}
 		p := &Processor{translator: mt}
 		mt.retErr = errors.New("test error")
-		_, err := p.ProcessResponseBody(context.Background(), &extprocv3.HttpBody{})
+		_, err := p.ProcessResponseBody(t.Context(), &extprocv3.HttpBody{})
 		require.ErrorContains(t, err, "test error")
 	})
 	t.Run("ok", func(t *testing.T) {
@@ -87,7 +86,7 @@ func TestProcessor_ProcessResponseBody(t *testing.T) {
 				},
 			},
 		}}
-		res, err := p.ProcessResponseBody(context.Background(), inBody)
+		res, err := p.ProcessResponseBody(t.Context(), inBody)
 		require.NoError(t, err)
 		commonRes := res.Response.(*extprocv3.ProcessingResponse_ResponseBody).ResponseBody.Response
 		require.Equal(t, expBodyMut, commonRes.BodyMutation)
@@ -110,7 +109,7 @@ func TestProcessor_ProcessRequestBody(t *testing.T) {
 	t.Run("body parser error", func(t *testing.T) {
 		rbp := mockRequestBodyParser{t: t, retErr: errors.New("test error")}
 		p := &Processor{config: &processorConfig{bodyParser: rbp.impl}}
-		_, err := p.ProcessRequestBody(context.Background(), &extprocv3.HttpBody{})
+		_, err := p.ProcessRequestBody(t.Context(), &extprocv3.HttpBody{})
 		require.ErrorContains(t, err, "failed to parse request body: test error")
 	})
 	t.Run("router error", func(t *testing.T) {
@@ -118,7 +117,7 @@ func TestProcessor_ProcessRequestBody(t *testing.T) {
 		rbp := mockRequestBodyParser{t: t, retModelName: "some-model", expPath: "/foo"}
 		rt := mockRouter{t: t, expHeaders: headers, retErr: errors.New("test error")}
 		p := &Processor{config: &processorConfig{bodyParser: rbp.impl, router: rt}, requestHeaders: headers, logger: slog.Default()}
-		_, err := p.ProcessRequestBody(context.Background(), &extprocv3.HttpBody{})
+		_, err := p.ProcessRequestBody(t.Context(), &extprocv3.HttpBody{})
 		require.ErrorContains(t, err, "failed to calculate route: test error")
 	})
 	t.Run("translator not found", func(t *testing.T) {
@@ -132,7 +131,7 @@ func TestProcessor_ProcessRequestBody(t *testing.T) {
 			bodyParser: rbp.impl, router: rt,
 			factories: make(map[filterapi.VersionedAPISchema]translator.Factory),
 		}, requestHeaders: headers, logger: slog.Default()}
-		_, err := p.ProcessRequestBody(context.Background(), &extprocv3.HttpBody{})
+		_, err := p.ProcessRequestBody(t.Context(), &extprocv3.HttpBody{})
 		require.ErrorContains(t, err, "failed to find factory for output schema {\"some-schema\" \"v10.0\"}")
 	})
 	t.Run("translator factory error", func(t *testing.T) {
@@ -149,7 +148,7 @@ func TestProcessor_ProcessRequestBody(t *testing.T) {
 				{Name: "some-schema", Version: "v10.0"}: factory.impl,
 			},
 		}, requestHeaders: headers, logger: slog.Default()}
-		_, err := p.ProcessRequestBody(context.Background(), &extprocv3.HttpBody{})
+		_, err := p.ProcessRequestBody(t.Context(), &extprocv3.HttpBody{})
 		require.ErrorContains(t, err, "failed to create translator: test error")
 	})
 	t.Run("translator error", func(t *testing.T) {
@@ -166,7 +165,7 @@ func TestProcessor_ProcessRequestBody(t *testing.T) {
 				{Name: "some-schema", Version: "v10.0"}: factory.impl,
 			},
 		}, requestHeaders: headers, logger: slog.Default()}
-		_, err := p.ProcessRequestBody(context.Background(), &extprocv3.HttpBody{})
+		_, err := p.ProcessRequestBody(t.Context(), &extprocv3.HttpBody{})
 		require.ErrorContains(t, err, "failed to transform request: test error")
 	})
 	t.Run("ok", func(t *testing.T) {
@@ -189,7 +188,7 @@ func TestProcessor_ProcessRequestBody(t *testing.T) {
 			selectedBackendHeaderKey: "x-ai-gateway-backend-key",
 			modelNameHeaderKey:       "x-ai-gateway-model-key",
 		}, requestHeaders: headers, logger: slog.Default()}
-		resp, err := p.ProcessRequestBody(context.Background(), &extprocv3.HttpBody{})
+		resp, err := p.ProcessRequestBody(t.Context(), &extprocv3.HttpBody{})
 		require.NoError(t, err)
 		require.Equal(t, mt, p.translator)
 		require.NotNil(t, resp)
diff --git a/internal/extproc/server_test.go b/internal/extproc/server_test.go
index 2e64363..c63209a 100644
--- a/internal/extproc/server_test.go
+++ b/internal/extproc/server_test.go
@@ -30,7 +30,7 @@ func requireNewServerWithMockProcessor(t *testing.T) *Server[*mockProcessor] {
 func TestServer_LoadConfig(t *testing.T) {
 	t.Run("invalid input schema", func(t *testing.T) {
 		s := requireNewServerWithMockProcessor(t)
-		err := s.LoadConfig(context.Background(), &filterapi.Config{
+		err := s.LoadConfig(t.Context(), &filterapi.Config{
 			Schema: filterapi.VersionedAPISchema{Name: "some-invalid-schema"},
 		})
 		require.Error(t, err)
@@ -73,7 +73,7 @@ func TestServer_LoadConfig(t *testing.T) {
 			},
 		}
 		s := requireNewServerWithMockProcessor(t)
-		err := s.LoadConfig(context.Background(), config)
+		err := s.LoadConfig(t.Context(), config)
 		require.NoError(t, err)
 
 		require.NotNil(t, s.config)
@@ -102,7 +102,7 @@ func TestServer_LoadConfig(t *testing.T) {
 func TestServer_Check(t *testing.T) {
 	s := requireNewServerWithMockProcessor(t)
 
-	res, err := s.Check(context.Background(), nil)
+	res, err := s.Check(t.Context(), nil)
 	require.NoError(t, err)
 	require.NotNil(t, res)
 	require.Equal(t, grpc_health_v1.HealthCheckResponse_SERVING, res.Status)
@@ -120,7 +120,7 @@ func TestServer_processMsg(t *testing.T) {
 	t.Run("unknown request type", func(t *testing.T) {
 		s := requireNewServerWithMockProcessor(t)
 		p := s.newProcessor(nil, slog.Default())
-		_, err := s.processMsg(context.Background(), p, &extprocv3.ProcessingRequest{})
+		_, err := s.processMsg(t.Context(), p, &extprocv3.ProcessingRequest{})
 		require.ErrorContains(t, err, "unknown request type")
 	})
 	t.Run("request headers", func(t *testing.T) {
@@ -135,7 +135,7 @@ func TestServer_processMsg(t *testing.T) {
 		req := &extprocv3.ProcessingRequest{
 			Request: &extprocv3.ProcessingRequest_RequestHeaders{RequestHeaders: &extprocv3.HttpHeaders{Headers: hm}},
 		}
-		resp, err := s.processMsg(context.Background(), p, req)
+		resp, err := s.processMsg(t.Context(), p, req)
 		require.NoError(t, err)
 		require.NotNil(t, resp)
 		require.Equal(t, expResponse, resp)
@@ -152,7 +152,7 @@ func TestServer_processMsg(t *testing.T) {
 		req := &extprocv3.ProcessingRequest{
 			Request: &extprocv3.ProcessingRequest_RequestBody{RequestBody: reqBody},
 		}
-		resp, err := s.processMsg(context.Background(), p, req)
+		resp, err := s.processMsg(t.Context(), p, req)
 		require.NoError(t, err)
 		require.NotNil(t, resp)
 		require.Equal(t, expResponse, resp)
@@ -169,7 +169,7 @@ func TestServer_processMsg(t *testing.T) {
 		req := &extprocv3.ProcessingRequest{
 			Request: &extprocv3.ProcessingRequest_ResponseHeaders{ResponseHeaders: &extprocv3.HttpHeaders{Headers: hm}},
 		}
-		resp, err := s.processMsg(context.Background(), p, req)
+		resp, err := s.processMsg(t.Context(), p, req)
 		require.NoError(t, err)
 		require.NotNil(t, resp)
 		require.Equal(t, expResponse, resp)
@@ -186,7 +186,7 @@ func TestServer_processMsg(t *testing.T) {
 		req := &extprocv3.ProcessingRequest{
 			Request: &extprocv3.ProcessingRequest_ResponseHeaders{ResponseHeaders: &extprocv3.HttpHeaders{Headers: hm}},
 		}
-		resp, err := s.processMsg(context.Background(), p, req)
+		resp, err := s.processMsg(t.Context(), p, req)
 		require.NoError(t, err)
 		require.NotNil(t, resp)
 		require.Equal(t, expResponse, resp)
@@ -203,7 +203,7 @@ func TestServer_processMsg(t *testing.T) {
 		req := &extprocv3.ProcessingRequest{
 			Request: &extprocv3.ProcessingRequest_ResponseBody{ResponseBody: reqBody},
 		}
-		resp, err := s.processMsg(context.Background(), p, req)
+		resp, err := s.processMsg(t.Context(), p, req)
 		require.NoError(t, err)
 		require.NotNil(t, resp)
 		require.Equal(t, expResponse, resp)
@@ -213,7 +213,7 @@ func TestServer_processMsg(t *testing.T) {
 func TestServer_Process(t *testing.T) {
 	t.Run("context done", func(t *testing.T) {
 		s := requireNewServerWithMockProcessor(t)
-		ctx, cancel := context.WithCancel(context.Background())
+		ctx, cancel := context.WithCancel(t.Context())
 		cancel()
 
 		ms := &mockExternalProcessingStream{t: t, ctx: ctx}
@@ -222,19 +222,19 @@ func TestServer_Process(t *testing.T) {
 	})
 	t.Run("recv iof", func(t *testing.T) {
 		s := requireNewServerWithMockProcessor(t)
-		ms := &mockExternalProcessingStream{t: t, retErr: io.EOF, ctx: context.Background()}
+		ms := &mockExternalProcessingStream{t: t, retErr: io.EOF, ctx: t.Context()}
 		err := s.Process(ms)
 		require.NoError(t, err)
 	})
 	t.Run("recv canceled", func(t *testing.T) {
 		s := requireNewServerWithMockProcessor(t)
-		ms := &mockExternalProcessingStream{t: t, retErr: status.Error(codes.Canceled, "someerror"), ctx: context.Background()}
+		ms := &mockExternalProcessingStream{t: t, retErr: status.Error(codes.Canceled, "someerror"), ctx: t.Context()}
 		err := s.Process(ms)
 		require.NoError(t, err)
 	})
 	t.Run("recv generic error", func(t *testing.T) {
 		s := requireNewServerWithMockProcessor(t)
-		ms := &mockExternalProcessingStream{t: t, retErr: errors.New("some error"), ctx: context.Background()}
+		ms := &mockExternalProcessingStream{t: t, retErr: errors.New("some error"), ctx: t.Context()}
 		err := s.Process(ms)
 		require.ErrorContains(t, err, "some error")
 	})
@@ -242,7 +242,7 @@ func TestServer_Process(t *testing.T) {
 	t.Run("ok", func(t *testing.T) {
 		s := requireNewServerWithMockProcessor(t)
 
-		ctx, cancel := context.WithTimeout(context.Background(), time.Second)
+		ctx, cancel := context.WithTimeout(t.Context(), time.Second)
 		defer cancel()
 
 		p := s.newProcessor(nil, slog.Default())
diff --git a/internal/extproc/watcher_test.go b/internal/extproc/watcher_test.go
index be66ba5..57b8867 100644
--- a/internal/extproc/watcher_test.go
+++ b/internal/extproc/watcher_test.go
@@ -79,7 +79,7 @@ rules:
     value: gpt4.4444
 `
 	require.NoError(t, os.WriteFile(path, []byte(cfg), 0o600))
-	ctx, cancel := context.WithCancel(context.Background())
+	ctx, cancel := context.WithCancel(t.Context())
 	defer cancel()
 	logger, buf := newTestLoggerWithBuffer()
 	err := StartConfigWatcher(ctx, path, rcv, logger, time.Millisecond*100)
diff --git a/tests/controller/controller_test.go b/tests/controller/controller_test.go
index eb90691..aaacfda 100644
--- a/tests/controller/controller_test.go
+++ b/tests/controller/controller_test.go
@@ -6,7 +6,6 @@
 package controller
 
 import (
-	"context"
 	"fmt"
 	"log/slog"
 	"os"
@@ -53,8 +52,8 @@ func TestStartControllers(t *testing.T) {
 	}
 	l := logr.FromSlogHandler(slog.NewTextHandler(os.Stderr, &slog.HandlerOptions{}))
 	klog.SetLogger(l)
-	ctx, cancel := context.WithDeadline(context.Background(), time.Now().Add(2*time.Minute))
-	defer cancel()
+
+	ctx := t.Context()
 	go func() {
 		err := controller.StartControllers(ctx, cfg, l, opts)
 		require.NoError(t, err)
@@ -341,8 +340,7 @@ func TestAIGatewayRouteController(t *testing.T) {
 	err = ctrl.NewControllerManagedBy(mgr).For(&aigv1a1.AIGatewayRoute{}).Complete(rc)
 	require.NoError(t, err)
 
-	ctx, cancel := context.WithDeadline(context.Background(), time.Now().Add(2*time.Minute))
-	defer cancel()
+	ctx := t.Context()
 	go func() {
 		err := mgr.Start(ctx)
 		require.NoError(t, err)
@@ -439,8 +437,7 @@ func TestAIServiceBackendController(t *testing.T) {
 	err = ctrl.NewControllerManagedBy(mgr).For(&aigv1a1.AIServiceBackend{}).Complete(bc)
 	require.NoError(t, err)
 
-	ctx, cancel := context.WithDeadline(context.Background(), time.Now().Add(2*time.Minute))
-	defer cancel()
+	ctx := t.Context()
 	go func() {
 		err := mgr.Start(ctx)
 		require.NoError(t, err)
@@ -483,8 +480,7 @@ func TestSecretController(t *testing.T) {
 	err = ctrl.NewControllerManagedBy(mgr).For(&corev1.Secret{}).Complete(sc)
 	require.NoError(t, err)
 
-	ctx, cancel := context.WithDeadline(context.Background(), time.Now().Add(2*time.Minute))
-	defer cancel()
+	ctx := t.Context()
 	go func() {
 		err := mgr.Start(ctx)
 		require.NoError(t, err)
diff --git a/tests/crdcel/main_test.go b/tests/crdcel/main_test.go
index a455491..509600e 100644
--- a/tests/crdcel/main_test.go
+++ b/tests/crdcel/main_test.go
@@ -3,11 +3,9 @@
 package celvalidation
 
 import (
-	"context"
 	"embed"
 	"path"
 	"testing"
-	"time"
 
 	"github.com/stretchr/testify/require"
 	"k8s.io/apimachinery/pkg/util/yaml"
@@ -21,8 +19,7 @@ var testdata embed.FS
 
 func TestAIGatewayRoutes(t *testing.T) {
 	c, _, _ := testsinternal.NewEnvTest(t)
-	ctx, cancel := context.WithDeadline(context.Background(), time.Now().Add(30*time.Second))
-	defer cancel()
+	ctx := t.Context()
 
 	for _, tc := range []struct {
 		name   string
@@ -67,9 +64,7 @@ func TestAIGatewayRoutes(t *testing.T) {
 
 func TestAIServiceBackends(t *testing.T) {
 	c, _, _ := testsinternal.NewEnvTest(t)
-
-	ctx, cancel := context.WithDeadline(context.Background(), time.Now().Add(30*time.Second))
-	defer cancel()
+	ctx := t.Context()
 
 	for _, tc := range []struct {
 		name   string
@@ -102,9 +97,7 @@ func TestAIServiceBackends(t *testing.T) {
 
 func TestBackendSecurityPolicies(t *testing.T) {
 	c, _, _ := testsinternal.NewEnvTest(t)
-
-	ctx, cancel := context.WithDeadline(context.Background(), time.Now().Add(30*time.Second))
-	defer cancel()
+	ctx := t.Context()
 
 	for _, tc := range []struct {
 		name   string
diff --git a/tests/e2e/basic_test.go b/tests/e2e/basic_test.go
index fd5ee14..d7cfe04 100644
--- a/tests/e2e/basic_test.go
+++ b/tests/e2e/basic_test.go
@@ -17,11 +17,8 @@ import (
 
 // TestExamplesBasic tests the basic example in examples/basic directory.
 func Test_Examples_Basic(t *testing.T) {
-	ctx, cancel := context.WithTimeout(context.Background(), 3*time.Minute)
-	defer cancel()
-
 	const manifest = "../../examples/basic/basic.yaml"
-	require.NoError(t, kubectlApplyManifest(ctx, manifest))
+	require.NoError(t, kubectlApplyManifest(t.Context(), manifest))
 
 	const egSelector = "gateway.envoyproxy.io/owning-gateway-name=envoy-ai-gateway-basic"
 	requireWaitForPodReady(t, egNamespace, egSelector)
@@ -45,7 +42,7 @@ func Test_Examples_Basic(t *testing.T) {
 		replaced := strings.ReplaceAll(string(read), "OPENAI_API_KEY", cmp.Or(openAiApiKey, "dummy-openai-api-key"))
 		replaced = strings.ReplaceAll(replaced, "AWS_ACCESS_KEY_ID", cmp.Or(awsAccessKeyID, "dummy-aws-access-key-id"))
 		replaced = strings.ReplaceAll(replaced, "AWS_SECRET_ACCESS_KEY", cmp.Or(awsSecretAccessKey, "dummy-aws-secret-access-key"))
-		require.NoError(t, kubectlApplyManifestStdin(ctx, replaced))
+		require.NoError(t, kubectlApplyManifestStdin(t.Context(), replaced))
 
 		time.Sleep(5 * time.Second) // At least 5 seconds for the updated secret to be propagated.
 
diff --git a/tests/e2e/token_ratelimit_test.go b/tests/e2e/token_ratelimit_test.go
index 9e917ed..8f7f8be 100644
--- a/tests/e2e/token_ratelimit_test.go
+++ b/tests/e2e/token_ratelimit_test.go
@@ -3,7 +3,6 @@
 package e2e
 
 import (
-	"context"
 	"encoding/base64"
 	"encoding/json"
 	"fmt"
@@ -21,11 +20,8 @@ import (
 )
 
 func Test_Examples_TokenRateLimit(t *testing.T) {
-	ctx, cancel := context.WithTimeout(context.Background(), 3*time.Minute)
-	defer cancel()
-
 	const manifest = "../../examples/token_ratelimit/token_ratelimit.yaml"
-	require.NoError(t, kubectlApplyManifest(ctx, manifest))
+	require.NoError(t, kubectlApplyManifest(t.Context(), manifest))
 
 	const egSelector = "gateway.envoyproxy.io/owning-gateway-name=envoy-ai-gateway-token-ratelimit"
 	requireWaitForPodReady(t, egNamespace, egSelector)
diff --git a/tests/e2e/translation_testupstream_test.go b/tests/e2e/translation_testupstream_test.go
index cc73e61..f7a4ec3 100644
--- a/tests/e2e/translation_testupstream_test.go
+++ b/tests/e2e/translation_testupstream_test.go
@@ -17,11 +17,8 @@ import (
 
 // TestTranslationWithTestUpstream tests the translation with the test upstream.
 func TestTranslationWithTestUpstream(t *testing.T) {
-	ctx, cancel := context.WithTimeout(context.Background(), 3*time.Minute)
-	defer cancel()
-
 	const manifest = "testdata/translation_testupstream.yaml"
-	require.NoError(t, kubectlApplyManifest(ctx, manifest))
+	require.NoError(t, kubectlApplyManifest(t.Context(), manifest))
 
 	const egSelector = "gateway.envoyproxy.io/owning-gateway-name=translation-testupstream"
 	requireWaitForPodReady(t, egNamespace, egSelector)
@@ -57,7 +54,7 @@ func TestTranslationWithTestUpstream(t *testing.T) {
 					fwd := requireNewHTTPPortForwarder(t, egNamespace, egSelector, egDefaultPort)
 					defer fwd.kill()
 
-					ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
+					ctx, cancel := context.WithTimeout(t.Context(), 10*time.Second)
 					defer cancel()
 
 					t.Logf("modelName: %s", tc.modelName)
diff --git a/tests/extproc/custom_extproc_test.go b/tests/extproc/custom_extproc_test.go
index b86ef2e..29b8db8 100644
--- a/tests/extproc/custom_extproc_test.go
+++ b/tests/extproc/custom_extproc_test.go
@@ -3,7 +3,6 @@
 package extproc
 
 import (
-	"context"
 	"encoding/base64"
 	"fmt"
 	"os"
@@ -53,7 +52,7 @@ func TestExtProcCustomRouter(t *testing.T) {
 			option.WithHeader(testupstreamlib.ResponseBodyHeaderKey,
 				base64.StdEncoding.EncodeToString([]byte(`{"choices":[{"message":{"content":"This is a test."}}]}`)),
 			))
-		chatCompletion, err := client.Chat.Completions.New(context.Background(), openai.ChatCompletionNewParams{
+		chatCompletion, err := client.Chat.Completions.New(t.Context(), openai.ChatCompletionNewParams{
 			Messages: openai.F([]openai.ChatCompletionMessageParamUnion{
 				openai.UserMessage("Say this is a test"),
 			}),
diff --git a/tests/extproc/extproc_test.go b/tests/extproc/extproc_test.go
index 47b9a34..c19b9be 100644
--- a/tests/extproc/extproc_test.go
+++ b/tests/extproc/extproc_test.go
@@ -34,23 +34,21 @@ var (
 //
 // The config must be in YAML format specified in [filterapi.Config] type.
 func requireExtProc(t *testing.T, stdout io.Writer, executable, configPath string, envs ...string) {
-	cmd := exec.Command(executable)
+	cmd := exec.CommandContext(t.Context(), executable)
 	cmd.Stdout = stdout
 	cmd.Stderr = os.Stderr
 	cmd.Args = append(cmd.Args, "-configPath", configPath)
 	cmd.Env = append(os.Environ(), envs...)
 	require.NoError(t, cmd.Start())
-	t.Cleanup(func() { _ = cmd.Process.Signal(os.Interrupt) })
 }
 
 func requireTestUpstream(t *testing.T) {
 	// Starts the Envoy proxy.
-	cmd := exec.Command(testUpstreamExecutablePath()) // #nosec G204
+	cmd := exec.CommandContext(t.Context(), testUpstreamExecutablePath()) // #nosec G204
 	cmd.Stdout = os.Stdout
 	cmd.Stderr = os.Stderr
 	cmd.Env = []string{"TESTUPSTREAM_ID=extproc_test"}
 	require.NoError(t, cmd.Start())
-	t.Cleanup(func() { _ = cmd.Process.Kill() })
 }
 
 // requireRunEnvoy starts the Envoy proxy with the provided configuration.
@@ -63,7 +61,7 @@ func requireRunEnvoy(t *testing.T, accessLogPath string) {
 	require.NoError(t, os.WriteFile(envoyYamlPath, []byte(envoyYaml), 0o600))
 
 	// Starts the Envoy proxy.
-	cmd := exec.Command("envoy",
+	cmd := exec.CommandContext(t.Context(), "envoy",
 		"-c", envoyYamlPath,
 		"--log-level", "warn",
 		"--concurrency", strconv.Itoa(max(runtime.NumCPU(), 2)),
@@ -71,7 +69,6 @@ func requireRunEnvoy(t *testing.T, accessLogPath string) {
 	cmd.Stdout = os.Stdout
 	cmd.Stderr = os.Stderr
 	require.NoError(t, cmd.Start())
-	t.Cleanup(func() { _ = cmd.Process.Kill() })
 }
 
 // requireBinaries requires Envoy to be present in the PATH as well as the Extproc and testuptream binaries in the out directory.
diff --git a/tests/extproc/real_providers_test.go b/tests/extproc/real_providers_test.go
index 19b69cd..73a5666 100644
--- a/tests/extproc/real_providers_test.go
+++ b/tests/extproc/real_providers_test.go
@@ -6,7 +6,6 @@ import (
 	"bufio"
 	"bytes"
 	"cmp"
-	"context"
 	"encoding/json"
 	"fmt"
 	"os"
@@ -72,7 +71,7 @@ func TestWithRealProviders(t *testing.T) {
 			t.Run(tc.modelName, func(t *testing.T) {
 				cc.maybeSkip(t, tc.required)
 				require.Eventually(t, func() bool {
-					chatCompletion, err := client.Chat.Completions.New(context.Background(), openai.ChatCompletionNewParams{
+					chatCompletion, err := client.Chat.Completions.New(t.Context(), openai.ChatCompletionNewParams{
 						Messages: openai.F([]openai.ChatCompletionMessageParamUnion{
 							openai.UserMessage("Say this is a test"),
 						}),
@@ -140,7 +139,7 @@ func TestWithRealProviders(t *testing.T) {
 			t.Run(tc.name, func(t *testing.T) {
 				cc.maybeSkip(t, tc.required)
 				require.Eventually(t, func() bool {
-					stream := client.Chat.Completions.NewStreaming(context.Background(), openai.ChatCompletionNewParams{
+					stream := client.Chat.Completions.NewStreaming(t.Context(), openai.ChatCompletionNewParams{
 						Messages: openai.F([]openai.ChatCompletionMessageParamUnion{
 							openai.UserMessage("Say this is a test"),
 						}),
@@ -186,7 +185,7 @@ func TestWithRealProviders(t *testing.T) {
 		cc.maybeSkip(t, requiredCredentialAWS)
 		client := openai.NewClient(option.WithBaseURL(listenerAddress + "/v1/"))
 		require.Eventually(t, func() bool {
-			chatCompletion, err := client.Chat.Completions.New(context.Background(), openai.ChatCompletionNewParams{
+			chatCompletion, err := client.Chat.Completions.New(t.Context(), openai.ChatCompletionNewParams{
 				Messages: openai.F([]openai.ChatCompletionMessageParamUnion{
 					openai.UserMessage("What is the weather like in Paris today?"),
 				}),