diff --git a/e2e/framework/context.go b/e2e/framework/context.go index f441a5516..48dcd69e4 100644 --- a/e2e/framework/context.go +++ b/e2e/framework/context.go @@ -23,6 +23,14 @@ func newF(t *testing.T) *F { return newFWithID(uuid.Generate()[:8], t) } +func newFFromParent(f *F, t *testing.T) *F { + child := newF(t) + for k, v := range f.data { + child.Set(k, v) + } + return child +} + func newFWithID(id string, t *testing.T) *F { ft := &F{ id: id, diff --git a/e2e/framework/doc.go b/e2e/framework/doc.go index 755573754..d682ffc3b 100644 --- a/e2e/framework/doc.go +++ b/e2e/framework/doc.go @@ -99,7 +99,7 @@ The test framework honors go test's parallel feature under certain conditions. A TestSuite can be created with the Parallel field set to true to enable parallel execution of the test cases of the suite. Tests within a test case will be executed sequentially unless f.T().Parallel() is called. Note that if -multiple tests are to be executed in parallel, access to TC is note syncronized. +multiple tests are to be executed in parallel, access to TC is not syncronized. The *framework.F offers a way to store state between before/after each method if desired. diff --git a/e2e/framework/framework.go b/e2e/framework/framework.go index 5c14bdf89..b0f4476f1 100644 --- a/e2e/framework/framework.go +++ b/e2e/framework/framework.go @@ -131,7 +131,10 @@ func (f *Framework) runSuite(t *testing.T, s *TestSuite) (skip bool, err error) // The test name is set to the name of the implementing type, including package name := fmt.Sprintf("%T", c) - // Each TestCase is provisioned a nomad cluster + // Each TestCase is provisioned a Nomad cluster to test against. + // This varies by the provisioner implementation used, currently + // the default behavior is for every Test case to use a single shared + // Nomad cluster. info, err := f.provisioner.ProvisionCluster(ProvisionerOptions{ Name: name, ExpectConsul: s.Consul, @@ -176,7 +179,7 @@ func (f *Framework) runSuite(t *testing.T, s *TestSuite) (skip bool, err error) // Test cases are never parallel t.Run(method.Name, func(t *testing.T) { - cF := newF(t) + cF := newFFromParent(f, t) if BeforeEachTest, ok := c.(BeforeEachTest); ok { BeforeEachTest.BeforeEach(cF) } diff --git a/e2e/framework/provisioner.go b/e2e/framework/provisioner.go index d418f918b..f06373b65 100644 --- a/e2e/framework/provisioner.go +++ b/e2e/framework/provisioner.go @@ -1,13 +1,12 @@ package framework import ( - "crypto/md5" - "encoding/hex" "fmt" "os" capi "github.com/hashicorp/consul/api" napi "github.com/hashicorp/nomad/api" + "github.com/hashicorp/nomad/helper/uuid" vapi "github.com/hashicorp/vault/api" ) @@ -42,10 +41,8 @@ type singleClusterProvisioner struct{} func (p *singleClusterProvisioner) ProvisionCluster(opts ProvisionerOptions) (*ClusterInfo, error) { // Build ID based off given name - h := md5.New() - h.Write([]byte(opts.Name)) info := &ClusterInfo{ - ID: hex.EncodeToString(h.Sum(nil))[:8], + ID: uuid.Generate()[:8], Name: opts.Name, }