Skip to content

Commit

Permalink
bump docker version (#184)
Browse files Browse the repository at this point in the history
* bump docker version

* update test.sh for proper dns resolution

* upgrade codeclimate reporter and bump docker version

* at docker api server negotiation with and switch from NewEnvClient to NewClientWithOpts as newEnvClient is deprecated

* add nameserver to resolve.conf

* remove extra commander test in makefile

* use golang image from build for docker-exec test

* code cleanup

* Go mody tidy

Co-authored-by: Hitt, Dylan F <[email protected]>
  • Loading branch information
dylanhitt and Hitt, Dylan F authored Jul 3, 2022
1 parent 2acd0b2 commit 09285ba
Show file tree
Hide file tree
Showing 782 changed files with 248,924 additions and 5,081 deletions.
1 change: 1 addition & 0 deletions commander_unix.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ tests:
exit-code: 0

it should execute test from url:
skip: false
config:
env:
USER: from_parent
Expand Down
10 changes: 9 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,21 @@ go 1.17
require (
github.com/antchfx/xmlquery v1.3.5
github.com/commander-cli/cmd v1.3.0
github.com/docker/docker v1.13.1
github.com/containerd/containerd v1.5.8 // indirect
github.com/docker/docker v20.10.11+incompatible
github.com/docker/go-connections v0.4.0 // indirect
github.com/gorilla/mux v1.8.0 // indirect
github.com/logrusorgru/aurora v2.0.3+incompatible
github.com/moby/term v0.0.0-20210619224110-3f7ff695adc6 // indirect
github.com/morikuni/aec v1.0.0 // indirect
github.com/opencontainers/image-spec v1.0.2 // indirect
github.com/pmezard/go-difflib v1.0.0
github.com/stretchr/testify v1.7.0
github.com/tidwall/gjson v1.9.3
github.com/urfave/cli v1.22.5
golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2
golang.org/x/time v0.0.0-20211116232009-f0f3c7e86c11 // indirect
google.golang.org/grpc v1.42.0 // indirect
gopkg.in/h2non/gock.v1 v1.0.16
gopkg.in/yaml.v2 v2.4.0
)
Expand Down
933 changes: 926 additions & 7 deletions go.sum

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion integration/linux/docker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,5 @@ tests:
PRETTY_NAME="Alpine Linux v3.11"
HOME_URL="https://alpinelinux.org/"
BUG_REPORT_URL="https://bugs.alpinelinux.org/"
"id -u":
stdout: "1001"
44 changes: 27 additions & 17 deletions pkg/runtime/docker_executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@ import (
"encoding/base64"
"encoding/json"
"fmt"
"github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/container"
"github.com/docker/docker/client"
"github.com/docker/docker/pkg/stdcopy"
"log"
"os"
"strings"
"time"

"github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/container"
"github.com/docker/docker/client"
"github.com/docker/docker/pkg/stdcopy"
)

var _ Executor = (*DockerExecutor)(nil)
Expand All @@ -34,7 +35,7 @@ func (e DockerExecutor) Execute(test TestCase) TestResult {
log.Printf("DOCKER_API_VERSION: %s \n", os.Getenv("DOCKER_API_VERSION"))

ctx := context.Background()
cli, err := client.NewEnvClient()
cli, err := client.NewClientWithOpts(client.WithAPIVersionNegotiation(), client.FromEnv)
if err != nil {
test.Result.Error = err
return TestResult{
Expand Down Expand Up @@ -72,14 +73,15 @@ func (e DockerExecutor) Execute(test TestCase) TestResult {
}

log.Printf("Create container %s\n", e.Image)
resp, err := cli.ContainerCreate(ctx, &container.Config{
Image: e.Image,
WorkingDir: test.Command.Dir,
Env: env,
User: e.ExecUser,
Cmd: []string{"/bin/sh", "-c", test.Command.Cmd},
Tty: false,
}, nil, nil, "")
resp, err := cli.ContainerCreate(ctx,
&container.Config{
Image: e.Image,
WorkingDir: test.Command.Dir,
Env: env,
User: e.ExecUser,
Cmd: []string{"/bin/sh", "-c", test.Command.Cmd},
Tty: false,
}, nil, nil, nil, "")
if err != nil {
test.Result.Error = fmt.Errorf("could not pull image '%s' with error: '%s'", e.Image, err)
return TestResult{
Expand All @@ -94,12 +96,19 @@ func (e DockerExecutor) Execute(test TestCase) TestResult {
TestCase: test,
}
}

duration := time.Duration(1 * time.Second)
defer cli.ContainerStop(ctx, resp.ID, &duration)

status, err := cli.ContainerWait(ctx, resp.ID)
if err != nil {
panic(err)
status := container.ContainerWaitOKBody{}
statusCh, errC := cli.ContainerWait(ctx, resp.ID, "")
select {
case err := <-errC:
if err != nil {
panic(err)
}
case s := <-statusCh:
status = s
}

out, err := cli.ContainerLogs(ctx, resp.ID, types.ContainerLogsOptions{ShowStdout: true, ShowStderr: true})
Expand All @@ -119,9 +128,10 @@ func (e DockerExecutor) Execute(test TestCase) TestResult {
log.Println("title: '"+test.Title+"'", " Directory: ", test.Command.Dir)
log.Println("title: '"+test.Title+"'", " Env: ", test.Command.Env)

// status := <-waitBody
// Write test result
test.Result = CommandResult{
ExitCode: int(status),
ExitCode: int(status.StatusCode),
Stdout: strings.TrimSpace(strings.Replace(stdout.String(), "\r\n", "\n", -1)),
Stderr: strings.TrimSpace(strings.Replace(stderr.String(), "\r\n", "\n", -1)),
}
Expand Down
1 change: 0 additions & 1 deletion test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,3 @@ if [[ "$NO_CLEANUP" -eq "0" ]]; then
fi

exit $status_code

1 change: 1 addition & 0 deletions vendor/github.com/Microsoft/go-winio/CODEOWNERS

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

36 changes: 24 additions & 12 deletions vendor/github.com/Microsoft/go-winio/fileinfo.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions vendor/github.com/Microsoft/go-winio/hvsock.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions vendor/github.com/Microsoft/go-winio/pkg/guid/guid.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion vendor/github.com/Microsoft/go-winio/syscall.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 09285ba

Please sign in to comment.