Skip to content

Commit

Permalink
use a more recent pubsub emulator
Browse files Browse the repository at this point in the history
  • Loading branch information
calebdoxsey committed Jul 24, 2021
1 parent c5a7a91 commit a17009a
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:
- name: Pull test docker images
run: |
docker pull bigtruedata/gcloud-pubsub-emulator:latest
docker pull fixl/google-cloud-sdk-emulators:349.0.0-pubsub
- name: Download go modules
run: |
Expand Down
22 changes: 18 additions & 4 deletions testutil/googlepubsub.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"time"

"github.com/ory/dockertest"
"github.com/ory/dockertest/docker"
)

// WithGooglePubSubEmulator runs a gcloud pubsub emulator in a docker container,
Expand All @@ -19,9 +20,10 @@ func WithGooglePubSubEmulator(ctx context.Context, callback func()) error {
}

resource, err := dockerPool.RunWithOptions(&dockertest.RunOptions{
Repository: "bigtruedata/gcloud-pubsub-emulator",
Tag: "latest",
Cmd: []string{"start", "--host-port", "0.0.0.0:8538"},
Repository: "fixl/google-cloud-sdk-emulators",
Tag: "349.0.0-pubsub",
Cmd: []string{"start", "--host-port=0.0.0.0:8085"},
ExposedPorts: []string{"8085"},
})
if err != nil {
return fmt.Errorf("error running pubsub emulator: %w", err)
Expand All @@ -31,8 +33,9 @@ func WithGooglePubSubEmulator(ctx context.Context, callback func()) error {
} else {
_ = resource.Expire(60 * 10)
}
go TailLogs(ctx, dockerPool, resource)

addr := resource.GetHostPort("8538/tcp")
addr := resource.GetHostPort("8085/tcp")

if err = dockerPool.Retry(func() error {
conn, err := net.Dial("tcp", addr)
Expand All @@ -56,3 +59,14 @@ func WithGooglePubSubEmulator(ctx context.Context, callback func()) error {

return nil
}

func TailLogs(ctx context.Context, pool *dockertest.Pool, resource *dockertest.Resource) {
_ = pool.Client.Logs(docker.LogsOptions{
Context: ctx,
Stderr: true,
Stdout: true,
Follow: true,
Container: resource.Container.ID,
OutputStream: os.Stderr,
})
}

0 comments on commit a17009a

Please sign in to comment.