[MM-28033] Perform localcachelayer tests for one DB type only when in CI (#15433)
* Perform localcachelayer tests for one DB type only if in CI * Add newStoreType() for sqlstore case
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
9c2d2180e6
Коммит
7abc4f5383
@@ -4,6 +4,7 @@
|
|||||||
package localcachelayer
|
package localcachelayer
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"os"
|
||||||
"sync"
|
"sync"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
@@ -22,6 +23,13 @@ type storeType struct {
|
|||||||
|
|
||||||
var storeTypes []*storeType
|
var storeTypes []*storeType
|
||||||
|
|
||||||
|
func newStoreType(name, driver string) *storeType {
|
||||||
|
return &storeType{
|
||||||
|
Name: name,
|
||||||
|
SqlSettings: storetest.MakeSqlSettings(driver),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func StoreTest(t *testing.T, f func(*testing.T, store.Store)) {
|
func StoreTest(t *testing.T, f func(*testing.T, store.Store)) {
|
||||||
defer func() {
|
defer func() {
|
||||||
if err := recover(); err != nil {
|
if err := recover(); err != nil {
|
||||||
@@ -62,14 +70,20 @@ func initStores() {
|
|||||||
if testing.Short() {
|
if testing.Short() {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
storeTypes = append(storeTypes, &storeType{
|
|
||||||
Name: "LocalCache+MySQL",
|
// In CI, we already run the entire test suite for both mysql and postgres in parallel.
|
||||||
SqlSettings: storetest.MakeSqlSettings(model.DATABASE_DRIVER_MYSQL),
|
// So we just run the tests for the current database set.
|
||||||
})
|
if os.Getenv("IS_CI") == "true" {
|
||||||
storeTypes = append(storeTypes, &storeType{
|
switch os.Getenv("MM_SQLSETTINGS_DRIVERNAME") {
|
||||||
Name: "LocalCache+PostgreSQL",
|
case "mysql":
|
||||||
SqlSettings: storetest.MakeSqlSettings(model.DATABASE_DRIVER_POSTGRES),
|
storeTypes = append(storeTypes, newStoreType("LocalCache+MySQL", model.DATABASE_DRIVER_MYSQL))
|
||||||
})
|
case "postgres":
|
||||||
|
storeTypes = append(storeTypes, newStoreType("LocalCache+PostgreSQL", model.DATABASE_DRIVER_POSTGRES))
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
storeTypes = append(storeTypes, newStoreType("LocalCache+MySQL", model.DATABASE_DRIVER_MYSQL),
|
||||||
|
newStoreType("LocalCache+PostgreSQL", model.DATABASE_DRIVER_POSTGRES))
|
||||||
|
}
|
||||||
|
|
||||||
defer func() {
|
defer func() {
|
||||||
if err := recover(); err != nil {
|
if err := recover(); err != nil {
|
||||||
|
|||||||
@@ -23,6 +23,13 @@ type storeType struct {
|
|||||||
|
|
||||||
var storeTypes []*storeType
|
var storeTypes []*storeType
|
||||||
|
|
||||||
|
func newStoreType(name, driver string) *storeType {
|
||||||
|
return &storeType{
|
||||||
|
Name: name,
|
||||||
|
SqlSettings: storetest.MakeSqlSettings(driver),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func StoreTest(t *testing.T, f func(*testing.T, store.Store)) {
|
func StoreTest(t *testing.T, f func(*testing.T, store.Store)) {
|
||||||
defer func() {
|
defer func() {
|
||||||
if err := recover(); err != nil {
|
if err := recover(); err != nil {
|
||||||
@@ -86,25 +93,13 @@ func initStores() {
|
|||||||
if os.Getenv("IS_CI") == "true" {
|
if os.Getenv("IS_CI") == "true" {
|
||||||
switch os.Getenv("MM_SQLSETTINGS_DRIVERNAME") {
|
switch os.Getenv("MM_SQLSETTINGS_DRIVERNAME") {
|
||||||
case "mysql":
|
case "mysql":
|
||||||
storeTypes = append(storeTypes, &storeType{
|
storeTypes = append(storeTypes, newStoreType("MySQL", model.DATABASE_DRIVER_MYSQL))
|
||||||
Name: "MySQL",
|
|
||||||
SqlSettings: storetest.MakeSqlSettings(model.DATABASE_DRIVER_MYSQL),
|
|
||||||
})
|
|
||||||
case "postgres":
|
case "postgres":
|
||||||
storeTypes = append(storeTypes, &storeType{
|
storeTypes = append(storeTypes, newStoreType("PostgreSQL", model.DATABASE_DRIVER_POSTGRES))
|
||||||
Name: "PostgreSQL",
|
|
||||||
SqlSettings: storetest.MakeSqlSettings(model.DATABASE_DRIVER_POSTGRES),
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
storeTypes = append(storeTypes, &storeType{
|
storeTypes = append(storeTypes, newStoreType("MySQL", model.DATABASE_DRIVER_MYSQL),
|
||||||
Name: "MySQL",
|
newStoreType("PostgreSQL", model.DATABASE_DRIVER_POSTGRES))
|
||||||
SqlSettings: storetest.MakeSqlSettings(model.DATABASE_DRIVER_MYSQL),
|
|
||||||
})
|
|
||||||
storeTypes = append(storeTypes, &storeType{
|
|
||||||
Name: "PostgreSQL",
|
|
||||||
SqlSettings: storetest.MakeSqlSettings(model.DATABASE_DRIVER_POSTGRES),
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
defer func() {
|
defer func() {
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user