Skip to content

Commit

Permalink
fix(cloud-spanner): stop emulator container with background context
Browse files Browse the repository at this point in the history
Use a background context with a 10s timeout when stopping the emulator.

This makes sure the container is (at least attempted) stopped when e.g.
pressing ctrl-c while running tests.
  • Loading branch information
radhus committed Oct 4, 2024
1 parent 47f5824 commit b1b5e7e
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions tools/sgcloudspanner/emulator.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ func RunEmulator(ctx context.Context) (_ func(), err error) {
}
containerID := strings.TrimSpace(dockerRunStdout.String())
cleanup := func() {
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
defer cancel()
sg.Logger(ctx).Println("stopping down Cloud Spanner emulator...")
cmd := sgdocker.Command(ctx, "kill", containerID)
cmd.Stdout, cmd.Stderr = nil, nil
Expand Down

0 comments on commit b1b5e7e

Please sign in to comment.