From 8b87665f235b84ac9c3795970d51c2ca898ffe00 Mon Sep 17 00:00:00 2001 From: Toshiki Sonoda Date: Wed, 7 Dec 2022 16:30:32 +0900 Subject: [PATCH] e2e: keeps the http_proxy value In a proxy environment, http_proxy needs to keep the value to use a proxy. Signed-off-by: Toshiki Sonoda --- test/e2e/build_test.go | 6 +++++- test/e2e/run_env_test.go | 7 +++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/test/e2e/build_test.go b/test/e2e/build_test.go index f6dbb69871a2..b6c89653d765 100644 --- a/test/e2e/build_test.go +++ b/test/e2e/build_test.go @@ -300,6 +300,11 @@ var _ = Describe("Podman build", func() { }) It("podman build --http_proxy flag", func() { + if env, found := os.LookupEnv("http_proxy"); found { + defer os.Setenv("http_proxy", env) + } else { + defer os.Unsetenv("http_proxy") + } os.Setenv("http_proxy", "1.2.3.4") if IsRemote() { podmanTest.StopRemoteService() @@ -316,7 +321,6 @@ RUN printenv http_proxy`, ALPINE) session.Wait(120) Expect(session).Should(Exit(0)) Expect(session.OutputToString()).To(ContainSubstring("1.2.3.4")) - os.Unsetenv("http_proxy") }) It("podman build relay exit code to process", func() { diff --git a/test/e2e/run_env_test.go b/test/e2e/run_env_test.go index 2b2d67f5727f..68a89fe04aac 100644 --- a/test/e2e/run_env_test.go +++ b/test/e2e/run_env_test.go @@ -121,6 +121,11 @@ ENV hello=world }) It("podman run --http-proxy test", func() { + if env, found := os.LookupEnv("http_proxy"); found { + defer os.Setenv("http_proxy", env) + } else { + defer os.Unsetenv("http_proxy") + } os.Setenv("http_proxy", "1.2.3.4") if IsRemote() { podmanTest.StopRemoteService() @@ -140,12 +145,10 @@ ENV hello=world session.WaitWithDefaultTimeout() Expect(session).Should(Exit(0)) Expect(session.OutputToString()).To(ContainSubstring("5.6.7.8")) - os.Unsetenv("http_proxy") session = podmanTest.Podman([]string{"run", "--http-proxy=false", "--env", "http_proxy=5.6.7.8", ALPINE, "printenv", "http_proxy"}) session.WaitWithDefaultTimeout() Expect(session).Should(Exit(0)) Expect(session.OutputToString()).To(ContainSubstring("5.6.7.8")) - os.Unsetenv("http_proxy") }) })