Random ACI group name for tests, otherwise we are conflicting with each other + the CI.

Same for storage account name (outside of the scope of resource group)
This commit is contained in:
Guillaume Tardif 2020-06-30 17:29:47 +02:00
parent e5e87d3357
commit f850dc557d
1 changed files with 20 additions and 13 deletions

View File

@ -19,13 +19,12 @@ package main
import ( import (
"context" "context"
"fmt" "fmt"
"math/rand"
"net/url" "net/url"
"os" "os"
"strings" "strings"
"testing" "testing"
"time"
"github.com/docker/api/azure"
"github.com/docker/api/azure/login"
"github.com/Azure/azure-sdk-for-go/profiles/2019-03-01/resources/mgmt/resources" "github.com/Azure/azure-sdk-for-go/profiles/2019-03-01/resources/mgmt/resources"
azure_storage "github.com/Azure/azure-sdk-for-go/profiles/2019-03-01/storage/mgmt/storage" azure_storage "github.com/Azure/azure-sdk-for-go/profiles/2019-03-01/storage/mgmt/storage"
@ -35,21 +34,26 @@ import (
log "github.com/sirupsen/logrus" log "github.com/sirupsen/logrus"
"github.com/stretchr/testify/suite" "github.com/stretchr/testify/suite"
"github.com/docker/api/azure"
"github.com/docker/api/azure/login"
"github.com/docker/api/context/store" "github.com/docker/api/context/store"
"github.com/docker/api/tests/aci-e2e/storage" "github.com/docker/api/tests/aci-e2e/storage"
. "github.com/docker/api/tests/framework" . "github.com/docker/api/tests/framework"
) )
const ( const (
resourceGroupName = "resourceGroupTest"
location = "westeurope" location = "westeurope"
contextName = "acitest" contextName = "acitest"
testContainerName = "testcontainername" testContainerName = "testcontainername"
testShareName = "dockertestshare"
testFileContent = "Volume mounted with success!"
testFileName = "index.html"
) )
var ( var (
subscriptionID string subscriptionID string
resourceGroupName = "resourceGroupTestE2E-" + RandStringBytes(10)
testStorageAccountName = "storageteste2e" + RandStringBytes(6) // "between 3 and 24 characters in length and use numbers and lower-case letters only"
) )
type E2eACISuite struct { type E2eACISuite struct {
@ -238,13 +242,6 @@ func (s *E2eACISuite) TestACIBackend() {
}) })
} }
const (
testStorageAccountName = "dockertestaccount"
testShareName = "dockertestshare"
testFileContent = "Volume mounted with success!"
testFileName = "index.html"
)
func createStorageAccount(aciContext store.AciContext, accountName string) azure_storage.Account { func createStorageAccount(aciContext store.AciContext, accountName string) azure_storage.Account {
log.Println("Creating storage account " + accountName) log.Println("Creating storage account " + accountName)
storageAccount, err := storage.CreateStorageAccount(context.TODO(), aciContext, accountName) storageAccount, err := storage.CreateStorageAccount(context.TODO(), aciContext, accountName)
@ -314,3 +311,13 @@ func deleteResourceGroup(groupName string) {
err = helper.Delete(ctx, *models[0].SubscriptionID, groupName) err = helper.Delete(ctx, *models[0].SubscriptionID, groupName)
Expect(err).To(BeNil()) Expect(err).To(BeNil())
} }
func RandStringBytes(n int) string {
rand.Seed(time.Now().UnixNano())
const digits = "0123456789"
b := make([]byte, n)
for i := range b {
b[i] = digits[rand.Intn(len(digits))]
}
return string(b)
}