|
6 | 6 | "net"
|
7 | 7 | "path/filepath"
|
8 | 8 | "strconv"
|
| 9 | + "strings" |
9 | 10 | "testing"
|
10 | 11 | "time"
|
11 | 12 |
|
@@ -132,6 +133,53 @@ func TestPushPullInstall(t *testing.T) {
|
132 | 133 | })
|
133 | 134 | }
|
134 | 135 |
|
| 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 | + |
135 | 183 | func findAvailablePort() int {
|
136 | 184 | rand.Seed(time.Now().UnixNano())
|
137 | 185 | for {
|
|
0 commit comments