diff --git a/command/snapshot/save/snapshot_save_test.go b/command/snapshot/save/snapshot_save_test.go index 705402c853..c7c5331f95 100644 --- a/command/snapshot/save/snapshot_save_test.go +++ b/command/snapshot/save/snapshot_save_test.go @@ -15,6 +15,7 @@ import ( "github.com/hashicorp/consul/api" "github.com/hashicorp/consul/lib" "github.com/hashicorp/consul/sdk/testutil" + "github.com/hashicorp/consul/sdk/testutil/retry" "github.com/mitchellh/cli" "github.com/stretchr/testify/require" ) @@ -151,6 +152,13 @@ func TestSnapshotSaveCommand_TruncatedStream(t *testing.T) { _, _ = 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") defer os.RemoveAll(dir)