Skip to content

Commit f27cef8

Browse files
authored
test: provide unique timestamp based network name for docker tests (#3147)
* test: provide unique timestamp based network name for docker int tests Signed-off-by: Jacob Lisi <[email protected]> * simplify unique ID gen Signed-off-by: Jacob Lisi <[email protected]>
1 parent 0e1615b commit f27cef8

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

cmd/blocksconvert/blocksconvert

59.2 MB
Binary file not shown.

integration/configs.go

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,11 @@ package integration
44

55
import (
66
"fmt"
7+
"math/rand"
78
"path/filepath"
89
"strings"
910
"text/template"
11+
"time"
1012

1113
"github.com/cortexproject/cortex/integration/e2e"
1214
e2edb "github.com/cortexproject/cortex/integration/e2e/db"
@@ -17,7 +19,7 @@ type storeConfig struct {
1719
}
1820

1921
const (
20-
networkName = "e2e-cortex-test"
22+
networkNamePrefix = "e2e-cortex-test-"
2123
bucketName = "cortex"
2224
cortexConfigFile = "config.yaml"
2325
cortexSchemaConfigFile = "schema.yaml"
@@ -27,7 +29,24 @@ const (
2729
caCertFile = "certs/root.crt"
2830
serverCertFile = "certs/server.crt"
2931
serverKeyFile = "certs/server.key"
30-
storeConfigTemplate = `
32+
)
33+
34+
// Generate a 6 character (a-z,0-9) id for the test being run.
35+
// This ID is used to generate a network name for the test
36+
func genUniqueTestID() string {
37+
rand.Seed(time.Now().UnixNano())
38+
chars := []rune("abcdefghijklmnopqrstuvwxyz" + "0123456789")
39+
length := 6
40+
var b strings.Builder
41+
for i := 0; i < length; i++ {
42+
b.WriteRune(chars[rand.Intn(len(chars))])
43+
}
44+
return b.String() // E.g. "ExcbsVQs"
45+
}
46+
47+
var (
48+
networkName = networkNamePrefix + genUniqueTestID()
49+
storeConfigTemplate = `
3150
- from: {{.From}}
3251
store: {{.IndexStore}}
3352
schema: v9

0 commit comments

Comments
 (0)