mirror of https://github.com/docker/compose.git
Merge pull request #720 from docker/ci_aci_regions
Running tests in many regions to avoid per region limit when we run too many // things in the CI
This commit is contained in:
commit
cd0de2ea4d
|
@ -20,6 +20,7 @@ import (
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"math/rand"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
"os"
|
"os"
|
||||||
|
@ -50,10 +51,14 @@ import (
|
||||||
|
|
||||||
const (
|
const (
|
||||||
contextName = "aci-test"
|
contextName = "aci-test"
|
||||||
location = "eastus2"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var binDir string
|
var (
|
||||||
|
binDir string
|
||||||
|
|
||||||
|
location = []string{"westcentralus", "westus2", "northeurope", "southeastasia", "eastus2", "centralus", "australiaeast", "southcentralus",
|
||||||
|
"centralindia", "brazilsouth", "southindia", "northcentralus", "eastasia", "canadacentral", "japaneast", "koreacentral"}
|
||||||
|
)
|
||||||
|
|
||||||
func TestMain(m *testing.M) {
|
func TestMain(m *testing.M) {
|
||||||
p, cleanup, err := SetupExistingCLI()
|
p, cleanup, err := SetupExistingCLI()
|
||||||
|
@ -79,7 +84,8 @@ func TestLoginLogout(t *testing.T) {
|
||||||
|
|
||||||
t.Run("create context", func(t *testing.T) {
|
t.Run("create context", func(t *testing.T) {
|
||||||
sID := getSubscriptionID(t)
|
sID := getSubscriptionID(t)
|
||||||
err := createResourceGroup(t, sID, rg)
|
location := getTestLocation()
|
||||||
|
err := createResourceGroup(t, sID, rg, location)
|
||||||
assert.Check(t, is.Nil(err))
|
assert.Check(t, is.Nil(err))
|
||||||
t.Cleanup(func() {
|
t.Cleanup(func() {
|
||||||
_ = deleteResourceGroup(t, rg)
|
_ = deleteResourceGroup(t, rg)
|
||||||
|
@ -122,9 +128,15 @@ func TestLoginLogout(t *testing.T) {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func getTestLocation() string {
|
||||||
|
rand.Seed(time.Now().Unix())
|
||||||
|
n := rand.Intn(len(location))
|
||||||
|
return location[n]
|
||||||
|
}
|
||||||
|
|
||||||
func TestContainerRunVolume(t *testing.T) {
|
func TestContainerRunVolume(t *testing.T) {
|
||||||
c := NewParallelE2eCLI(t, binDir)
|
c := NewParallelE2eCLI(t, binDir)
|
||||||
sID, rg := setupTestResourceGroup(t, c)
|
sID, rg, location := setupTestResourceGroup(t, c)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
fileshareName = "dockertestshare"
|
fileshareName = "dockertestshare"
|
||||||
|
@ -338,7 +350,7 @@ func lines(output string) []string {
|
||||||
|
|
||||||
func TestContainerRunAttached(t *testing.T) {
|
func TestContainerRunAttached(t *testing.T) {
|
||||||
c := NewParallelE2eCLI(t, binDir)
|
c := NewParallelE2eCLI(t, binDir)
|
||||||
_, groupID := setupTestResourceGroup(t, c)
|
_, groupID, location := setupTestResourceGroup(t, c)
|
||||||
|
|
||||||
// Used in subtests
|
// Used in subtests
|
||||||
var (
|
var (
|
||||||
|
@ -456,7 +468,7 @@ func TestContainerRunAttached(t *testing.T) {
|
||||||
|
|
||||||
func TestComposeUpUpdate(t *testing.T) {
|
func TestComposeUpUpdate(t *testing.T) {
|
||||||
c := NewParallelE2eCLI(t, binDir)
|
c := NewParallelE2eCLI(t, binDir)
|
||||||
_, groupID := setupTestResourceGroup(t, c)
|
_, groupID, location := setupTestResourceGroup(t, c)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
composeFile = "../composefiles/aci-demo/aci_demo_port.yaml"
|
composeFile = "../composefiles/aci-demo/aci_demo_port.yaml"
|
||||||
|
@ -586,7 +598,7 @@ func TestComposeUpUpdate(t *testing.T) {
|
||||||
|
|
||||||
func TestRunEnvVars(t *testing.T) {
|
func TestRunEnvVars(t *testing.T) {
|
||||||
c := NewParallelE2eCLI(t, binDir)
|
c := NewParallelE2eCLI(t, binDir)
|
||||||
_, _ = setupTestResourceGroup(t, c)
|
_, _, _ = setupTestResourceGroup(t, c)
|
||||||
|
|
||||||
t.Run("run", func(t *testing.T) {
|
t.Run("run", func(t *testing.T) {
|
||||||
cmd := c.NewDockerCmd(
|
cmd := c.NewDockerCmd(
|
||||||
|
@ -630,23 +642,25 @@ func TestRunEnvVars(t *testing.T) {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func setupTestResourceGroup(t *testing.T, c *E2eCLI) (string, string) {
|
func setupTestResourceGroup(t *testing.T, c *E2eCLI) (string, string, string) {
|
||||||
startTime := strconv.Itoa(int(time.Now().Unix()))
|
startTime := strconv.Itoa(int(time.Now().Unix()))
|
||||||
rg := "E2E-" + t.Name() + "-" + startTime
|
rg := "E2E-" + t.Name() + "-" + startTime
|
||||||
azureLogin(t, c)
|
azureLogin(t, c)
|
||||||
sID := getSubscriptionID(t)
|
sID := getSubscriptionID(t)
|
||||||
err := createResourceGroup(t, sID, rg)
|
location := getTestLocation()
|
||||||
|
err := createResourceGroup(t, sID, rg, location)
|
||||||
assert.Check(t, is.Nil(err))
|
assert.Check(t, is.Nil(err))
|
||||||
t.Cleanup(func() {
|
t.Cleanup(func() {
|
||||||
if err := deleteResourceGroup(t, rg); err != nil {
|
if err := deleteResourceGroup(t, rg); err != nil {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
createAciContextAndUseIt(t, c, sID, rg)
|
|
||||||
|
createAciContextAndUseIt(t, c, sID, rg, location)
|
||||||
// Check nothing is running
|
// Check nothing is running
|
||||||
res := c.RunDockerCmd("ps")
|
res := c.RunDockerCmd("ps")
|
||||||
assert.Assert(t, is.Len(lines(res.Stdout()), 1))
|
assert.Assert(t, is.Len(lines(res.Stdout()), 1))
|
||||||
return sID, rg
|
return sID, rg, location
|
||||||
}
|
}
|
||||||
|
|
||||||
func deleteResourceGroup(t *testing.T, rgName string) error {
|
func deleteResourceGroup(t *testing.T, rgName string) error {
|
||||||
|
@ -683,14 +697,14 @@ func getSubscriptionID(t *testing.T) string {
|
||||||
return *models[0].SubscriptionID
|
return *models[0].SubscriptionID
|
||||||
}
|
}
|
||||||
|
|
||||||
func createResourceGroup(t *testing.T, sID, rgName string) error {
|
func createResourceGroup(t *testing.T, sID, rgName string, location string) error {
|
||||||
fmt.Printf(" [%s] creating resource group %s\n", t.Name(), rgName)
|
fmt.Printf(" [%s] creating resource group %s\n", t.Name(), rgName)
|
||||||
helper := aci.NewACIResourceGroupHelper()
|
helper := aci.NewACIResourceGroupHelper()
|
||||||
_, err := helper.CreateOrUpdate(context.TODO(), sID, rgName, resources.Group{Location: to.StringPtr(location)})
|
_, err := helper.CreateOrUpdate(context.TODO(), sID, rgName, resources.Group{Location: to.StringPtr(location)})
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
func createAciContextAndUseIt(t *testing.T, c *E2eCLI, sID, rgName string) {
|
func createAciContextAndUseIt(t *testing.T, c *E2eCLI, sID, rgName string, location string) {
|
||||||
res := c.RunDockerCmd("context", "create", "aci", contextName, "--subscription-id", sID, "--resource-group", rgName, "--location", location)
|
res := c.RunDockerCmd("context", "create", "aci", contextName, "--subscription-id", sID, "--resource-group", rgName, "--location", location)
|
||||||
res.Assert(t, icmd.Expected{Out: "Successfully created aci context \"" + contextName + "\""})
|
res.Assert(t, icmd.Expected{Out: "Successfully created aci context \"" + contextName + "\""})
|
||||||
res = c.RunDockerCmd("context", "use", contextName)
|
res = c.RunDockerCmd("context", "use", contextName)
|
||||||
|
|
Loading…
Reference in New Issue