Skip to content

Commit

Permalink
Deflake unit tests
Browse files Browse the repository at this point in the history
I was seeing occasional panics with:

panic: close of closed channel
goroutine XXX [running]:
vitess.io/vitess/go/vt/binlog/binlogplayer.(*MockDBClient).ExecuteFetch(0xc000282070, {0xc00005d020, 0x24}, 0x1?)

Signed-off-by: Matt Lord <mattalord@gmail.com>
  • Loading branch information
mattlord committed Aug 20, 2024
1 parent aac9f0e commit e3cb05d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
8 changes: 4 additions & 4 deletions go/vt/binlog/binlogplayer/mock_dbclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,13 +103,13 @@ func NewMockDbaClient(t *testing.T) *MockDBClient {
// ExpectRequest adds an expected result to the mock.
// This function should not be called conncurrently with other commands.
func (dc *MockDBClient) ExpectRequest(query string, result *sqltypes.Result, err error) {
dc.expectMu.Lock()
defer dc.expectMu.Unlock()
select {
case <-dc.done:
dc.done = make(chan struct{})
default:
}
dc.expectMu.Lock()
defer dc.expectMu.Unlock()
dc.expect = append(dc.expect, &mockExpect{
query: query,
result: result,
Expand All @@ -121,13 +121,13 @@ func (dc *MockDBClient) ExpectRequest(query string, result *sqltypes.Result, err
// queryRE is a regular expression.
// This function should not be called conncurrently with other commands.
func (dc *MockDBClient) ExpectRequestRE(queryRE string, result *sqltypes.Result, err error) {
dc.expectMu.Lock()
defer dc.expectMu.Unlock()
select {
case <-dc.done:
dc.done = make(chan struct{})
default:
}
dc.expectMu.Lock()
defer dc.expectMu.Unlock()
dc.expect = append(dc.expect, &mockExpect{
query: queryRE,
re: regexp.MustCompile(queryRE),
Expand Down
8 changes: 4 additions & 4 deletions go/vt/vttablet/tabletmanager/vdiff/framework_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -623,10 +623,10 @@ func (tvde *testVDiffEnv) close() {
tstenv.SchemaEngine.Reload(context.Background())
}
tvde.tablets = nil
vdiffenv.vse.Close()
vdiffenv.vre.Close()
vdiffenv.vde.Close()
vdiffenv.dbClient.Close()
tvde.vse.Close()
tvde.vre.Close()
tvde.vde.Close()
tvde.dbClient.Close()
}

func (tvde *testVDiffEnv) addTablet(id int, keyspace, shard string, tabletType topodatapb.TabletType) *fakeTabletConn {
Expand Down

0 comments on commit e3cb05d

Please sign in to comment.