Reduce flakiness of TestClosePreviousProxies

This commit is contained in:
MoofMonkey 2022-10-13 19:32:53 +03:00
parent f1aa0012f0
commit e7e3cb42b4
1 changed files with 4 additions and 5 deletions

View File

@ -5,7 +5,6 @@ import (
"encoding/json" "encoding/json"
"fmt" "fmt"
"io" "io"
"io/ioutil"
"net" "net"
"net/http" "net/http"
"net/http/httptest" "net/http/httptest"
@ -282,7 +281,7 @@ func TestConcurrentUpdateAndRead(t *testing.T) {
switch resp.StatusCode { switch resp.StatusCode {
// v1 proxy, warp enabled // v1 proxy, warp enabled
case 200: case 200:
body, err := ioutil.ReadAll(resp.Body) body, err := io.ReadAll(resp.Body)
require.NoError(t, err) require.NoError(t, err)
require.Equal(t, t.Name(), string(body)) require.Equal(t, t.Name(), string(body))
warpRoutingDisabled = false warpRoutingDisabled = false
@ -504,7 +503,7 @@ func TestClosePreviousProxies(t *testing.T) {
require.Equal(t, http.StatusTeapot, resp.StatusCode) require.Equal(t, http.StatusTeapot, resp.StatusCode)
// The hello-world server in config v1 should have been stopped. We wait a bit since it's closed asynchronously. // The hello-world server in config v1 should have been stopped. We wait a bit since it's closed asynchronously.
time.Sleep(time.Millisecond * 10) time.Sleep(time.Millisecond * 300)
resp, err = proxyHTTP(originProxyV1, hostname) resp, err = proxyHTTP(originProxyV1, hostname)
require.Error(t, err) require.Error(t, err)
require.Nil(t, resp) require.Nil(t, resp)
@ -522,8 +521,8 @@ func TestClosePreviousProxies(t *testing.T) {
// cancel the context should terminate the last proxy // cancel the context should terminate the last proxy
cancel() cancel()
// Wait for proxies to shutdown // Wait for proxies to shut down
time.Sleep(time.Millisecond * 10) time.Sleep(time.Millisecond * 300)
resp, err = proxyHTTP(originProxyV3, hostname) resp, err = proxyHTTP(originProxyV3, hostname)
require.Error(t, err) require.Error(t, err)