From ab8ae219f4c7ee4f4b8abe91bf5416fc15424987 Mon Sep 17 00:00:00 2001 From: Dirkjan Bussink Date: Thu, 25 Jan 2024 14:51:46 +0100 Subject: [PATCH] Move test files to regular names again (#15037) --- ...aky_test.go => auth_server_static_test.go} | 0 go/mysql/{conn_flaky_test.go => conn_test.go} | 0 .../{server_flaky_test.go => server_test.go} | 24 +++++++------------ ...eamlog_flaky_test.go => streamlog_test.go} | 0 ...icker_flaky_test.go => randticker_test.go} | 0 go/timer/suspendable_ticker_test.go | 2 +- .../{timer_flaky_test.go => timer_test.go} | 0 .../{client_flaky_test.go => client_test.go} | 0 ...{logutil_flaky_test.go => logutil_test.go} | 0 9 files changed, 9 insertions(+), 17 deletions(-) rename go/mysql/{auth_server_static_flaky_test.go => auth_server_static_test.go} (100%) rename go/mysql/{conn_flaky_test.go => conn_test.go} (100%) rename go/mysql/{server_flaky_test.go => server_test.go} (98%) rename go/streamlog/{streamlog_flaky_test.go => streamlog_test.go} (100%) rename go/timer/{randticker_flaky_test.go => randticker_test.go} (100%) rename go/timer/{timer_flaky_test.go => timer_test.go} (100%) rename go/vt/grpcclient/{client_flaky_test.go => client_test.go} (100%) rename go/vt/logutil/{logutil_flaky_test.go => logutil_test.go} (100%) diff --git a/go/mysql/auth_server_static_flaky_test.go b/go/mysql/auth_server_static_test.go similarity index 100% rename from go/mysql/auth_server_static_flaky_test.go rename to go/mysql/auth_server_static_test.go diff --git a/go/mysql/conn_flaky_test.go b/go/mysql/conn_test.go similarity index 100% rename from go/mysql/conn_flaky_test.go rename to go/mysql/conn_test.go diff --git a/go/mysql/server_flaky_test.go b/go/mysql/server_test.go similarity index 98% rename from go/mysql/server_flaky_test.go rename to go/mysql/server_test.go index c7b40ddcf8e..1b6e11b74aa 100644 --- a/go/mysql/server_flaky_test.go +++ b/go/mysql/server_test.go @@ -478,11 +478,6 @@ func TestClientFoundRows(t *testing.T) { func TestConnCounts(t *testing.T) { th := &testHandler{} - initialNumUsers := len(connCountPerUser.Counts()) - - // FIXME: we should be able to ResetAll counters instead of computing a delta, but it doesn't work for some reason - // connCountPerUser.ResetAll() - user := "anotherNotYetConnectedUser1" passwd := "password1" @@ -510,29 +505,26 @@ func TestConnCounts(t *testing.T) { c, err := Connect(context.Background(), params) require.NoError(t, err, "Connect failed") - connCounts := connCountPerUser.Counts() - assert.Equal(t, 1, len(connCounts)-initialNumUsers) checkCountsForUser(t, user, 1) // Test with a second new connection. c2, err := Connect(context.Background(), params) require.NoError(t, err) - connCounts = connCountPerUser.Counts() - // There is still only one new user. - assert.Equal(t, 1, len(connCounts)-initialNumUsers) checkCountsForUser(t, user, 2) - // Test after closing connections. time.Sleep lets it work, but seems flakey. + // Test after closing connections. c.Close() - // time.Sleep(10 * time.Millisecond) - // checkCountsForUser(t, user, 1) + assert.EventuallyWithT(t, func(t *assert.CollectT) { + checkCountsForUser(t, user, 1) + }, 1*time.Second, 10*time.Millisecond) c2.Close() - // time.Sleep(10 * time.Millisecond) - // checkCountsForUser(t, user, 0) + assert.EventuallyWithT(t, func(t *assert.CollectT) { + checkCountsForUser(t, user, 0) + }, 1*time.Second, 10*time.Millisecond) } -func checkCountsForUser(t *testing.T, user string, expected int64) { +func checkCountsForUser(t assert.TestingT, user string, expected int64) { connCounts := connCountPerUser.Counts() userCount, ok := connCounts[user] diff --git a/go/streamlog/streamlog_flaky_test.go b/go/streamlog/streamlog_test.go similarity index 100% rename from go/streamlog/streamlog_flaky_test.go rename to go/streamlog/streamlog_test.go diff --git a/go/timer/randticker_flaky_test.go b/go/timer/randticker_test.go similarity index 100% rename from go/timer/randticker_flaky_test.go rename to go/timer/randticker_test.go diff --git a/go/timer/suspendable_ticker_test.go b/go/timer/suspendable_ticker_test.go index 64c468a0edc..1c7cf65edcf 100644 --- a/go/timer/suspendable_ticker_test.go +++ b/go/timer/suspendable_ticker_test.go @@ -133,7 +133,7 @@ func TestSuspendableTickerTick(t *testing.T) { }) t.Run("tick after", func(t *testing.T) { before := ticks.Load() - ticker.TickAfter(1 * time.Second) + ticker.TickAfter(2 * time.Second) time.Sleep(time.Second) after := ticks.Load() assert.Zero(t, after-before) diff --git a/go/timer/timer_flaky_test.go b/go/timer/timer_test.go similarity index 100% rename from go/timer/timer_flaky_test.go rename to go/timer/timer_test.go diff --git a/go/vt/grpcclient/client_flaky_test.go b/go/vt/grpcclient/client_test.go similarity index 100% rename from go/vt/grpcclient/client_flaky_test.go rename to go/vt/grpcclient/client_test.go diff --git a/go/vt/logutil/logutil_flaky_test.go b/go/vt/logutil/logutil_test.go similarity index 100% rename from go/vt/logutil/logutil_flaky_test.go rename to go/vt/logutil/logutil_test.go