private/testplanet: don't cleanup cockroach
Márton found out that DROP DATABASE is rather slow on CRDB, and it makes a significant impact when running the whole testsuite. In sum of test times it's ~2.5h compared to ~2h. And the end-to-end ~20m to ~16m. This adds a new flag STORJ_TEST_COCKROACH_NODROP for enabling this behavior in the CI environment. Fixes https://github.com/storj/dev-enablement/issues/6 Change-Id: I5a6616c32dc6596a96ba3d203f409368307d7438
This commit is contained in:
parent
456aea727e
commit
5d6d5331f5
@ -182,6 +182,7 @@ pipeline {
|
|||||||
'cockroach://root@localhost:26257/testcockroach?sslmode=disable;' +
|
'cockroach://root@localhost:26257/testcockroach?sslmode=disable;' +
|
||||||
'cockroach://root@localhost:26258/testcockroach?sslmode=disable;' +
|
'cockroach://root@localhost:26258/testcockroach?sslmode=disable;' +
|
||||||
'cockroach://root@localhost:26259/testcockroach?sslmode=disable'
|
'cockroach://root@localhost:26259/testcockroach?sslmode=disable'
|
||||||
|
STORJ_TEST_COCKROACH_NODROP = 'true'
|
||||||
STORJ_TEST_COCKROACH_ALT = 'cockroach://root@localhost:26260/testcockroach?sslmode=disable'
|
STORJ_TEST_COCKROACH_ALT = 'cockroach://root@localhost:26260/testcockroach?sslmode=disable'
|
||||||
STORJ_TEST_POSTGRES = 'postgres://postgres@localhost/teststorj?sslmode=disable'
|
STORJ_TEST_POSTGRES = 'postgres://postgres@localhost/teststorj?sslmode=disable'
|
||||||
STORJ_TEST_LOG_LEVEL = 'info'
|
STORJ_TEST_LOG_LEVEL = 'info'
|
||||||
|
@ -7,7 +7,9 @@ package satellitedbtest
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"os"
|
||||||
"regexp"
|
"regexp"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
@ -28,6 +30,17 @@ import (
|
|||||||
"storj.io/storj/satellite/satellitedb"
|
"storj.io/storj/satellite/satellitedb"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// Cockroach DROP DATABASE takes a significant amount, however, it has no importance in our tests.
|
||||||
|
var cockroachNoDrop = flag.Bool("cockroach-no-drop", stringToBool(os.Getenv("STORJ_TEST_COCKROACH_NODROP")), "Skip dropping cockroach databases to speed up tests")
|
||||||
|
|
||||||
|
func stringToBool(v string) bool {
|
||||||
|
b, err := strconv.ParseBool(v)
|
||||||
|
if err != nil {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return b
|
||||||
|
}
|
||||||
|
|
||||||
// SatelliteDatabases maybe name can be better.
|
// SatelliteDatabases maybe name can be better.
|
||||||
type SatelliteDatabases struct {
|
type SatelliteDatabases struct {
|
||||||
Name string
|
Name string
|
||||||
@ -135,6 +148,9 @@ func CreateMasterDB(ctx context.Context, log *zap.Logger, name string, category
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
if *cockroachNoDrop && tempDB.Driver == "cockroach" {
|
||||||
|
tempDB.Cleanup = func(d tagsql.DB) error { return nil }
|
||||||
|
}
|
||||||
|
|
||||||
return CreateMasterDBOnTopOf(ctx, log, tempDB)
|
return CreateMasterDBOnTopOf(ctx, log, tempDB)
|
||||||
}
|
}
|
||||||
@ -161,6 +177,9 @@ func CreateMetabaseDB(ctx context.Context, log *zap.Logger, name string, categor
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
if *cockroachNoDrop && tempDB.Driver == "cockroach" {
|
||||||
|
tempDB.Cleanup = func(d tagsql.DB) error { return nil }
|
||||||
|
}
|
||||||
|
|
||||||
return CreateMetabaseDBOnTopOf(ctx, log, tempDB, config)
|
return CreateMetabaseDBOnTopOf(ctx, log, tempDB, config)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user