Skip to content

Commit

Permalink
Move test files to regular names again (#15037)
Browse files Browse the repository at this point in the history
  • Loading branch information
dbussink authored Jan 25, 2024
1 parent 5611de3 commit ab8ae21
Show file tree
Hide file tree
Showing 9 changed files with 9 additions and 17 deletions.
File renamed without changes.
File renamed without changes.
24 changes: 8 additions & 16 deletions go/mysql/server_flaky_test.go → go/mysql/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -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]
Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion go/timer/suspendable_ticker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit ab8ae21

Please sign in to comment.