fix some flaky snapshot tests (#8015)

This commit is contained in:
R.B. Boyer 2020-06-03 14:18:52 -05:00 committed by GitHub
parent 1cc5a2445d
commit b68045e594
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 0 deletions

View File

@ -15,6 +15,7 @@ import (
"github.com/hashicorp/consul/api" "github.com/hashicorp/consul/api"
"github.com/hashicorp/consul/lib" "github.com/hashicorp/consul/lib"
"github.com/hashicorp/consul/sdk/testutil" "github.com/hashicorp/consul/sdk/testutil"
"github.com/hashicorp/consul/sdk/testutil/retry"
"github.com/mitchellh/cli" "github.com/mitchellh/cli"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
) )
@ -151,6 +152,13 @@ func TestSnapshotSaveCommand_TruncatedStream(t *testing.T) {
_, _ = w.Write(data) _, _ = w.Write(data)
})) }))
// Wait until the server is actually listening.
retry.Run(t, func(r *retry.R) {
resp, err := http.Get("http://" + fakeAddr + "/not-real")
require.NoError(r, err)
require.Equal(r, http.StatusNotFound, resp.StatusCode)
})
dir := testutil.TempDir(t, "snapshot") dir := testutil.TempDir(t, "snapshot")
defer os.RemoveAll(dir) defer os.RemoveAll(dir)