Skip to content

Commit

Permalink
Merge branch 'main' into issue-332-generic-parallel-containers
Browse files Browse the repository at this point in the history
  • Loading branch information
Vladimir Stepanov committed Jun 16, 2022
2 parents 0d5b2ab + fa714e3 commit d2efcb4
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 3 deletions.
2 changes: 2 additions & 0 deletions container.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@ type ContainerRequest struct {
AutoRemove bool // if set to true, the container will be removed from the host when stopped
AlwaysPullImage bool // Always pull image
ImagePlatform string // ImagePlatform describes the platform which the image runs on.
Binds []string
ShmSize int64 // Amount of memory shared with the host (in bytes)
}

type (
Expand Down
2 changes: 2 additions & 0 deletions docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -865,12 +865,14 @@ func (p *DockerProvider) CreateContainer(ctx context.Context, req ContainerReque
hostConfig := &container.HostConfig{
ExtraHosts: req.ExtraHosts,
PortBindings: exposedPortMap,
Binds: req.Binds,
Mounts: mounts,
Tmpfs: req.Tmpfs,
AutoRemove: req.AutoRemove,
Privileged: req.Privileged,
NetworkMode: req.NetworkMode,
Resources: req.Resources,
ShmSize: req.ShmSize,
}

endpointConfigs := map[string]*network.EndpointSettings{}
Expand Down
23 changes: 20 additions & 3 deletions logconsumer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package testcontainers

import (
"context"
"errors"
"fmt"
"net/http"
"testing"
Expand Down Expand Up @@ -201,13 +202,29 @@ func TestContainerLogWithErrClosed(t *testing.T) {
},
})
if err != nil {
t.Fatal(err)
t.Fatal("create generic container:", err)
}
defer dind.Terminate(ctx)

remoteDocker, err := dind.Endpoint(ctx, "2375/tcp")
var remoteDocker string

ctxEndpoint, cancel := context.WithTimeout(ctx, 5*time.Second)
defer cancel()

// todo: remove this temporary fix (test is flaky).
for {
remoteDocker, err = dind.Endpoint(ctxEndpoint, "2375/tcp")
if err == nil {
break
}
if errors.Is(err, context.DeadlineExceeded) {
break
}
time.Sleep(100 * time.Microsecond)
t.Log("retrying get endpoint")
}
if err != nil {
t.Fatal(err)
t.Fatal("get endpoint:", err)
}

client, err := client.NewClientWithOpts(client.WithHost(remoteDocker))
Expand Down

0 comments on commit d2efcb4

Please sign in to comment.