SQLStore: Enable migration locking by default (#84983)
* Introduce new configuration for migration locking * Remove feature toggle * Fix test and turn it into an integration * Fix docs
This commit is contained in:
@@ -9,6 +9,7 @@ import (
|
||||
"testing"
|
||||
|
||||
"github.com/go-sql-driver/mysql"
|
||||
"github.com/golang-migrate/migrate/v4/database"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
"gopkg.in/ini.v1"
|
||||
@@ -69,7 +70,11 @@ func TestMigrations(t *testing.T) {
|
||||
checkStepsAndDatabaseMatch(t, mg, expectedMigrations)
|
||||
}
|
||||
|
||||
func TestMigrationLock(t *testing.T) {
|
||||
func TestIntegrationMigrationLock(t *testing.T) {
|
||||
if testing.Short() {
|
||||
t.Skip("skipping integration test")
|
||||
}
|
||||
|
||||
dbType := sqlutil.GetTestDBType()
|
||||
if dbType == SQLite {
|
||||
t.Skip()
|
||||
@@ -96,9 +101,12 @@ func TestMigrationLock(t *testing.T) {
|
||||
sess.Close()
|
||||
})
|
||||
|
||||
key, err := database.GenerateAdvisoryLockId("test")
|
||||
require.NoError(t, err)
|
||||
|
||||
cfg := LockCfg{
|
||||
Session: sess,
|
||||
Key: "test",
|
||||
Key: key,
|
||||
}
|
||||
|
||||
t.Run("obtaining lock should succeed", func(t *testing.T) {
|
||||
@@ -143,7 +151,7 @@ func TestMigrationLock(t *testing.T) {
|
||||
err = dialect.Lock(cfg)
|
||||
require.NoError(t, err)
|
||||
|
||||
err = d2.Lock(LockCfg{Session: sess2})
|
||||
err = d2.Lock(LockCfg{Session: sess2, Key: key})
|
||||
require.Error(t, err)
|
||||
assert.ErrorIs(t, err, ErrLockDB)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user