Skip to content
This repository has been archived by the owner on Jun 13, 2021. It is now read-only.

Commit

Permalink
Run e2e build test in DinD
Browse files Browse the repository at this point in the history
so we don't depend on docker version installed on CI nodes

Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
  • Loading branch information
ndeloof committed Oct 3, 2019
1 parent c692424 commit 8577f24
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 37 deletions.
37 changes: 19 additions & 18 deletions e2e/build_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,25 +14,26 @@ import (
)

func TestBuild(t *testing.T) {
cmd, cleanup := dockerCli.createTestCmd()
defer cleanup()
runWithDindSwarmAndRegistry(t, func(info dindSwarmAndRegistryInfo) {
cmd := info.configuredCmd

testDir := path.Join("testdata", "build")
dir := fs.NewDir(t, "test-name")
defer dir.Remove()
f := dir.Join("bundle.json")
cmd.Command = dockerCli.Command("app", "build", path.Join(testDir, "single"), "--output", f)
icmd.RunCmd(cmd).Assert(t, icmd.Success)
testDir := path.Join("testdata", "build")
dir := fs.NewDir(t, "test-name")
defer dir.Remove()
f := dir.Join("bundle.json")
cmd.Command = dockerCli.Command("app", "build", path.Join(testDir, "single"), "--output", f)
icmd.RunCmd(cmd).Assert(t, icmd.Success)

data, err := ioutil.ReadFile(f)
assert.NilError(t, err)
var bndl bundle.Bundle
err = json.Unmarshal(data, &bndl)
assert.NilError(t, err)
data, err := ioutil.ReadFile(f)
assert.NilError(t, err)
var bndl bundle.Bundle
err = json.Unmarshal(data, &bndl)
assert.NilError(t, err)

built := []string{bndl.InvocationImages[0].Digest, bndl.Images["web"].Digest, bndl.Images["worker"].Digest}
for _, ref := range built {
cmd.Command = dockerCli.Command("inspect", ref)
icmd.RunCmd(cmd).Assert(t, icmd.Success)
}
built := []string{bndl.InvocationImages[0].Digest, bndl.Images["web"].Digest, bndl.Images["worker"].Digest}
for _, ref := range built {
cmd.Command = dockerCli.Command("inspect", ref)
icmd.RunCmd(cmd).Assert(t, icmd.Success)
}
})
}
23 changes: 12 additions & 11 deletions e2e/commands_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,20 +71,21 @@ func testRenderApp(appPath string, env ...string) func(*testing.T) {
}

func TestRenderFormatters(t *testing.T) {
cmd, cleanup := dockerCli.createTestCmd()
defer cleanup()
runWithDindSwarmAndRegistry(t, func(info dindSwarmAndRegistryInfo) {
cmd := info.configuredCmd

appPath := filepath.Join("testdata", "simple", "simple.dockerapp")
cmd.Command = dockerCli.Command("app", "build", appPath)
icmd.RunCmd(cmd).Assert(t, icmd.Success)
appPath := filepath.Join("testdata", "simple", "simple.dockerapp")
cmd.Command = dockerCli.Command("app", "build", appPath)
icmd.RunCmd(cmd).Assert(t, icmd.Success)

cmd.Command = dockerCli.Command("app", "render", "--formatter", "json", appPath)
result := icmd.RunCmd(cmd).Assert(t, icmd.Success)
golden.Assert(t, result.Stdout(), "expected-json-render.golden")
cmd.Command = dockerCli.Command("app", "render", "--formatter", "json", appPath)
result := icmd.RunCmd(cmd).Assert(t, icmd.Success)
golden.Assert(t, result.Stdout(), "expected-json-render.golden")

cmd.Command = dockerCli.Command("app", "render", "--formatter", "yaml", appPath)
result = icmd.RunCmd(cmd).Assert(t, icmd.Success)
golden.Assert(t, result.Stdout(), "expected-yaml-render.golden")
cmd.Command = dockerCli.Command("app", "render", "--formatter", "yaml", appPath)
result = icmd.RunCmd(cmd).Assert(t, icmd.Success)
golden.Assert(t, result.Stdout(), "expected-yaml-render.golden")
})
}

func TestInit(t *testing.T) {
Expand Down
8 changes: 0 additions & 8 deletions e2e/images_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,26 +100,20 @@ a-simple-app:latest simple
ExitCode: 1,
Err: `"docker app image tag" requires exactly 2 arguments.`,
})
cmd.Command = dockerCli.Command("app", "image", "tag")
icmd.RunCmd(cmd).Assert(t, icmd.Expected{ExitCode: 1})

// with one argument
dockerAppImageTag("a-simple-app")
icmd.RunCmd(cmd).Assert(t, icmd.Expected{
ExitCode: 1,
Err: `"docker app image tag" requires exactly 2 arguments.`,
})
cmd.Command = dockerCli.Command("app", "image", "tag", "a-simple-app")
icmd.RunCmd(cmd).Assert(t, icmd.Expected{ExitCode: 1})

// with invalid src reference
dockerAppImageTag("a-simple-app$2", "b-simple-app")
icmd.RunCmd(cmd).Assert(t, icmd.Expected{
ExitCode: 1,
Err: `could not parse 'a-simple-app$2' as a valid reference: invalid reference format`,
})
cmd.Command = dockerCli.Command("app", "image", "tag", "a-simple-app$2", "b-simple-app")
icmd.RunCmd(cmd).Assert(t, icmd.Expected{ExitCode: 1})

// with invalid target reference
dockerAppImageTag("a-simple-app", "b@simple-app")
Expand All @@ -141,8 +135,6 @@ a-simple-app:latest simple
ExitCode: 1,
Err: `could not tag 'a-simple-app:not-a-tag': no such application image`,
})
cmd.Command = dockerCli.Command("app", "image", "tag", "a-simple-app", "b@simple-app")
icmd.RunCmd(cmd).Assert(t, icmd.Expected{ExitCode: 1})

// tag image with only names
dockerAppImageTag("a-simple-app", "b-simple-app")
Expand Down

0 comments on commit 8577f24

Please sign in to comment.