Upgrade github.com/testcontainers/testcontainers-go

This commit is contained in:
2020-09-06 14:31:23 +02:00
parent aac5b4d8c0
commit ee1ce9e0ae
68 changed files with 11760 additions and 1013 deletions

View File

@ -0,0 +1,9 @@
// +build !windows
package wait
import "syscall"
func isConnRefusedErr(err error) bool {
return err == syscall.ECONNREFUSED
}

View File

@ -0,0 +1,9 @@
package wait
import (
"golang.org/x/sys/windows"
)
func isConnRefusedErr(err error) bool {
return err == windows.WSAECONNREFUSED
}

View File

@ -6,7 +6,6 @@ import (
"net"
"os"
"strconv"
"syscall"
"time"
"github.com/pkg/errors"
@ -74,7 +73,7 @@ func (hp *HostPortStrategy) WaitUntilReady(ctx context.Context, target StrategyT
if err != nil {
if v, ok := err.(*net.OpError); ok {
if v2, ok := (v.Err).(*os.SyscallError); ok {
if v2.Err == syscall.ECONNREFUSED && ctx.Err() == nil {
if isConnRefusedErr(v2.Err) {
time.Sleep(100 * time.Millisecond)
continue
}
@ -90,6 +89,9 @@ func (hp *HostPortStrategy) WaitUntilReady(ctx context.Context, target StrategyT
//internal check
command := buildInternalCheckCommand(hp.Port.Int())
for {
if ctx.Err() != nil {
return ctx.Err()
}
exitCode, err := target.Exec(ctx, []string{"/bin/sh", "-c", command})
if err != nil {
return errors.Wrapf(err, "host port waiting failed")

View File

@ -4,16 +4,18 @@ import (
"context"
"database/sql"
"fmt"
"github.com/docker/go-connections/nat"
"time"
"github.com/docker/go-connections/nat"
)
//ForSQL constructs a new waitForSql strategy for the given driver
func ForSQL(port nat.Port, driver string, url func(nat.Port) string) *waitForSql {
return &waitForSql{
Port: port,
URL: url,
Driver: driver,
Port: port,
URL: url,
Driver: driver,
startupTimeout: defaultStartupTimeout(),
}
}
@ -31,11 +33,8 @@ func (w *waitForSql) Timeout(duration time.Duration) *waitForSql {
}
//WaitUntilReady repeatedly tries to run "SELECT 1" query on the given port using sql and driver.
// If the it doesn't succeed until the timeout value which defaults to 10 seconds, it will return an error
// If the it doesn't succeed until the timeout value which defaults to 60 seconds, it will return an error
func (w *waitForSql) WaitUntilReady(ctx context.Context, target StrategyTarget) (err error) {
if w.startupTimeout == 0 {
w.startupTimeout = time.Second * 10
}
ctx, cancel := context.WithTimeout(ctx, w.startupTimeout)
defer cancel()