mirror of
https://github.com/netbirdio/netbird.git
synced 2026-03-31 06:24:18 -04:00
[management] Reset test containers after cleanup (#3885)
This commit is contained in:
@@ -48,10 +48,13 @@ func CreateMysqlTestContainer() (func(), string, error) {
|
||||
}
|
||||
|
||||
cleanup := func() {
|
||||
timeoutCtx, cancelFunc := context.WithTimeout(ctx, 1*time.Second)
|
||||
defer cancelFunc()
|
||||
if err = mysqlContainer.Terminate(timeoutCtx); err != nil {
|
||||
log.WithContext(ctx).Warnf("failed to stop mysql container %s: %s", mysqlContainer.GetContainerID(), err)
|
||||
if mysqlContainer != nil {
|
||||
timeoutCtx, cancelFunc := context.WithTimeout(ctx, 1*time.Second)
|
||||
defer cancelFunc()
|
||||
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() {
|
||||
timeoutCtx, cancelFunc := context.WithTimeout(ctx, 1*time.Second)
|
||||
defer cancelFunc()
|
||||
if err = pgContainer.Terminate(timeoutCtx); err != nil {
|
||||
log.WithContext(ctx).Warnf("failed to stop postgres container %s: %s", pgContainer.GetContainerID(), err)
|
||||
if pgContainer != nil {
|
||||
timeoutCtx, cancelFunc := context.WithTimeout(ctx, 1*time.Second)
|
||||
defer cancelFunc()
|
||||
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)
|
||||
|
||||
Reference in New Issue
Block a user