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:
Egon Elbre 2022-05-18 17:43:40 +03:00
parent 456aea727e
commit 5d6d5331f5
2 changed files with 20 additions and 0 deletions

View File

@ -182,6 +182,7 @@ pipeline {
'cockroach://root@localhost:26257/testcockroach?sslmode=disable;' +
'cockroach://root@localhost:26258/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_POSTGRES = 'postgres://postgres@localhost/teststorj?sslmode=disable'
STORJ_TEST_LOG_LEVEL = 'info'

View File

@ -7,7 +7,9 @@ package satellitedbtest
import (
"context"
"flag"
"fmt"
"os"
"regexp"
"strconv"
"strings"
@ -28,6 +30,17 @@ import (
"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.
type SatelliteDatabases struct {
Name string
@ -135,6 +148,9 @@ func CreateMasterDB(ctx context.Context, log *zap.Logger, name string, category
if err != nil {
return nil, err
}
if *cockroachNoDrop && tempDB.Driver == "cockroach" {
tempDB.Cleanup = func(d tagsql.DB) error { return nil }
}
return CreateMasterDBOnTopOf(ctx, log, tempDB)
}
@ -161,6 +177,9 @@ func CreateMetabaseDB(ctx context.Context, log *zap.Logger, name string, categor
if err != nil {
return nil, err
}
if *cockroachNoDrop && tempDB.Driver == "cockroach" {
tempDB.Cleanup = func(d tagsql.DB) error { return nil }
}
return CreateMetabaseDBOnTopOf(ctx, log, tempDB, config)
}