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

Commit de787f1

Browse files
committed
Fix various modification in e2e tests
By example we do not display the full reference anymore but use relocation map Signed-off-by: Yves Brissaud <yves.brissaud@docker.com>
1 parent 303135a commit de787f1

7 files changed

Lines changed: 56 additions & 18 deletions

File tree

e2e/helper_test.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,11 @@ func runWithDindSwarmAndRegistry(t *testing.T, todo func(dindSwarmAndRegistryInf
9191
todo(info)
9292
}
9393

94+
func build(t *testing.T, cmd icmd.Cmd, dockerCli dockerCliCommand, ref, path string) {
95+
cmd.Command = dockerCli.Command("app", "build", "-t", ref, path)
96+
icmd.RunCmd(cmd).Assert(t, icmd.Success)
97+
}
98+
9499
// Container represents a docker container
95100
type Container struct {
96101
image string

e2e/pushpull_test.go

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,20 @@ import (
1313

1414
func TestPushInsecureRegistry(t *testing.T) {
1515
runWithDindSwarmAndRegistry(t, func(info dindSwarmAndRegistryInfo) {
16+
path := filepath.Join("testdata", "local")
1617
ref := info.registryAddress + "/test/push-insecure"
1718

1819
// create a command outside of the dind context so without the insecure registry configured
1920
cmdNoInsecureRegistry, cleanupNoInsecureRegistryCommand := dockerCli.createTestCmd()
2021
defer cleanupNoInsecureRegistryCommand()
21-
cmdNoInsecureRegistry.Command = dockerCli.Command("app", "push", "--tag", ref, filepath.Join("testdata", "push-pull", "push-pull.dockerapp"))
22+
build(t, cmdNoInsecureRegistry, dockerCli, ref, path)
23+
cmdNoInsecureRegistry.Command = dockerCli.Command("app", "push", ref)
2224
icmd.RunCmd(cmdNoInsecureRegistry).Assert(t, icmd.Expected{ExitCode: 1})
2325

24-
// run the push with the command inside dind context configured to allow access to the insecure registry
26+
// run the push with the command inside dind context configured to allow access to the insecure registr
2527
cmd := info.configuredCmd
26-
cmd.Command = dockerCli.Command("app", "push", "--tag", ref, filepath.Join("testdata", "push-pull", "push-pull.dockerapp"))
28+
build(t, cmd, dockerCli, ref, path)
29+
cmd.Command = dockerCli.Command("app", "push", ref)
2730
icmd.RunCmd(cmd).Assert(t, icmd.Success)
2831
})
2932
}
@@ -32,16 +35,15 @@ func TestPushInstall(t *testing.T) {
3235
runWithDindSwarmAndRegistry(t, func(info dindSwarmAndRegistryInfo) {
3336
cmd := info.configuredCmd
3437
ref := info.registryAddress + "/test/push-pull"
35-
path := filepath.Join("testdata", "push-pull")
36-
cmd.Command = dockerCli.Command("app", "build", "-f", filepath.Join(path, "push-pull.dockerapp"), "-t", ref, path)
37-
icmd.RunCmd(cmd).Assert(t, icmd.Success)
38+
build(t, cmd, dockerCli, ref, filepath.Join("testdata", "push-pull"))
39+
3840
cmd.Command = dockerCli.Command("app", "push", ref)
3941
icmd.RunCmd(cmd).Assert(t, icmd.Success)
4042

4143
cmd.Command = dockerCli.Command("app", "run", ref, "--name", t.Name())
4244
icmd.RunCmd(cmd).Assert(t, icmd.Success)
4345
cmd.Command = dockerCli.Command("service", "ls")
44-
assert.Check(t, cmp.Contains(icmd.RunCmd(cmd).Assert(t, icmd.Success).Combined(), ref))
46+
assert.Check(t, cmp.Contains(icmd.RunCmd(cmd).Assert(t, icmd.Success).Combined(), t.Name()))
4547
})
4648
}
4749

@@ -50,9 +52,8 @@ func TestPushPullInstall(t *testing.T) {
5052
cmd := info.configuredCmd
5153
ref := info.registryAddress + "/test/push-pull"
5254
tag := ":v.0.0.1"
53-
path := filepath.Join("testdata", "push-pull")
54-
cmd.Command = dockerCli.Command("app", "build", "-f", filepath.Join(path, "push-pull.dockerapp"), "-t", ref+tag, path)
55-
icmd.RunCmd(cmd).Assert(t, icmd.Success)
55+
build(t, cmd, dockerCli, ref+tag, filepath.Join("testdata", "push-pull"))
56+
5657
cmd.Command = dockerCli.Command("app", "push", ref+tag)
5758
icmd.RunCmd(cmd).Assert(t, icmd.Success)
5859
cmd.Command = dockerCli.Command("app", "pull", ref+tag)
@@ -91,8 +92,7 @@ func TestPushInstallBundle(t *testing.T) {
9192
ref := info.registryAddress + "/test/push-bundle"
9293

9394
// render the app to a bundle, we use the app from the push pull test above.
94-
cmd.Command = dockerCli.Command("app", "build", "--tag", "a-simple-app:1.0.0", filepath.Join("testdata", "push-pull"))
95-
icmd.RunCmd(cmd).Assert(t, icmd.Success)
95+
build(t, cmd, dockerCli, "a-simple-app:1.0.0", filepath.Join("testdata", "push-pull"))
9696

9797
// push it and install to check it is available
9898
t.Run("push-bundle", func(t *testing.T) {
@@ -105,14 +105,14 @@ func TestPushInstallBundle(t *testing.T) {
105105
cmd.Command = dockerCli.Command("app", "run", ref, "--name", name)
106106
icmd.RunCmd(cmd).Assert(t, icmd.Success)
107107
cmd.Command = dockerCli.Command("service", "ls")
108-
assert.Check(t, cmp.Contains(icmd.RunCmd(cmd).Assert(t, icmd.Success).Combined(), ref))
108+
assert.Check(t, cmp.Contains(icmd.RunCmd(cmd).Assert(t, icmd.Success).Combined(), name))
109109

110110
// ensure it doesn't confuse the next test
111111
cmd.Command = dockerCli.Command("app", "rm", name)
112112
icmd.RunCmd(cmd).Assert(t, icmd.Success)
113113

114114
cmd.Command = dockerCli.Command("service", "ls")
115-
assert.Check(t, !strings.Contains(icmd.RunCmd(cmd).Assert(t, icmd.Success).Combined(), ref))
115+
assert.Check(t, !strings.Contains(icmd.RunCmd(cmd).Assert(t, icmd.Success).Combined(), name))
116116
})
117117

118118
// push it again using the first ref and install from the new ref to check it is also available
@@ -127,7 +127,7 @@ func TestPushInstallBundle(t *testing.T) {
127127
cmd.Command = dockerCli.Command("app", "run", ref2, "--name", name)
128128
icmd.RunCmd(cmd).Assert(t, icmd.Success)
129129
cmd.Command = dockerCli.Command("service", "ls")
130-
assert.Check(t, cmp.Contains(icmd.RunCmd(cmd).Assert(t, icmd.Success).Combined(), ref2))
130+
assert.Check(t, cmp.Contains(icmd.RunCmd(cmd).Assert(t, icmd.Success).Combined(), name))
131131
})
132132

133133
// push it again using an app pre-bundled and tagged in the bundle store and install it to check it is also available
@@ -143,8 +143,7 @@ func TestPushInstallBundle(t *testing.T) {
143143
cmdIsolatedStore.Env = append(cmdIsolatedStore.Env, "DOCKER_CONTEXT=swarm-context")
144144

145145
// bundle the app again but this time with a tag to store it into the bundle store
146-
cmdIsolatedStore.Command = dockerCli.Command("app", "build", "--tag", ref2, filepath.Join("testdata", "push-pull"))
147-
icmd.RunCmd(cmdIsolatedStore).Assert(t, icmd.Success)
146+
build(t, cmdIsolatedStore, dockerCli, ref2, filepath.Join("testdata", "push-pull"))
148147
// Push the app without tagging it explicitly
149148
cmdIsolatedStore.Command = dockerCli.Command("app", "push", ref2)
150149
icmd.RunCmd(cmdIsolatedStore).Assert(t, icmd.Success)
@@ -154,7 +153,7 @@ func TestPushInstallBundle(t *testing.T) {
154153
cmd.Command = dockerCli.Command("app", "run", ref2, "--name", name)
155154
icmd.RunCmd(cmd).Assert(t, icmd.Success)
156155
cmd.Command = dockerCli.Command("service", "ls")
157-
assert.Check(t, cmp.Contains(icmd.RunCmd(cmd).Assert(t, icmd.Success).Combined(), ref))
156+
assert.Check(t, cmp.Contains(icmd.RunCmd(cmd).Assert(t, icmd.Success).Combined(), name))
158157
})
159158
})
160159
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
version: "3.6"
2+
services:
3+
web:
4+
image: web
5+
build: ./web
6+
ports:
7+
- "${services.web.port}:8080"
8+
worker:
9+
image: worker
10+
build:
11+
context: ./worker
12+
args:
13+
- REPLACE_BY_BUILD_ARG=original
14+
- STATIC_ARG=static
15+
dockerfile: Dockerfile.worker
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
version: 1.1.0-beta1
2+
name: local
3+
description: "new fancy webapp with microservices"
4+
maintainers:
5+
- name: John Developer
6+
email: john.dev@example.com
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
services:
2+
web:
3+
port: 1234

e2e/testdata/local/web/Dockerfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
FROM scratch
2+
3+
COPY . .
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
FROM nginx
2+
ARG REPLACE_BY_BUILD_ARG
3+
ARG STATIC_ARG
4+
LABEL com.docker.labelled.arg=$REPLACE_BY_BUILD_ARG
5+
LABEL com.docker.labelled.optional=$STATIC_ARG
6+
7+
COPY . .

0 commit comments

Comments
 (0)