Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test for sql wait strategy #214

Closed
wants to merge 10 commits into from
10 changes: 8 additions & 2 deletions wait/sql.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ func ForSQL(port nat.Port, driver string, url func(string, nat.Port) string) *wa
Port: port,
URL: url,
Driver: driver,
startupTimeout: defaultStartupTimeout(),
PollInterval: defaultPollInterval(),
// Not using the default duration here because it is too low. It will never work
startupTimeout: 20 * time.Second,
PollInterval: time.Second * 1,
query: defaultForSqlQuery,
}
}
Expand Down Expand Up @@ -88,6 +89,11 @@ func (w *waitForSql) WaitUntilReady(ctx context.Context, target StrategyTarget)
return fmt.Errorf("sql.Open: %v", err)
}
defer db.Close()

db.SetConnMaxLifetime(0)
db.SetMaxIdleConns(3)
db.SetMaxOpenConns(3)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Although the code LGTM, I'm a bit reluctant to hardcode this value here without giving the user the ability to set them in the wait strategy, according to their own requirements for the database under test. If we add them as part of the SQL strategy, then I think it's fine.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thinking about this twice, these settings should be added in a separate PR. Will send a commit on top removing them, and opening a discussion to make this configurable


for {
select {
case <-ctx.Done():
Expand Down