e2e: fix run_staticip_test about no_proxy

http.Get() could not recognize no_proxy with "ginkgo -nodes <any>".
Therefore, we set http.Client not to use a proxy instead of os.Setenv().

Fixes #17135

Signed-off-by: Toshiki Sonoda <sonoda.toshiki@fujitsu.com>
This commit is contained in:
Toshiki Sonoda
2023-01-31 16:55:11 +09:00
parent 56b9476304
commit 9272cabd38

View File

@ -105,15 +105,15 @@ var _ = Describe("Podman run with --ip flag", func() {
result.WaitWithDefaultTimeout()
Expect(result).Should(Exit(0))
// We need to set "no_proxy" in proxy environment
if env, found := os.LookupEnv("no_proxy"); found {
defer os.Setenv("no_proxy", env)
} else {
defer os.Unsetenv("no_proxy")
// This test should not use a proxy
client := &http.Client{
Transport: &http.Transport{
Proxy: nil,
},
}
os.Setenv("no_proxy", ip)
for retries := 20; retries > 0; retries-- {
response, err := http.Get(fmt.Sprintf("http://%s", ip))
response, err := client.Get(fmt.Sprintf("http://%s", ip))
if err == nil && response.StatusCode == http.StatusOK {
break
}