mirror of
https://github.com/kemko/nomad.git
synced 2026-01-01 16:05:42 +03:00
e2e/framework: code review fixes
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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.
|
||||
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
@@ -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,
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user