mirror of
https://github.com/docker/compose.git
synced 2025-07-22 13:14:29 +02:00
Display executed commands (prefixed with test name for readable logs in // runs)
Signed-off-by: Guillaume Tardif <guillaume.tardif@docker.com>
This commit is contained in:
parent
da6334f415
commit
30884ad91a
@ -169,7 +169,6 @@ func TestContainerRun(t *testing.T) {
|
|||||||
"nginx",
|
"nginx",
|
||||||
)
|
)
|
||||||
container = getContainerName(res.Stdout())
|
container = getContainerName(res.Stdout())
|
||||||
t.Logf("Container name: %q", container)
|
|
||||||
})
|
})
|
||||||
|
|
||||||
t.Run("inspect", func(t *testing.T) {
|
t.Run("inspect", func(t *testing.T) {
|
||||||
@ -184,7 +183,6 @@ func TestContainerRun(t *testing.T) {
|
|||||||
assert.Assert(t, is.Len(containerInspect.Ports, 1))
|
assert.Assert(t, is.Len(containerInspect.Ports, 1))
|
||||||
hostIP = containerInspect.Ports[0].HostIP
|
hostIP = containerInspect.Ports[0].HostIP
|
||||||
endpoint = fmt.Sprintf("http://%s:%d", containerInspect.Ports[0].HostIP, containerInspect.Ports[0].HostPort)
|
endpoint = fmt.Sprintf("http://%s:%d", containerInspect.Ports[0].HostIP, containerInspect.Ports[0].HostPort)
|
||||||
t.Logf("Endpoint: %s", endpoint)
|
|
||||||
})
|
})
|
||||||
|
|
||||||
t.Run("ps", func(t *testing.T) {
|
t.Run("ps", func(t *testing.T) {
|
||||||
@ -331,7 +329,6 @@ func TestContainerRunAttached(t *testing.T) {
|
|||||||
assert.Equal(t, port.ContainerPort, uint32(80))
|
assert.Equal(t, port.ContainerPort, uint32(80))
|
||||||
assert.Equal(t, port.HostPort, uint32(80))
|
assert.Equal(t, port.HostPort, uint32(80))
|
||||||
endpoint = fmt.Sprintf("http://%s:%d", port.HostIP, port.HostPort)
|
endpoint = fmt.Sprintf("http://%s:%d", port.HostIP, port.HostPort)
|
||||||
t.Logf("Endpoint: %s", endpoint)
|
|
||||||
|
|
||||||
assert.Assert(t, !strings.Contains(runRes.Stdout(), "/test"))
|
assert.Assert(t, !strings.Contains(runRes.Stdout(), "/test"))
|
||||||
checkRequest := func(t poll.LogT) poll.Result {
|
checkRequest := func(t poll.LogT) poll.Result {
|
||||||
@ -426,7 +423,6 @@ func TestCompose(t *testing.T) {
|
|||||||
assert.NilError(t, err)
|
assert.NilError(t, err)
|
||||||
assert.Assert(t, is.Len(containerInspect.Ports, 1))
|
assert.Assert(t, is.Len(containerInspect.Ports, 1))
|
||||||
endpoint := fmt.Sprintf("http://%s:%d", containerInspect.Ports[0].HostIP, containerInspect.Ports[0].HostPort)
|
endpoint := fmt.Sprintf("http://%s:%d", containerInspect.Ports[0].HostIP, containerInspect.Ports[0].HostPort)
|
||||||
t.Logf("Endpoint: %s", endpoint)
|
|
||||||
|
|
||||||
r, err := http.Get(endpoint + "/words/noun")
|
r, err := http.Get(endpoint + "/words/noun")
|
||||||
assert.NilError(t, err)
|
assert.NilError(t, err)
|
||||||
@ -456,7 +452,6 @@ func TestCompose(t *testing.T) {
|
|||||||
assert.NilError(t, err)
|
assert.NilError(t, err)
|
||||||
assert.Assert(t, is.Len(containerInspect.Ports, 1))
|
assert.Assert(t, is.Len(containerInspect.Ports, 1))
|
||||||
endpoint := fmt.Sprintf("http://%s:%d", containerInspect.Ports[0].HostIP, containerInspect.Ports[0].HostPort)
|
endpoint := fmt.Sprintf("http://%s:%d", containerInspect.Ports[0].HostIP, containerInspect.Ports[0].HostPort)
|
||||||
t.Logf("Endpoint: %s", endpoint)
|
|
||||||
var route string
|
var route string
|
||||||
switch cName {
|
switch cName {
|
||||||
case serverContainer:
|
case serverContainer:
|
||||||
@ -512,7 +507,6 @@ func TestRunEnvVars(t *testing.T) {
|
|||||||
res.Assert(t, icmd.Success)
|
res.Assert(t, icmd.Success)
|
||||||
out := strings.Split(strings.TrimSpace(res.Stdout()), "\n")
|
out := strings.Split(strings.TrimSpace(res.Stdout()), "\n")
|
||||||
container := strings.TrimSpace(out[len(out)-1])
|
container := strings.TrimSpace(out[len(out)-1])
|
||||||
t.Logf("Container name: %q", container)
|
|
||||||
|
|
||||||
res = c.RunDocker("inspect", container)
|
res = c.RunDocker("inspect", container)
|
||||||
|
|
||||||
@ -536,7 +530,6 @@ func setupTestResourceGroup(t *testing.T, c *E2eCLI, tName string) (string, stri
|
|||||||
rg := "E2E-" + tName + "-" + startTime
|
rg := "E2E-" + tName + "-" + startTime
|
||||||
azureLogin(t, c)
|
azureLogin(t, c)
|
||||||
sID := getSubscriptionID(t)
|
sID := getSubscriptionID(t)
|
||||||
t.Logf("Create resource group %q", rg)
|
|
||||||
err := createResourceGroup(sID, rg)
|
err := createResourceGroup(sID, rg)
|
||||||
assert.Check(t, is.Nil(err))
|
assert.Check(t, is.Nil(err))
|
||||||
t.Cleanup(func() {
|
t.Cleanup(func() {
|
||||||
@ -565,7 +558,6 @@ func deleteResourceGroup(rgName string) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func azureLogin(t *testing.T, c *E2eCLI) {
|
func azureLogin(t *testing.T, c *E2eCLI) {
|
||||||
t.Log("Log in to Azure")
|
|
||||||
// in order to create new service principal and get these 3 values : `az ad sp create-for-rbac --name 'TestServicePrincipal' --sdk-auth`
|
// in order to create new service principal and get these 3 values : `az ad sp create-for-rbac --name 'TestServicePrincipal' --sdk-auth`
|
||||||
clientID := os.Getenv("AZURE_CLIENT_ID")
|
clientID := os.Getenv("AZURE_CLIENT_ID")
|
||||||
clientSecret := os.Getenv("AZURE_CLIENT_SECRET")
|
clientSecret := os.Getenv("AZURE_CLIENT_SECRET")
|
||||||
@ -592,7 +584,6 @@ func createResourceGroup(sID, rgName string) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func createAciContextAndUseIt(t *testing.T, c *E2eCLI, sID, rgName string) {
|
func createAciContextAndUseIt(t *testing.T, c *E2eCLI, sID, rgName string) {
|
||||||
t.Log("Create ACI context")
|
|
||||||
res := c.RunDocker("context", "create", "aci", contextName, "--subscription-id", sID, "--resource-group", rgName, "--location", location)
|
res := c.RunDocker("context", "create", "aci", contextName, "--subscription-id", sID, "--resource-group", rgName, "--location", location)
|
||||||
res = c.RunDocker("context", "use", contextName)
|
res = c.RunDocker("context", "use", contextName)
|
||||||
res.Assert(t, icmd.Expected{Out: contextName})
|
res.Assert(t, icmd.Expected{Out: contextName})
|
||||||
@ -601,7 +592,6 @@ func createAciContextAndUseIt(t *testing.T, c *E2eCLI, sID, rgName string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func createStorageAccount(t *testing.T, aciContext store.AciContext, name string) (azure_storage.Account, func() error) {
|
func createStorageAccount(t *testing.T, aciContext store.AciContext, name string) (azure_storage.Account, func() error) {
|
||||||
t.Logf("Create storage account %q", name)
|
|
||||||
account, err := storage.CreateStorageAccount(context.TODO(), aciContext, name)
|
account, err := storage.CreateStorageAccount(context.TODO(), aciContext, name)
|
||||||
assert.Check(t, is.Nil(err))
|
assert.Check(t, is.Nil(err))
|
||||||
assert.Check(t, is.Equal(*(account.Name), name))
|
assert.Check(t, is.Equal(*(account.Name), name))
|
||||||
|
@ -20,11 +20,13 @@ import (
|
|||||||
"bytes"
|
"bytes"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"runtime"
|
"runtime"
|
||||||
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"gotest.tools/v3/assert"
|
"gotest.tools/v3/assert"
|
||||||
@ -161,6 +163,7 @@ func (c *E2eCLI) NewDockerCmd(args ...string) icmd.Cmd {
|
|||||||
|
|
||||||
// RunDockerOrFail runs a docker command and returns a result
|
// RunDockerOrFail runs a docker command and returns a result
|
||||||
func (c *E2eCLI) RunDockerOrFail(args ...string) *icmd.Result {
|
func (c *E2eCLI) RunDockerOrFail(args ...string) *icmd.Result {
|
||||||
|
fmt.Printf(" [%s] docker %s\n", c.test.Name() , strings.Join(args, " ") )
|
||||||
return icmd.RunCmd(c.NewDockerCmd(args...))
|
return icmd.RunCmd(c.NewDockerCmd(args...))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user