Wrap StartDbInDocker in a mutex. (#275)

* Wrap StartDbInDocker in a mutex.

* Adding TODO to debug further.

* Clarifying the TODO to point out a race condition.
pull/270/head
Todd Knight 6 years ago committed by GitHub
parent 1deea8aa3a
commit 01059e6ca8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -6,6 +6,7 @@ import (
"fmt"
"os"
"strings"
"sync"
"github.com/golang-migrate/migrate/v4"
"github.com/hashicorp/boundary/internal/db/migrations"
@ -80,8 +81,15 @@ func InitDbInDocker(dialect string) (cleanup func() error, retURL, container str
return c, url, container, nil
}
var (
mx = sync.Mutex{}
)
// StartDbInDocker
func StartDbInDocker(dialect string) (cleanup func() error, retURL, container string, err error) {
// TODO: Debug what part of this method is actually causing race condition issues with our test and fix.
mx.Lock()
defer mx.Unlock()
pool, err := dockertest.NewPool("")
if err != nil {
return func() error { return nil }, "", "", fmt.Errorf("could not connect to docker: %w", err)

Loading…
Cancel
Save