From d51d843fcd5d25674c3e0ba1a5a7feb5c045952c Mon Sep 17 00:00:00 2001 From: Agniva De Sarker Date: Mon, 26 Oct 2020 13:21:24 +0530 Subject: [PATCH] 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 ``` --- store/sqlstore/supplier_test.go | 53 --------------------------------- 1 file changed, 53 deletions(-) diff --git a/store/sqlstore/supplier_test.go b/store/sqlstore/supplier_test.go index 5f3bd45bb4..9168b14fbd 100644 --- a/store/sqlstore/supplier_test.go +++ b/store/sqlstore/supplier_test.go @@ -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 {