mirror of
https://github.com/docker/compose.git
synced 2025-07-22 21:24:38 +02:00
Allow running ECS E2E tests locally
Signed-off-by: Guillaume Tardif <guillaume.tardif@docker.com>
This commit is contained in:
parent
3a83d85d7a
commit
d49d4473c3
@ -48,6 +48,7 @@ make e2e-local
|
|||||||
```
|
```
|
||||||
This requires a local Docker Engine running
|
This requires a local Docker Engine running
|
||||||
|
|
||||||
|
Local ACI E2E tests:
|
||||||
```
|
```
|
||||||
AZURE_TENANT_ID="xxx" AZURE_CLIENT_ID="yyy" AZURE_CLIENT_SECRET="yyy" make e2e-aci
|
AZURE_TENANT_ID="xxx" AZURE_CLIENT_ID="yyy" AZURE_CLIENT_SECRET="yyy" make e2e-aci
|
||||||
```
|
```
|
||||||
@ -65,6 +66,13 @@ You can also run a single ACI test from the test suite:
|
|||||||
AZURE_TENANT_ID="xxx" AZURE_CLIENT_ID="yyy" AZURE_CLIENT_SECRET="yyy" make E2E_TEST=TestContainerRun e2e-aci
|
AZURE_TENANT_ID="xxx" AZURE_CLIENT_ID="yyy" AZURE_CLIENT_SECRET="yyy" make E2E_TEST=TestContainerRun e2e-aci
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Local ECS E2E tests:
|
||||||
|
```
|
||||||
|
TEST_AWS_PROFILE=myProfile TEST_AWS_REGION=eu-west-3 make e2e-ecs
|
||||||
|
```
|
||||||
|
|
||||||
|
This requires a valid AWS profile defined in ~/.aws/credentials.
|
||||||
|
|
||||||
## Release
|
## Release
|
||||||
|
|
||||||
To create a new release:
|
To create a new release:
|
||||||
|
@ -18,7 +18,6 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"gotest.tools/v3/assert"
|
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
@ -27,6 +26,8 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"gotest.tools/v3/assert"
|
||||||
|
|
||||||
. "github.com/docker/api/tests/framework"
|
. "github.com/docker/api/tests/framework"
|
||||||
"gotest.tools/v3/icmd"
|
"gotest.tools/v3/icmd"
|
||||||
)
|
)
|
||||||
@ -52,12 +53,24 @@ func TestCompose(t *testing.T) {
|
|||||||
stack := contextName
|
stack := contextName
|
||||||
|
|
||||||
t.Run("create context", func(t *testing.T) {
|
t.Run("create context", func(t *testing.T) {
|
||||||
profile := contextName
|
localTestProfile := os.Getenv("TEST_AWS_PROFILE")
|
||||||
region := os.Getenv("AWS_DEFAULT_REGION")
|
var res *icmd.Result
|
||||||
secretKey := os.Getenv("AWS_SECRET_ACCESS_KEY")
|
if localTestProfile != "" {
|
||||||
keyID := os.Getenv("AWS_ACCESS_KEY_ID")
|
region := os.Getenv("TEST_AWS_REGION")
|
||||||
res := c.RunDockerCmd("context", "create", "ecs", contextName, "--profile", profile, "--region", region, "--secret-key", secretKey, "--key-id", keyID)
|
assert.Check(t, region != "")
|
||||||
res.Assert(t, icmd.Success)
|
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 = c.RunDockerCmd("context", "use", contextName)
|
||||||
res.Assert(t, icmd.Expected{Out: contextName})
|
res.Assert(t, icmd.Expected{Out: contextName})
|
||||||
res = c.RunDockerCmd("context", "ls")
|
res = c.RunDockerCmd("context", "ls")
|
||||||
@ -69,21 +82,23 @@ func TestCompose(t *testing.T) {
|
|||||||
res.Assert(t, icmd.Success)
|
res.Assert(t, icmd.Success)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
var url string
|
||||||
t.Run("compose ps", func(t *testing.T) {
|
t.Run("compose ps", func(t *testing.T) {
|
||||||
res := c.RunDockerCmd("compose", "ps", "--project-name", stack)
|
res := c.RunDockerCmd("compose", "ps", "--project-name", stack)
|
||||||
res.Assert(t, icmd.Success)
|
res.Assert(t, icmd.Success)
|
||||||
lines := strings.Split(res.Stdout(), "\n")
|
lines := strings.Split(res.Stdout(), "\n")
|
||||||
|
|
||||||
assert.Equal(t,3, len(lines))
|
assert.Equal(t, 3, len(lines))
|
||||||
fields := strings.Fields(lines[1])
|
fields := strings.Fields(lines[1])
|
||||||
assert.Equal(t, 4, len(fields))
|
assert.Equal(t, 4, len(fields))
|
||||||
assert.Check(t, strings.Contains(fields[0], stack))
|
assert.Check(t, strings.Contains(fields[0], stack))
|
||||||
assert.Equal(t, "nginx", fields[1])
|
assert.Equal(t, "nginx", fields[1])
|
||||||
assert.Equal(t, "1/1", fields[2])
|
assert.Equal(t, "1/1", fields[2])
|
||||||
assert.Check(t, strings.Contains(fields[3], "->80/http"))
|
assert.Check(t, strings.Contains(fields[3], "->80/http"))
|
||||||
url := "http://" + strings.Replace(fields[3], "->80/http", "", 1)
|
url = "http://" + strings.Replace(fields[3], "->80/http", "", 1)
|
||||||
|
})
|
||||||
|
|
||||||
|
t.Run("nginx GET", func(t *testing.T) {
|
||||||
r, err := http.Get(url)
|
r, err := http.Get(url)
|
||||||
assert.NilError(t, err)
|
assert.NilError(t, err)
|
||||||
assert.Equal(t, r.StatusCode, http.StatusOK)
|
assert.Equal(t, r.StatusCode, http.StatusOK)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user