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

Add a core test logger to help capture the MSSQL container output #28472

Merged
merged 2 commits into from
Sep 23, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 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,6 +33,8 @@ 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
Expand All @@ -43,23 +46,23 @@ func PrepareMSSQLTestContainer(t *testing.T) (cleanup func(), retURL string) {
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
Loading