mirror of https://github.com/docker/compose.git
More ECS E2E tests (secrets), in // of compose
Signed-off-by: Guillaume Tardif <guillaume.tardif@docker.com>
This commit is contained in:
parent
69ce33321f
commit
e05603a5ca
|
@ -48,37 +48,43 @@ func TestMain(m *testing.M) {
|
||||||
os.Exit(exitCode)
|
os.Exit(exitCode)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestCompose(t *testing.T) {
|
func TestSecrets(t *testing.T) {
|
||||||
startTime := strconv.Itoa(int(time.Now().UnixNano()))
|
c, testID := setupTest(t)
|
||||||
c := NewE2eCLI(t, binDir)
|
secretName := "secret" + testID
|
||||||
contextName := "teste2e" + startTime
|
description := "description " + testID
|
||||||
stack := contextName
|
|
||||||
|
|
||||||
t.Run("create context", func(t *testing.T) {
|
t.Run("create secret", func(t *testing.T) {
|
||||||
localTestProfile := os.Getenv("TEST_AWS_PROFILE")
|
res := c.RunDockerCmd("secret", "create", secretName, "-u", "user1", "-p", "pass1", "-d", description)
|
||||||
var res *icmd.Result
|
|
||||||
if localTestProfile != "" {
|
|
||||||
region := os.Getenv("TEST_AWS_REGION")
|
|
||||||
assert.Check(t, region != "")
|
|
||||||
res = c.RunDockerCmd("context", "create", "ecs", contextName, "--profile", localTestProfile, "--region", region)
|
|
||||||
res.Assert(t, icmd.Success)
|
res.Assert(t, icmd.Success)
|
||||||
} else {
|
assert.Check(t, strings.Contains(res.Stdout(), "secret:"+secretName))
|
||||||
profile := contextName
|
|
||||||
region := os.Getenv("AWS_DEFAULT_REGION")
|
|
||||||
secretKey := os.Getenv("AWS_SECRET_ACCESS_KEY")
|
|
||||||
keyID := os.Getenv("AWS_ACCESS_KEY_ID")
|
|
||||||
assert.Check(t, keyID != "")
|
|
||||||
assert.Check(t, secretKey != "")
|
|
||||||
assert.Check(t, region != "")
|
|
||||||
res = c.RunDockerCmd("context", "create", "ecs", contextName, "--profile", profile, "--region", region, "--secret-key", secretKey, "--key-id", keyID)
|
|
||||||
res.Assert(t, icmd.Success)
|
|
||||||
}
|
|
||||||
res = c.RunDockerCmd("context", "use", contextName)
|
|
||||||
res.Assert(t, icmd.Expected{Out: contextName})
|
|
||||||
res = c.RunDockerCmd("context", "ls")
|
|
||||||
res.Assert(t, icmd.Expected{Out: contextName + " *"})
|
|
||||||
})
|
})
|
||||||
|
|
||||||
|
t.Run("list secrets", func(t *testing.T) {
|
||||||
|
res := c.RunDockerCmd("secret", "list")
|
||||||
|
res.Assert(t, icmd.Success)
|
||||||
|
assert.Check(t, strings.Contains(res.Stdout(), secretName))
|
||||||
|
assert.Check(t, strings.Contains(res.Stdout(), description))
|
||||||
|
})
|
||||||
|
|
||||||
|
t.Run("inspect secret", func(t *testing.T) {
|
||||||
|
res := c.RunDockerCmd("secret", "inspect", secretName)
|
||||||
|
res.Assert(t, icmd.Success)
|
||||||
|
assert.Check(t, strings.Contains(res.Stdout(), `"Name": "`+secretName+`"`))
|
||||||
|
assert.Check(t, strings.Contains(res.Stdout(), `"Description": "`+description+`"`))
|
||||||
|
})
|
||||||
|
|
||||||
|
t.Run("rm secret", func(t *testing.T) {
|
||||||
|
res := c.RunDockerCmd("secret", "rm", secretName)
|
||||||
|
res.Assert(t, icmd.Success)
|
||||||
|
res = c.RunDockerCmd("secret", "list")
|
||||||
|
res.Assert(t, icmd.Success)
|
||||||
|
assert.Check(t, !strings.Contains(res.Stdout(), secretName))
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestCompose(t *testing.T) {
|
||||||
|
c, stack := setupTest(t)
|
||||||
|
|
||||||
t.Run("compose up", func(t *testing.T) {
|
t.Run("compose up", func(t *testing.T) {
|
||||||
res := c.RunDockerCmd("compose", "up", "--project-name", stack, "-f", "../composefiles/nginx.yaml")
|
res := c.RunDockerCmd("compose", "up", "--project-name", stack, "-f", "../composefiles/nginx.yaml")
|
||||||
res.Assert(t, icmd.Success)
|
res.Assert(t, icmd.Success)
|
||||||
|
@ -122,3 +128,35 @@ func TestCompose(t *testing.T) {
|
||||||
res.Assert(t, icmd.Success)
|
res.Assert(t, icmd.Success)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func setupTest(t *testing.T) (*E2eCLI, string) {
|
||||||
|
startTime := strconv.Itoa(int(time.Now().UnixNano()))
|
||||||
|
c := NewParallelE2eCLI(t, binDir)
|
||||||
|
contextName := "e2e" + t.Name() + startTime
|
||||||
|
stack := contextName
|
||||||
|
t.Run("create context", func(t *testing.T) {
|
||||||
|
localTestProfile := os.Getenv("TEST_AWS_PROFILE")
|
||||||
|
var res *icmd.Result
|
||||||
|
if localTestProfile != "" {
|
||||||
|
region := os.Getenv("TEST_AWS_REGION")
|
||||||
|
assert.Check(t, region != "")
|
||||||
|
res = c.RunDockerCmd("context", "create", "ecs", contextName, "--profile", localTestProfile, "--region", region)
|
||||||
|
res.Assert(t, icmd.Success)
|
||||||
|
} else {
|
||||||
|
profile := contextName
|
||||||
|
region := os.Getenv("AWS_DEFAULT_REGION")
|
||||||
|
secretKey := os.Getenv("AWS_SECRET_ACCESS_KEY")
|
||||||
|
keyID := os.Getenv("AWS_ACCESS_KEY_ID")
|
||||||
|
assert.Check(t, keyID != "")
|
||||||
|
assert.Check(t, secretKey != "")
|
||||||
|
assert.Check(t, region != "")
|
||||||
|
res = c.RunDockerCmd("context", "create", "ecs", contextName, "--profile", profile, "--region", region, "--secret-key", secretKey, "--key-id", keyID)
|
||||||
|
res.Assert(t, icmd.Success)
|
||||||
|
}
|
||||||
|
res = c.RunDockerCmd("context", "use", contextName)
|
||||||
|
res.Assert(t, icmd.Expected{Out: contextName})
|
||||||
|
res = c.RunDockerCmd("context", "ls")
|
||||||
|
res.Assert(t, icmd.Expected{Out: contextName + " *"})
|
||||||
|
})
|
||||||
|
return c, stack
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue