Repository: envoyproxy/gateway

Issue:
use MakeRequestAndExpectEventuallyConsistentResponse instead
```golang
req = http.MakeRequest(t, &expectedResponse, gwAddr, "http", "http")

			http.AwaitConvergence(t, threshold, timeout, func(elapsed time.Duration) bool {
				cReq, cRes, err := suite.RoundTripper.CaptureRoundTrip(req)
				if err != nil {
					tlog.Logf(t, "Request failed, not ready yet: %v (after %v)", err.Error(), elapsed)
					return false
				}
				if err := http.CompareRoundTrip(t, &req, cReq, cRes, expectedResponse); err != nil {
					tlog.Logf(t, "Response expectation failed for request: %+v  not ready yet: %v (after %v)", req, err, elapsed)
					return false
				}
				return true
			})
```

Discussion:
@ADITYATIWARI342005: Hey @zirain 
I would like for you to elaborate the context a bit, e.g. the file/folder where these changes are supposed to be made.

Feel free to assign it to me.
Thank you.@zirain: @ADITYATIWARI342005 most of them are under `test/`, in short we should use `http.MakeRequestAndExpectEventuallyConsistentResponse` instead of the custom logic.@ADITYATIWARI342005: Thanks for the information, I will start working on it, and raise a PR soon.
@zirain: @ADITYATIWARI342005 thanks for taking this.@ADITYATIWARI342005: @zirain 
the PR is ready for review, please do mention if there are any other files that need refactoring( if I missed any).

Thank you.@ADITYATIWARI342005: @zirain @arkodg 
I had a query.
There are some build CI checks that are constantly failing on every pull request for the repository.
If you allow me, I would like to fix them (if I am able to), because I think they are false positives that often hide actual concerning failing checks.@zirain: @ADITYATIWARI342005 there's should be some flake tests(some of them tracked by seperated issues)

If all the e2e tests fail, then you must have done something wrong. Otherwise, you can re-run it using '/retest'.

Solution patch:
diff --git a/tools/docker/envoy-gateway/Dockerfile b/tools/docker/envoy-gateway/Dockerfile
index 70ff2e963..e8dc0313b 100644
--- a/tools/docker/envoy-gateway/Dockerfile
+++ b/tools/docker/envoy-gateway/Dockerfile
@@ -1,4 +1,4 @@
-FROM busybox@sha256:d82f458899c9696cb26a7c02d5568f81c8c8223f8661bb2a7988b269c8b9051e AS source
+FROM busybox@sha256:2f590fc602ce325cbff2ccfc39499014d039546dc400ef8bbf5c6ffb860632e7 AS source
 # Create the data directory for eg
 RUN mkdir -p /var/lib/eg && chmod -R 0777 /var/lib/eg
 



Test patch:
diff --git a/test/resilience/tests/envoygateway.go b/test/resilience/tests/envoygateway.go
index eab6e2f07..43f6f4919 100644
--- a/test/resilience/tests/envoygateway.go
+++ b/test/resilience/tests/envoygateway.go
@@ -19,7 +19,6 @@ import (
 	gwapiv1 "sigs.k8s.io/gateway-api/apis/v1"
 	"sigs.k8s.io/gateway-api/conformance/utils/http"
 	"sigs.k8s.io/gateway-api/conformance/utils/kubernetes"
-	"sigs.k8s.io/gateway-api/conformance/utils/tlog"
 
 	"github.com/envoyproxy/gateway/test/resilience/suite"
 )
@@ -51,6 +50,11 @@ var EGResilience = suite.ResilienceTest{
 		}
 		ap.MustApplyWithCleanup(t, suite.Client, suite.TimeoutConfig, "testdata/base.yaml", true)
 
+		// Preserve original convergence semantics for resilience tests
+		localTimeout := suite.TimeoutConfig
+		localTimeout.RequiredConsecutiveSuccesses = threshold
+		localTimeout.MaxTimeToConsistency = timeout
+
 		// this test will fail until https://github.com/envoyproxy/gateway/pull/4767/files is merged
 		t.Run("Secondary EnvoyGateway instances can serve an up to date xDS", func(t *testing.T) {
 			ctx := context.Background()
@@ -107,20 +111,7 @@ var EGResilience = suite.ResilienceTest{
 				Namespace: ns,
 			}
 
-			req := http.MakeRequest(t, &expectedResponse, gwAddr, "http", "http")
-			http.AwaitConvergence(t, threshold, timeout, func(elapsed time.Duration) bool {
-				cReq, cRes, err := suite.RoundTripper.CaptureRoundTrip(req)
-				if err != nil {
-					tlog.Logf(t, "Request failed, not ready yet: %v (after %v)", err.Error(), elapsed)
-					return false
-				}
-
-				if err := http.CompareRoundTrip(t, &req, cReq, cRes, expectedResponse); err != nil {
-					tlog.Logf(t, "Response expectation failed for request: %+v  not ready yet: %v (after %v)", req, err, elapsed)
-					return false
-				}
-				return true
-			})
+			http.MakeRequestAndExpectEventuallyConsistentResponse(t, suite.RoundTripper, localTimeout, gwAddr, expectedResponse)
 		})
 
 		t.Run("EnvoyGateway reconciles missed resources and sync xDS after api server connectivity is restored", func(t *testing.T) {
@@ -166,20 +157,7 @@ var EGResilience = suite.ResilienceTest{
 				Namespace: ns,
 			}
 
-			req := http.MakeRequest(t, &expectedResponse, gwAddr, "http", "http")
-			http.AwaitConvergence(t, threshold, time.Minute, func(elapsed time.Duration) bool {
-				cReq, cRes, err := suite.RoundTripper.CaptureRoundTrip(req)
-				if err != nil {
-					tlog.Logf(t, "Request failed, not ready yet: %v (after %v)", err.Error(), elapsed)
-					return false
-				}
-
-				if err := http.CompareRoundTrip(t, &req, cReq, cRes, expectedResponse); err != nil {
-					tlog.Logf(t, "Response expectation failed for request: %+v  not ready yet: %v (after %v)", req, err, elapsed)
-					return false
-				}
-				return true
-			})
+			http.MakeRequestAndExpectEventuallyConsistentResponse(t, suite.RoundTripper, localTimeout, gwAddr, expectedResponse)
 
 			require.NoError(t, err, "Failed during connectivity checkup")
 		})
@@ -237,21 +215,7 @@ var EGResilience = suite.ResilienceTest{
 				Namespace: ns,
 			}
 
-			req := http.MakeRequest(t, &expectedResponse, gwAddr, "http", "http")
-
-			http.AwaitConvergence(t, threshold, timeout, func(elapsed time.Duration) bool {
-				cReq, cRes, err := suite.RoundTripper.CaptureRoundTrip(req)
-				if err != nil {
-					tlog.Logf(t, "Request failed, not ready yet: %v (after %v)", err.Error(), elapsed)
-					return false
-				}
-
-				if err := http.CompareRoundTrip(t, &req, cReq, cRes, expectedResponse); err != nil {
-					tlog.Logf(t, "Response expectation failed for request: %+v  not ready yet: %v (after %v)", req, err, elapsed)
-					return false
-				}
-				return true
-			})
+			http.MakeRequestAndExpectEventuallyConsistentResponse(t, suite.RoundTripper, localTimeout, gwAddr, expectedResponse)
 		})
 	},
 }
diff --git a/test/resilience/tests/envoyproxy.go b/test/resilience/tests/envoyproxy.go
index a7c408c41..5e0b47fbb 100644
--- a/test/resilience/tests/envoyproxy.go
+++ b/test/resilience/tests/envoyproxy.go
@@ -17,7 +17,6 @@ import (
 	gwapiv1 "sigs.k8s.io/gateway-api/apis/v1"
 	"sigs.k8s.io/gateway-api/conformance/utils/http"
 	"sigs.k8s.io/gateway-api/conformance/utils/kubernetes"
-	"sigs.k8s.io/gateway-api/conformance/utils/tlog"
 
 	"github.com/envoyproxy/gateway/test/resilience/suite"
 )
@@ -40,6 +39,11 @@ var EPResilience = suite.ResilienceTest{
 
 		ap.MustApplyWithCleanup(t, suite.Client, suite.TimeoutConfig, "testdata/base.yaml", true)
 
+		// Preserve original convergence semantics for resilience tests
+		localTimeout := suite.TimeoutConfig
+		localTimeout.RequiredConsecutiveSuccesses = 2
+		localTimeout.MaxTimeToConsistency = time.Minute
+
 		t.Run("Envoy proxies continue to work even when eg is offline", func(t *testing.T) {
 			ctx := context.Background()
 
@@ -77,19 +81,7 @@ var EPResilience = suite.ResilienceTest{
 				Namespace: ns,
 			}
 
-			req := http.MakeRequest(t, &expectedResponse, gwAddr, "http", "http")
-			http.AwaitConvergence(t, threshold, timeout, func(elapsed time.Duration) bool {
-				cReq, cRes, err := suite.RoundTripper.CaptureRoundTrip(req)
-				if err != nil {
-					tlog.Logf(t, "Request failed, not ready yet: %v (after %v)", err.Error(), elapsed)
-					return false
-				}
-				if err := http.CompareRoundTrip(t, &req, cReq, cRes, expectedResponse); err != nil {
-					tlog.Logf(t, "Response expectation failed for request: %+v  not ready yet: %v (after %v)", req, err, elapsed)
-					return false
-				}
-				return true
-			})
+			http.MakeRequestAndExpectEventuallyConsistentResponse(t, suite.RoundTripper, localTimeout, gwAddr, expectedResponse)
 		})
 	},
 }
diff --git a/test/resilience/tests/extensionserver.go b/test/resilience/tests/extensionserver.go
index e396635da..ac4923033 100644
--- a/test/resilience/tests/extensionserver.go
+++ b/test/resilience/tests/extensionserver.go
@@ -47,6 +47,11 @@ var ESResilience = suite.ResilienceTest{
 
 		ap.MustApplyWithCleanup(t, suite.Client, suite.TimeoutConfig, "testdata/base.yaml", true)
 
+		// Preserve original convergence semantics for resilience tests
+		localTimeout := suite.TimeoutConfig
+		localTimeout.RequiredConsecutiveSuccesses = 2
+		localTimeout.MaxTimeToConsistency = time.Minute
+
 		ap.MustApplyWithCleanup(t, suite.Client, suite.TimeoutConfig, "testdata/route_for_extension_manager.yaml", true)
 
 		t.Run("Verify Snapshot Preservation after XDS translation error", func(t *testing.T) {
@@ -69,19 +74,7 @@ var ESResilience = suite.ResilienceTest{
 				Namespace: ns,
 			}
 
-			req := http.MakeRequest(t, &expectedResponse, gwAddr, "http", "http")
-			http.AwaitConvergence(t, threshold, timeout, func(elapsed time.Duration) bool {
-				cReq, cRes, err := suite.RoundTripper.CaptureRoundTrip(req)
-				if err != nil {
-					tlog.Logf(t, "Request failed, not ready yet: %v (after %v)", err.Error(), elapsed)
-					return false
-				}
-				if err := http.CompareRoundTrip(t, &req, cReq, cRes, expectedResponse); err != nil {
-					tlog.Logf(t, "Response expectation failed for request: %+v  not ready yet: %v (after %v)", req, err, elapsed)
-					return false
-				}
-				return true
-			})
+			http.MakeRequestAndExpectEventuallyConsistentResponse(t, suite.RoundTripper, localTimeout, gwAddr, expectedResponse)
 
 			t.Log("Check Route is modified by extension server")
 			// ensure the extension server is connected and mutating resources
@@ -96,19 +89,7 @@ var ESResilience = suite.ResilienceTest{
 				Namespace: ns,
 			}
 
-			req = http.MakeRequest(t, &expectedResponse, gwAddr, "http", "http")
-			http.AwaitConvergence(t, threshold, timeout, func(elapsed time.Duration) bool {
-				cReq, cRes, err := suite.RoundTripper.CaptureRoundTrip(req)
-				if err != nil {
-					tlog.Logf(t, "Request failed, not ready yet: %v (after %v)", err.Error(), elapsed)
-					return false
-				}
-				if err := http.CompareRoundTrip(t, &req, cReq, cRes, expectedResponse); err != nil {
-					tlog.Logf(t, "Response expectation failed for request: %+v  not ready yet: %v (after %v)", req, err, elapsed)
-					return false
-				}
-				return true
-			})
+			http.MakeRequestAndExpectEventuallyConsistentResponse(t, suite.RoundTripper, localTimeout, gwAddr, expectedResponse)
 
 			t.Log("Getting current error translation count")
 			translatorErrors, err := waitForMetricValueVerification(t, suite, PrometheusXDSTranslatorErrors, func(actual float64) bool {
@@ -138,19 +119,7 @@ var ESResilience = suite.ResilienceTest{
 			require.NoError(t, err, "Failed to scale deployment replicas")
 
 			// confirm that the old (pre-error) cache is preserved
-			req = http.MakeRequest(t, &expectedResponse, gwAddr, "http", "http")
-			http.AwaitConvergence(t, threshold, timeout, func(elapsed time.Duration) bool {
-				cReq, cRes, err := suite.RoundTripper.CaptureRoundTrip(req)
-				if err != nil {
-					tlog.Logf(t, "Request failed, not ready yet: %v (after %v)", err.Error(), elapsed)
-					return false
-				}
-				if err := http.CompareRoundTrip(t, &req, cReq, cRes, expectedResponse); err != nil {
-					tlog.Logf(t, "Response expectation failed for request: %+v  not ready yet: %v (after %v)", req, err, elapsed)
-					return false
-				}
-				return true
-			})
+			http.MakeRequestAndExpectEventuallyConsistentResponse(t, suite.RoundTripper, localTimeout, gwAddr, expectedResponse)
 
 			t.Log("Deleting control plane cache and confirming proxy cache is still preserved")
 			t.Log("Scaling down control plane")
@@ -174,19 +143,7 @@ var ESResilience = suite.ResilienceTest{
 			require.NoError(t, err, "Failed to capture envoy connection to control plane")
 
 			t.Log("Checking proxy cache is still preserved when connected to control plane with no snapshot")
-			req = http.MakeRequest(t, &expectedResponse, gwAddr, "http", "http")
-			http.AwaitConvergence(t, threshold, timeout, func(elapsed time.Duration) bool {
-				cReq, cRes, err := suite.RoundTripper.CaptureRoundTrip(req)
-				if err != nil {
-					tlog.Logf(t, "Request failed, not ready yet: %v (after %v)", err.Error(), elapsed)
-					return false
-				}
-				if err := http.CompareRoundTrip(t, &req, cReq, cRes, expectedResponse); err != nil {
-					tlog.Logf(t, "Response expectation failed for request: %+v  not ready yet: %v (after %v)", req, err, elapsed)
-					return false
-				}
-				return true
-			})
+			http.MakeRequestAndExpectEventuallyConsistentResponse(t, suite.RoundTripper, localTimeout, gwAddr, expectedResponse)
 
 			t.Log("Fixing translation error by changing the failing route")
 			ap.MustApplyWithCleanup(t, suite.Client, suite.TimeoutConfig, "testdata/route_fail_extension_manager_update.yaml", true)
@@ -203,20 +160,7 @@ var ESResilience = suite.ResilienceTest{
 				Namespace: ns,
 			}
 
-			req = http.MakeRequest(t, &expectedResponse, gwAddr, "http", "http")
-
-			http.AwaitConvergence(t, threshold, timeout, func(elapsed time.Duration) bool {
-				cReq, cRes, err := suite.RoundTripper.CaptureRoundTrip(req)
-				if err != nil {
-					tlog.Logf(t, "Request failed, not ready yet: %v (after %v)", err.Error(), elapsed)
-					return false
-				}
-				if err := http.CompareRoundTrip(t, &req, cReq, cRes, expectedResponse); err != nil {
-					tlog.Logf(t, "Response expectation failed for request: %+v  not ready yet: %v (after %v)", req, err, elapsed)
-					return false
-				}
-				return true
-			})
+			http.MakeRequestAndExpectEventuallyConsistentResponse(t, suite.RoundTripper, localTimeout, gwAddr, expectedResponse)
 		})
 	},
 }