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

Commit ced138b

Browse files
author
Ian Campbell
committed
e2e: Add a test for pushing from a bundle and from a ref
The use of `!strings.Contains()` in one assertion, rather than `!cmp.Contains()` is due to gotestyourself/gotest.tools#147 Signed-off-by: Ian Campbell <[email protected]>
1 parent 594ce0e commit ced138b

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed

e2e/pushpull_test.go

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"net"
77
"path/filepath"
88
"strconv"
9+
"strings"
910
"testing"
1011
"time"
1112

@@ -132,6 +133,53 @@ func TestPushPullInstall(t *testing.T) {
132133
})
133134
}
134135

136+
func TestPushInstallBundle(t *testing.T) {
137+
runWithDindSwarmAndRegistry(t, func(info dindSwarmAndRegistryInfo) {
138+
cmd := info.configuredCmd
139+
ref := info.registryAddress + "/test/push-bundle"
140+
141+
tmpDir := fs.NewDir(t, t.Name())
142+
defer tmpDir.Remove()
143+
bundleFile := tmpDir.Join("bundle.json")
144+
145+
// render the app to a bundle, we use the app from the push pull test above.
146+
cmd.Command = dockerCli.Command("app", "bundle", "-o", bundleFile, filepath.Join("testdata", "push-pull", "push-pull.dockerapp"))
147+
icmd.RunCmd(cmd).Assert(t, icmd.Success)
148+
149+
// push it and install to check it is available
150+
t.Run("push-bundle", func(t *testing.T) {
151+
name := strings.Replace(t.Name(), "/", "_", 1)
152+
cmd.Command = dockerCli.Command("app", "push", "--insecure-registries="+info.registryAddress, "--tag", ref, bundleFile)
153+
icmd.RunCmd(cmd).Assert(t, icmd.Success)
154+
155+
cmd.Command = dockerCli.Command("app", "install", "--insecure-registries="+info.registryAddress, ref, "--name", name)
156+
icmd.RunCmd(cmd).Assert(t, icmd.Success)
157+
cmd.Command = dockerCli.Command("service", "ls")
158+
assert.Check(t, cmp.Contains(icmd.RunCmd(cmd).Assert(t, icmd.Success).Combined(), ref))
159+
160+
// ensure it doesn't confuse the next test
161+
cmd.Command = dockerCli.Command("app", "uninstall", name)
162+
icmd.RunCmd(cmd).Assert(t, icmd.Success)
163+
164+
cmd.Command = dockerCli.Command("service", "ls")
165+
assert.Check(t, !strings.Contains(icmd.RunCmd(cmd).Assert(t, icmd.Success).Combined(), ref))
166+
})
167+
168+
// push it again using the first ref and install from the new ref to check it is also available
169+
t.Run("push-ref", func(t *testing.T) {
170+
name := strings.Replace(t.Name(), "/", "_", 1)
171+
ref2 := info.registryAddress + "/test/push-ref"
172+
cmd.Command = dockerCli.Command("app", "push", "--insecure-registries="+info.registryAddress, "--tag", ref2, ref+":latest")
173+
icmd.RunCmd(cmd).Assert(t, icmd.Success)
174+
175+
cmd.Command = dockerCli.Command("app", "install", "--insecure-registries="+info.registryAddress, ref2, "--name", name)
176+
icmd.RunCmd(cmd).Assert(t, icmd.Success)
177+
cmd.Command = dockerCli.Command("service", "ls")
178+
assert.Check(t, cmp.Contains(icmd.RunCmd(cmd).Assert(t, icmd.Success).Combined(), ref2))
179+
})
180+
})
181+
}
182+
135183
func findAvailablePort() int {
136184
rand.Seed(time.Now().UnixNano())
137185
for {

0 commit comments

Comments
 (0)