Skip to content

Commit

Permalink
backport of commit 6acfc8e (#28475)
Browse files Browse the repository at this point in the history
Co-authored-by: Steven Clark <[email protected]>
  • Loading branch information
1 parent 2a0f595 commit de8670d
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions helper/testhelpers/mssql/mssqlhelper.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"strings"
"testing"

"github.com/hashicorp/vault/helper/testhelpers/corehelpers"
"github.com/hashicorp/vault/sdk/helper/docker"
)

Expand All @@ -32,34 +33,36 @@ func PrepareMSSQLTestContainer(t *testing.T) (cleanup func(), retURL string) {
return func() {}, os.Getenv("MSSQL_URL")
}

logger := corehelpers.NewTestLogger(t)

var err error
for i := 0; i < numRetries; i++ {
var svc *docker.Service
var runner *docker.Runner
runner, err = docker.NewServiceRunner(docker.RunOptions{
ContainerName: "sqlserver",
ImageRepo: "mcr.microsoft.com/mssql/server",
ImageTag: "2017-latest-ubuntu",
ImageTag: "2022-latest",
Env: []string{"ACCEPT_EULA=Y", "SA_PASSWORD=" + mssqlPassword},
Ports: []string{"1433/tcp"},
LogConsumer: func(s string) {
if t.Failed() {
t.Logf("container logs: %s", s)
}
logger.Info(s)
},
})
if err != nil {
t.Logf("Could not start docker MSSQL: %v", err)
logger.Error("failed creating new service runner", "error", err.Error())
continue
}

svc, err = runner.StartService(context.Background(), connectMSSQL)
if err == nil {
return svc.Cleanup, svc.Config.URL().String()
}

logger.Error("failed starting service", "error", err.Error())
}

t.Fatalf("Could not start docker MSSQL: %v", err)
t.Fatalf("Could not start docker MSSQL last error: %v", err)
return nil, ""
}

Expand Down

0 comments on commit de8670d

Please sign in to comment.