Skip to content

Commit 75bf907

Browse files
committed
autobahn_test.go: Pull image before starting container
1 parent e1e65ad commit 75bf907

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

autobahn_test.go

+11-1
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,8 @@ func waitWS(ctx context.Context, url string) error {
112112
// TODO: Let docker pick the port and use docker port to find it.
113113
// Does mean we can't use -i but that's fine.
114114
func wstestServer(ctx context.Context) (url string, closeFn func() error, err error) {
115+
defer errd.Wrap(&err, "failed to start autobahn wstest server")
116+
115117
serverAddr, err := unusedListenAddr()
116118
if err != nil {
117119
return "", nil, err
@@ -141,6 +143,15 @@ func wstestServer(ctx context.Context) (url string, closeFn func() error, err er
141143
}
142144
}()
143145

146+
dockerPull := exec.CommandContext(ctx, "docker", "pull", "crossbario/autobahn-testsuite")
147+
// TODO: log to *testing.T
148+
dockerPull.Stdout = os.Stdout
149+
dockerPull.Stderr = os.Stderr
150+
err = dockerPull.Run()
151+
if err != nil {
152+
return "", nil, fmt.Errorf("failed to pull docker image: %w", err)
153+
}
154+
144155
wd, err := os.Getwd()
145156
if err != nil {
146157
return "", nil, err
@@ -159,7 +170,6 @@ func wstestServer(ctx context.Context) (url string, closeFn func() error, err er
159170
"--webport=0",
160171
)
161172
fmt.Println(strings.Join(args, " "))
162-
// TODO: pull image in advance
163173
wstest := exec.CommandContext(ctx, "docker", args...)
164174
// TODO: log to *testing.T
165175
wstest.Stdout = os.Stdout

0 commit comments

Comments
 (0)