Add E2E test on deploying ACR images

Signed-off-by: Guillaume Tardif <guillaume.tardif@docker.com>
This commit is contained in:
Guillaume Tardif 2020-08-19 14:09:38 +02:00
parent 04c678b099
commit 5cab129c10
2 changed files with 22 additions and 4 deletions

View File

@ -150,10 +150,10 @@ func (c cliRegistryHelper) autoLoginAcr(registry string) error {
}
data := url.Values{
"grant_type": {"access_token"},
"service": {registry},
"tenant": {tenantID},
"access_token": {token.AccessToken},
"grant_type": {"access_token"},
"service": {registry},
"tenant": {tenantID},
"access_token": {token.AccessToken},
}
repoAuthURL := fmt.Sprintf("https://%s/oauth2/exchange", registry)
res, err := http.Post(repoAuthURL, "application/x-www-form-urlencoded", strings.NewReader(data.Encode()))

View File

@ -550,6 +550,24 @@ func TestRunEnvVars(t *testing.T) {
})
}
func TestDeployACRImage(t *testing.T) {
c := NewParallelE2eCLI(t, binDir)
_, _ = setupTestResourceGroup(t, c, "runAcr")
t.Run("run", func(t *testing.T) {
cmd := c.NewDockerCmd("run", "-d", "dockerregistrygta.azurecr.io/hello-aci")
res := icmd.RunCmd(cmd)
res.Assert(t, icmd.Success)
out := strings.Split(strings.TrimSpace(res.Stdout()), "\n")
container := strings.TrimSpace(out[len(out)-1])
t.Logf("Container name: %q", container)
waitForStatus(t, c, container, "Terminated")
res = c.RunDockerCmd("logs", container)
assert.Assert(t, strings.Contains(res.Stdout(), "Hello from Docker!"))
})
}
func setupTestResourceGroup(t *testing.T, c *E2eCLI, tName string) (string, string) {
startTime := strconv.Itoa(int(time.Now().Unix()))
rg := "E2E-" + tName + "-" + startTime