[management] Reset test containers after cleanup (#3885)

This commit is contained in:
Bethuel Mmbaga 2025-05-27 14:42:00 +03:00 committed by GitHub
parent cdd27a9fe5
commit a0d28f9851
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -48,11 +48,14 @@ func CreateMysqlTestContainer() (func(), string, error) {
}
cleanup := func() {
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
}
}
talksConn, err := mysqlContainer.ConnectionString(ctx)
@ -91,11 +94,15 @@ func CreatePostgresTestContainer() (func(), string, error) {
}
cleanup := func() {
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)