mirror of
https://github.com/netbirdio/netbird.git
synced 2025-06-19 17:31:39 +02:00
[management] Reset test containers after cleanup (#3885)
This commit is contained in:
parent
cdd27a9fe5
commit
a0d28f9851
@ -48,10 +48,13 @@ func CreateMysqlTestContainer() (func(), string, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
cleanup := func() {
|
cleanup := func() {
|
||||||
timeoutCtx, cancelFunc := context.WithTimeout(ctx, 1*time.Second)
|
if mysqlContainer != nil {
|
||||||
defer cancelFunc()
|
timeoutCtx, cancelFunc := context.WithTimeout(ctx, 1*time.Second)
|
||||||
if err = mysqlContainer.Terminate(timeoutCtx); err != nil {
|
defer cancelFunc()
|
||||||
log.WithContext(ctx).Warnf("failed to stop mysql container %s: %s", mysqlContainer.GetContainerID(), err)
|
if err = mysqlContainer.Terminate(timeoutCtx); err != nil {
|
||||||
|
log.WithContext(ctx).Warnf("failed to stop mysql container %s: %s", mysqlContainer.GetContainerID(), err)
|
||||||
|
}
|
||||||
|
mysqlContainer = nil // reset the container to allow recreation
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -91,11 +94,15 @@ func CreatePostgresTestContainer() (func(), string, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
cleanup := func() {
|
cleanup := func() {
|
||||||
timeoutCtx, cancelFunc := context.WithTimeout(ctx, 1*time.Second)
|
if pgContainer != nil {
|
||||||
defer cancelFunc()
|
timeoutCtx, cancelFunc := context.WithTimeout(ctx, 1*time.Second)
|
||||||
if err = pgContainer.Terminate(timeoutCtx); err != nil {
|
defer cancelFunc()
|
||||||
log.WithContext(ctx).Warnf("failed to stop postgres container %s: %s", pgContainer.GetContainerID(), err)
|
if err = pgContainer.Terminate(timeoutCtx); err != nil {
|
||||||
|
log.WithContext(ctx).Warnf("failed to stop postgres container %s: %s", pgContainer.GetContainerID(), err)
|
||||||
|
}
|
||||||
|
pgContainer = nil // reset the container to allow recreation
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
talksConn, err := pgContainer.ConnectionString(ctx)
|
talksConn, err := pgContainer.ConnectionString(ctx)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user