Upgrade github.com/testcontainers/testcontainers-go
This commit is contained in:
9
vendor/github.com/testcontainers/testcontainers-go/wait/errors.go
generated
vendored
Normal file
9
vendor/github.com/testcontainers/testcontainers-go/wait/errors.go
generated
vendored
Normal file
@ -0,0 +1,9 @@
|
||||
// +build !windows
|
||||
|
||||
package wait
|
||||
|
||||
import "syscall"
|
||||
|
||||
func isConnRefusedErr(err error) bool {
|
||||
return err == syscall.ECONNREFUSED
|
||||
}
|
9
vendor/github.com/testcontainers/testcontainers-go/wait/errors_windows.go
generated
vendored
Normal file
9
vendor/github.com/testcontainers/testcontainers-go/wait/errors_windows.go
generated
vendored
Normal file
@ -0,0 +1,9 @@
|
||||
package wait
|
||||
|
||||
import (
|
||||
"golang.org/x/sys/windows"
|
||||
)
|
||||
|
||||
func isConnRefusedErr(err error) bool {
|
||||
return err == windows.WSAECONNREFUSED
|
||||
}
|
6
vendor/github.com/testcontainers/testcontainers-go/wait/host_port.go
generated
vendored
6
vendor/github.com/testcontainers/testcontainers-go/wait/host_port.go
generated
vendored
@ -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")
|
||||
|
15
vendor/github.com/testcontainers/testcontainers-go/wait/sql.go
generated
vendored
15
vendor/github.com/testcontainers/testcontainers-go/wait/sql.go
generated
vendored
@ -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()
|
||||
|
||||
|
Reference in New Issue
Block a user