mirror of
https://github.com/mattermost/mattermost.git
synced 2025-02-25 18:55:24 -06:00
MM-22950: Remove supplier test (#16072)
This test is too flaky to be written as a test. Let's just remove it. https://mattermost.atlassian.net/browse/MM-29950 ```release-note NONE ```
This commit is contained in:
@@ -7,7 +7,6 @@ import (
|
||||
"regexp"
|
||||
"sync"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/mattermost/gorp"
|
||||
_ "github.com/mattn/go-sqlite3"
|
||||
@@ -237,58 +236,6 @@ func TestGetDbVersion(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestRecycleDBConns(t *testing.T) {
|
||||
if testing.Short() {
|
||||
t.Skip("skipping recycle DBConns test")
|
||||
}
|
||||
testDrivers := []string{
|
||||
model.DATABASE_DRIVER_POSTGRES,
|
||||
model.DATABASE_DRIVER_MYSQL,
|
||||
model.DATABASE_DRIVER_SQLITE,
|
||||
}
|
||||
|
||||
for _, driver := range testDrivers {
|
||||
t.Run(driver, func(t *testing.T) {
|
||||
settings := makeSqlSettings(driver)
|
||||
supplier := sqlstore.NewSqlSupplier(*settings, nil)
|
||||
|
||||
var wg sync.WaitGroup
|
||||
tables := []string{"Posts", "Channels", "Users"}
|
||||
for _, table := range tables {
|
||||
wg.Add(1)
|
||||
go func(table string) {
|
||||
defer wg.Done()
|
||||
query := `SELECT count(*) FROM ` + table
|
||||
_, err := supplier.GetMaster().SelectInt(query)
|
||||
assert.NoError(t, err)
|
||||
}(table)
|
||||
}
|
||||
wg.Wait()
|
||||
|
||||
stats := supplier.GetMaster().Db.Stats()
|
||||
assert.Equal(t, 0, int(stats.MaxLifetimeClosed), "unexpected number of connections closed due to maxlifetime")
|
||||
|
||||
supplier.RecycleDBConnections(2 * time.Second)
|
||||
var success bool
|
||||
// We try 3 times to let the connections be closed.
|
||||
// Because sometimes, there can be significant goroutine contention which does not
|
||||
// give enough time for the connection cleaner goroutine to run.
|
||||
for i := 0; i < 3; i++ {
|
||||
// We cannot reliably control exactly how many open connections are there. So we
|
||||
// just do a basic check and confirm that atleast one has been closed.
|
||||
stats = supplier.GetMaster().Db.Stats()
|
||||
if int(stats.MaxLifetimeClosed) == 0 {
|
||||
time.Sleep(2 * time.Second)
|
||||
continue
|
||||
}
|
||||
success = true
|
||||
break
|
||||
}
|
||||
assert.True(t, success, "No connections were closed due to maxlifetime")
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestGetAllConns(t *testing.T) {
|
||||
t.Parallel()
|
||||
testCases := []struct {
|
||||
|
||||
Reference in New Issue
Block a user