Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
kopaygorodsky committed Jul 12, 2024
1 parent 4e27d66 commit 3af8ff2
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
12 changes: 10 additions & 2 deletions testing/integration/saga/suite/mysqlsuite.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ import (
"sync"
"time"

"github.com/testcontainers/testcontainers-go"
"github.com/testcontainers/testcontainers-go/wait"

driverSql "github.com/go-sql-driver/mysql"
"github.com/stretchr/testify/require"
"github.com/stretchr/testify/suite"
Expand Down Expand Up @@ -49,6 +52,10 @@ func (t *MysqlSuite) SetupSuite() {
mysql.WithDatabase(dbCreds.dbName),
mysql.WithUsername(dbCreds.user),
mysql.WithPassword(dbCreds.password),
testcontainers.WithWaitStrategy(
wait.ForLog("[Server] /usr/sbin/mysqld: ready for connections").
WithOccurrence(1).
WithStartupTimeout(30*time.Second)),
)
t.Require().NoError(err)
t.dbContainer = dbContainer
Expand All @@ -64,6 +71,8 @@ func (t *MysqlSuite) SetupSuite() {
connectionStr = v
}

time.Sleep(time.Second * 5)

t.dbConn, err = sql.Open("mysql", connectionStr)
require.NoError(t.T(), err)
err = t.dbConn.Ping()
Expand All @@ -87,8 +96,7 @@ func (t *MysqlSuite) TearDownSuite() {
require.NoError(t.T(), t.dbConn.Close())
ctx, cancel := context.WithTimeout(context.Background(), time.Second*10)
defer cancel()
timeout := time.Second * 10
err = t.dbContainer.Stop(ctx, &timeout)
err = t.dbContainer.Stop(ctx, nil)
t.Require().NoError(err)
}

Expand Down
4 changes: 3 additions & 1 deletion testing/integration/saga/suite/pgsuite.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func (t *PgSuite) SetupSuite() {
testcontainers.WithWaitStrategy(
wait.ForLog("database system is ready to accept connections").
WithOccurrence(2).
WithStartupTimeout(1*time.Second)),
WithStartupTimeout(30*time.Second)),
)
require.NoError(t.T(), err)
t.dbContainer = dbContainer
Expand All @@ -64,6 +64,8 @@ func (t *PgSuite) SetupSuite() {
connectionStr = v
}

time.Sleep(time.Second * 5)

ctx, cancel := context.WithTimeout(context.Background(), time.Second*10)
defer cancel()

Expand Down

0 comments on commit 3af8ff2

Please sign in to comment.