Skip to content
This repository was archived by the owner on Jul 18, 2025. It is now read-only.

Commit 0d85dfb

Browse files
committed
Run e2e build test in DinD
so we don't depend on docker version installed on CI nodes Signed-off-by: Nicolas De Loof <[email protected]>
1 parent 11645ad commit 0d85dfb

File tree

3 files changed

+31
-37
lines changed

3 files changed

+31
-37
lines changed

e2e/build_test.go

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -14,25 +14,26 @@ import (
1414
)
1515

1616
func TestBuild(t *testing.T) {
17-
cmd, cleanup := dockerCli.createTestCmd()
18-
defer cleanup()
17+
runWithDindSwarmAndRegistry(t, func(info dindSwarmAndRegistryInfo) {
18+
cmd := info.configuredCmd
1919

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

27-
data, err := ioutil.ReadFile(f)
28-
assert.NilError(t, err)
29-
var bndl bundle.Bundle
30-
err = json.Unmarshal(data, &bndl)
31-
assert.NilError(t, err)
27+
data, err := ioutil.ReadFile(f)
28+
assert.NilError(t, err)
29+
var bndl bundle.Bundle
30+
err = json.Unmarshal(data, &bndl)
31+
assert.NilError(t, err)
3232

33-
built := []string{bndl.InvocationImages[0].Digest, bndl.Images["web"].Digest, bndl.Images["worker"].Digest}
34-
for _, ref := range built {
35-
cmd.Command = dockerCli.Command("inspect", ref)
36-
icmd.RunCmd(cmd).Assert(t, icmd.Success)
37-
}
33+
built := []string{bndl.InvocationImages[0].Digest, bndl.Images["web"].Digest, bndl.Images["worker"].Digest}
34+
for _, ref := range built {
35+
cmd.Command = dockerCli.Command("inspect", ref)
36+
icmd.RunCmd(cmd).Assert(t, icmd.Success)
37+
}
38+
})
3839
}

e2e/commands_test.go

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -71,20 +71,21 @@ func testRenderApp(appPath string, env ...string) func(*testing.T) {
7171
}
7272

7373
func TestRenderFormatters(t *testing.T) {
74-
cmd, cleanup := dockerCli.createTestCmd()
75-
defer cleanup()
74+
runWithDindSwarmAndRegistry(t, func(info dindSwarmAndRegistryInfo) {
75+
cmd := info.configuredCmd
7676

77-
appPath := filepath.Join("testdata", "simple", "simple.dockerapp")
78-
cmd.Command = dockerCli.Command("app", "build", appPath)
79-
icmd.RunCmd(cmd).Assert(t, icmd.Success)
77+
appPath := filepath.Join("testdata", "simple", "simple.dockerapp")
78+
cmd.Command = dockerCli.Command("app", "build", appPath)
79+
icmd.RunCmd(cmd).Assert(t, icmd.Success)
8080

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

85-
cmd.Command = dockerCli.Command("app", "render", "--formatter", "yaml", appPath)
86-
result = icmd.RunCmd(cmd).Assert(t, icmd.Success)
87-
golden.Assert(t, result.Stdout(), "expected-yaml-render.golden")
85+
cmd.Command = dockerCli.Command("app", "render", "--formatter", "yaml", appPath)
86+
result = icmd.RunCmd(cmd).Assert(t, icmd.Success)
87+
golden.Assert(t, result.Stdout(), "expected-yaml-render.golden")
88+
})
8889
}
8990

9091
func TestInit(t *testing.T) {

e2e/images_test.go

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -100,26 +100,20 @@ a-simple-app:latest simple
100100
ExitCode: 1,
101101
Err: `"docker app image tag" requires exactly 2 arguments.`,
102102
})
103-
cmd.Command = dockerCli.Command("app", "image", "tag")
104-
icmd.RunCmd(cmd).Assert(t, icmd.Expected{ExitCode: 1})
105103

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

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

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

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

0 commit comments

Comments
 (0)