mirror of https://github.com/0xERR0R/blocky.git
chore: improve execution time of e2e tests
This commit is contained in:
parent
b1d014017b
commit
ed864962b2
2
Makefile
2
Makefile
|
@ -63,7 +63,7 @@ e2e-test: ## run e2e tests
|
|||
-o type=docker \
|
||||
-t blocky-e2e \
|
||||
.
|
||||
go run github.com/onsi/ginkgo/v2/ginkgo --label-filter="e2e" ./...
|
||||
go run github.com/onsi/ginkgo/v2/ginkgo --label-filter="e2e" e2e
|
||||
|
||||
race: ## run tests with race detector
|
||||
go run github.com/onsi/ginkgo/v2/ginkgo --label-filter="!e2e" --race ./...
|
||||
|
|
|
@ -16,6 +16,7 @@ import (
|
|||
"github.com/0xERR0R/blocky/helpertest"
|
||||
"github.com/0xERR0R/blocky/util"
|
||||
"github.com/avast/retry-go/v4"
|
||||
"github.com/docker/docker/api/types/container"
|
||||
"github.com/docker/go-connections/nat"
|
||||
"github.com/miekg/dns"
|
||||
"github.com/onsi/ginkgo/v2"
|
||||
|
@ -161,6 +162,11 @@ func createMariaDBContainer() (testcontainers.Container, error) {
|
|||
return container, err
|
||||
}
|
||||
|
||||
const (
|
||||
modeOwner = 700
|
||||
startupTimeout = 30 * time.Second
|
||||
)
|
||||
|
||||
func createBlockyContainer(tmpDir *helpertest.TmpFolder, lines ...string) (testcontainers.Container, error) {
|
||||
f1 := tmpDir.CreateStringFile("config1.yaml",
|
||||
lines...,
|
||||
|
@ -174,8 +180,6 @@ func createBlockyContainer(tmpDir *helpertest.TmpFolder, lines ...string) (testc
|
|||
return nil, fmt.Errorf("can't create config struct %w", err)
|
||||
}
|
||||
|
||||
const modeOwner = 700
|
||||
|
||||
ctx := context.Background()
|
||||
req := testcontainers.ContainerRequest{
|
||||
Image: blockyImage,
|
||||
|
@ -190,8 +194,13 @@ func createBlockyContainer(tmpDir *helpertest.TmpFolder, lines ...string) (testc
|
|||
FileMode: modeOwner,
|
||||
},
|
||||
},
|
||||
ConfigModifier: func(c *container.Config) {
|
||||
c.Healthcheck = &container.HealthConfig{
|
||||
Interval: time.Second,
|
||||
}
|
||||
},
|
||||
// can't use forExposedPorts / forListeningPorts because it needs "/bin/sh" in container
|
||||
WaitingFor: wait.NewExecStrategy([]string{"/app/blocky", "healthcheck"}),
|
||||
WaitingFor: wait.NewExecStrategy([]string{"/app/blocky", "healthcheck"}).WithStartupTimeout(startupTimeout),
|
||||
}
|
||||
|
||||
container, err := testcontainers.GenericContainer(ctx, testcontainers.GenericContainerRequest{
|
||||
|
|
|
@ -43,9 +43,11 @@ func NewQueryLoggingResolver(cfg config.QueryLogConfig) *QueryLoggingResolver {
|
|||
case config.QueryLogTypeCsvClient:
|
||||
writer, err = querylog.NewCSVWriter(cfg.Target, true, cfg.LogRetentionDays)
|
||||
case config.QueryLogTypeMysql:
|
||||
writer, err = querylog.NewDatabaseWriter("mysql", cfg.Target, cfg.LogRetentionDays, cfg.FlushInterval.ToDuration())
|
||||
writer, err = querylog.NewDatabaseWriter("mysql", cfg.Target, cfg.LogRetentionDays,
|
||||
cfg.FlushInterval.ToDuration())
|
||||
case config.QueryLogTypePostgresql:
|
||||
writer, err = querylog.NewDatabaseWriter("postgresql", cfg.Target, cfg.LogRetentionDays, cfg.FlushInterval.ToDuration())
|
||||
writer, err = querylog.NewDatabaseWriter("postgresql", cfg.Target, cfg.LogRetentionDays,
|
||||
cfg.FlushInterval.ToDuration())
|
||||
case config.QueryLogTypeConsole:
|
||||
writer = querylog.NewLoggerWriter()
|
||||
case config.QueryLogTypeNone:
|
||||
|
|
Loading…
Reference in New Issue