Commit 04b8f8e7 authored by Michael Schurter's avatar Michael Schurter
Browse files

Remove `structs` import from `api`

Goes a step further and removes structs import from api's tests as well
by moving GenerateUUID to its own package.
parent 1ca9c74f
Showing with 125 additions and 55 deletions
+125 -55
......@@ -10,7 +10,7 @@ import (
"testing"
"time"
"github.com/hashicorp/nomad/nomad/structs"
"github.com/hashicorp/nomad/helper/uuid"
"github.com/hashicorp/nomad/testutil"
"github.com/stretchr/testify/assert"
)
......@@ -317,7 +317,7 @@ func TestClient_NodeClient(t *testing.T) {
http := "testdomain:4646"
tlsNode := func(string, *QueryOptions) (*Node, *QueryMeta, error) {
return &Node{
ID: structs.GenerateUUID(),
ID: uuid.Generate(),
Status: "ready",
HTTPAddr: http,
TLSEnabled: true,
......@@ -325,7 +325,7 @@ func TestClient_NodeClient(t *testing.T) {
}
noTlsNode := func(string, *QueryOptions) (*Node, *QueryMeta, error) {
return &Node{
ID: structs.GenerateUUID(),
ID: uuid.Generate(),
Status: "ready",
HTTPAddr: http,
TLSEnabled: false,
......
......@@ -9,7 +9,6 @@ import (
"github.com/gorhill/cronexpr"
"github.com/hashicorp/nomad/helper"
"github.com/hashicorp/nomad/nomad/structs"
)
const (
......@@ -330,6 +329,20 @@ type UpdateStrategy struct {
Canary *int `mapstructure:"canary"`
}
// DefaultUpdateStrategy provides a baseline that can be used to upgrade
// jobs with the old policy or for populating field defaults.
func DefaultUpdateStrategy() *UpdateStrategy {
return &UpdateStrategy{
Stagger: helper.TimeToPtr(30 * time.Second),
MaxParallel: helper.IntToPtr(1),
HealthCheck: helper.StringToPtr("checks"),
MinHealthyTime: helper.TimeToPtr(10 * time.Second),
HealthyDeadline: helper.TimeToPtr(5 * time.Minute),
AutoRevert: helper.BoolToPtr(false),
Canary: helper.IntToPtr(0),
}
}
func (u *UpdateStrategy) Copy() *UpdateStrategy {
if u == nil {
return nil
......@@ -403,34 +416,34 @@ func (u *UpdateStrategy) Merge(o *UpdateStrategy) {
}
func (u *UpdateStrategy) Canonicalize() {
d := structs.DefaultUpdateStrategy
d := DefaultUpdateStrategy()
if u.MaxParallel == nil {
u.MaxParallel = helper.IntToPtr(d.MaxParallel)
u.MaxParallel = d.MaxParallel
}
if u.Stagger == nil {
u.Stagger = helper.TimeToPtr(d.Stagger)
u.Stagger = d.Stagger
}
if u.HealthCheck == nil {
u.HealthCheck = helper.StringToPtr(d.HealthCheck)
u.HealthCheck = d.HealthCheck
}
if u.HealthyDeadline == nil {
u.HealthyDeadline = helper.TimeToPtr(d.HealthyDeadline)
u.HealthyDeadline = d.HealthyDeadline
}
if u.MinHealthyTime == nil {
u.MinHealthyTime = helper.TimeToPtr(d.MinHealthyTime)
u.MinHealthyTime = d.MinHealthyTime
}
if u.AutoRevert == nil {
u.AutoRevert = helper.BoolToPtr(d.AutoRevert)
u.AutoRevert = d.AutoRevert
}
if u.Canary == nil {
u.Canary = helper.IntToPtr(d.Canary)
u.Canary = d.Canary
}
}
......
......@@ -4,13 +4,13 @@ import (
"time"
"github.com/hashicorp/nomad/helper"
"github.com/hashicorp/nomad/nomad/structs"
"github.com/hashicorp/nomad/helper/uuid"
)
func MockJob() *Job {
job := &Job{
Region: helper.StringToPtr("global"),
ID: helper.StringToPtr(structs.GenerateUUID()),
ID: helper.StringToPtr(uuid.Generate()),
Name: helper.StringToPtr("my-job"),
Type: helper.StringToPtr("service"),
Priority: helper.IntToPtr(50),
......
......@@ -5,6 +5,7 @@ import (
"github.com/hashicorp/nomad/acl"
"github.com/hashicorp/nomad/client/config"
"github.com/hashicorp/nomad/helper/uuid"
"github.com/hashicorp/nomad/nomad/mock"
"github.com/hashicorp/nomad/nomad/structs"
"github.com/hashicorp/nomad/testutil"
......@@ -160,7 +161,7 @@ func TestClient_ACL_ResolveToken(t *testing.T) {
}
// Test bad token
out4, err := c1.ResolveToken(structs.GenerateUUID())
out4, err := c1.ResolveToken(uuid.Generate())
assert.Equal(t, structs.ErrTokenNotFound, err)
assert.Nil(t, out4)
}
......@@ -15,6 +15,7 @@ import (
"github.com/hashicorp/consul/api"
"github.com/hashicorp/go-multierror"
"github.com/hashicorp/nomad/command/agent/consul"
"github.com/hashicorp/nomad/helper/uuid"
"github.com/hashicorp/nomad/nomad/mock"
"github.com/hashicorp/nomad/nomad/structs"
"github.com/hashicorp/nomad/testutil"
......@@ -122,7 +123,7 @@ func TestAllocRunner_DeploymentHealth_Unhealthy_BadStart(t *testing.T) {
task.Config["start_error"] = "test error"
// Make the alloc be part of a deployment
ar.alloc.DeploymentID = structs.GenerateUUID()
ar.alloc.DeploymentID = uuid.Generate()
ar.alloc.Job.TaskGroups[0].Update = structs.DefaultUpdateStrategy.Copy()
ar.alloc.Job.TaskGroups[0].Update.HealthCheck = structs.UpdateStrategyHealthCheck_TaskStates
ar.alloc.Job.TaskGroups[0].Update.MaxParallel = 1
......@@ -171,7 +172,7 @@ func TestAllocRunner_DeploymentHealth_Unhealthy_Deadline(t *testing.T) {
task.Config["run_for"] = "10s"
// Make the alloc be part of a deployment
ar.alloc.DeploymentID = structs.GenerateUUID()
ar.alloc.DeploymentID = uuid.Generate()
ar.alloc.Job.TaskGroups[0].Update = structs.DefaultUpdateStrategy.Copy()
ar.alloc.Job.TaskGroups[0].Update.HealthCheck = structs.UpdateStrategyHealthCheck_TaskStates
ar.alloc.Job.TaskGroups[0].Update.MaxParallel = 1
......@@ -224,7 +225,7 @@ func TestAllocRunner_DeploymentHealth_Healthy_NoChecks(t *testing.T) {
task2.Config["start_block_for"] = "500ms"
// Make the alloc be part of a deployment
ar.alloc.DeploymentID = structs.GenerateUUID()
ar.alloc.DeploymentID = uuid.Generate()
ar.alloc.Job.TaskGroups[0].Update = structs.DefaultUpdateStrategy.Copy()
ar.alloc.Job.TaskGroups[0].Update.HealthCheck = structs.UpdateStrategyHealthCheck_TaskStates
ar.alloc.Job.TaskGroups[0].Update.MaxParallel = 1
......@@ -272,14 +273,14 @@ func TestAllocRunner_DeploymentHealth_Healthy_Checks(t *testing.T) {
task2.Services = nil
// Make the alloc be part of a deployment
ar.alloc.DeploymentID = structs.GenerateUUID()
ar.alloc.DeploymentID = uuid.Generate()
ar.alloc.Job.TaskGroups[0].Update = structs.DefaultUpdateStrategy.Copy()
ar.alloc.Job.TaskGroups[0].Update.HealthCheck = structs.UpdateStrategyHealthCheck_Checks
ar.alloc.Job.TaskGroups[0].Update.MaxParallel = 1
ar.alloc.Job.TaskGroups[0].Update.MinHealthyTime = 100 * time.Millisecond
checkHealthy := &api.AgentCheck{
CheckID: structs.GenerateUUID(),
CheckID: uuid.Generate(),
Status: api.HealthPassing,
}
checkUnhealthy := &api.AgentCheck{
......@@ -359,7 +360,7 @@ func TestAllocRunner_DeploymentHealth_Unhealthy_Checks(t *testing.T) {
task.Config["run_for"] = "10s"
// Make the alloc be part of a deployment
ar.alloc.DeploymentID = structs.GenerateUUID()
ar.alloc.DeploymentID = uuid.Generate()
ar.alloc.Job.TaskGroups[0].Update = structs.DefaultUpdateStrategy.Copy()
ar.alloc.Job.TaskGroups[0].Update.HealthCheck = structs.UpdateStrategyHealthCheck_Checks
ar.alloc.Job.TaskGroups[0].Update.MaxParallel = 1
......@@ -367,7 +368,7 @@ func TestAllocRunner_DeploymentHealth_Unhealthy_Checks(t *testing.T) {
ar.alloc.Job.TaskGroups[0].Update.HealthyDeadline = 1 * time.Second
checkUnhealthy := &api.AgentCheck{
CheckID: structs.GenerateUUID(),
CheckID: uuid.Generate(),
Status: api.HealthWarning,
}
......@@ -428,7 +429,7 @@ func TestAllocRunner_DeploymentHealth_Healthy_UpdatedDeployment(t *testing.T) {
task.Config["run_for"] = "30s"
// Make the alloc be part of a deployment
ar.alloc.DeploymentID = structs.GenerateUUID()
ar.alloc.DeploymentID = uuid.Generate()
ar.alloc.Job.TaskGroups[0].Update = structs.DefaultUpdateStrategy.Copy()
ar.alloc.Job.TaskGroups[0].Update.HealthCheck = structs.UpdateStrategyHealthCheck_TaskStates
ar.alloc.Job.TaskGroups[0].Update.MaxParallel = 1
......@@ -455,7 +456,7 @@ func TestAllocRunner_DeploymentHealth_Healthy_UpdatedDeployment(t *testing.T) {
// Mimick an update to a new deployment id
oldCount, last := upd.Last()
last.DeploymentStatus = nil
last.DeploymentID = structs.GenerateUUID()
last.DeploymentID = uuid.Generate()
ar.Update(last)
testutil.WaitForResult(func() (bool, error) {
......
......@@ -27,6 +27,7 @@ import (
"github.com/hashicorp/nomad/command/agent/consul"
"github.com/hashicorp/nomad/helper"
"github.com/hashicorp/nomad/helper/tlsutil"
"github.com/hashicorp/nomad/helper/uuid"
"github.com/hashicorp/nomad/nomad"
"github.com/hashicorp/nomad/nomad/structs"
vaultapi "github.com/hashicorp/vault/api"
......@@ -733,12 +734,12 @@ func (c *Client) nodeID() (id, secret string, err error) {
if hostID == "" {
// Generate a random hostID if no constant ID is available on
// this platform.
hostID = structs.GenerateUUID()
hostID = uuid.Generate()
}
// Do not persist in dev mode
if c.config.DevMode {
return hostID, structs.GenerateUUID(), nil
return hostID, uuid.Generate(), nil
}
// Attempt to read existing ID
......@@ -771,7 +772,7 @@ func (c *Client) nodeID() (id, secret string, err error) {
secret = string(secretBuf)
} else {
// Generate new ID
secret = structs.GenerateUUID()
secret = uuid.Generate()
// Persist the ID
if err := ioutil.WriteFile(secretPath, []byte(secret), 0700); err != nil {
......
......@@ -16,6 +16,7 @@ import (
"github.com/hashicorp/nomad/client/fingerprint"
"github.com/hashicorp/nomad/command/agent/consul"
"github.com/hashicorp/nomad/helper"
"github.com/hashicorp/nomad/helper/uuid"
"github.com/hashicorp/nomad/nomad"
"github.com/hashicorp/nomad/nomad/mock"
"github.com/hashicorp/nomad/nomad/structs"
......@@ -908,7 +909,7 @@ func TestClient_BlockedAllocations(t *testing.T) {
// Add a new chained alloc
alloc2 := alloc.Copy()
alloc2.ID = structs.GenerateUUID()
alloc2.ID = uuid.Generate()
alloc2.Job = alloc.Job
alloc2.JobID = alloc.JobID
alloc2.PreviousAllocation = alloc.ID
......
......@@ -6,7 +6,7 @@ import (
"time"
docker "github.com/fsouza/go-dockerclient"
"github.com/hashicorp/nomad/nomad/structs"
"github.com/hashicorp/nomad/helper/uuid"
"github.com/hashicorp/nomad/testutil"
)
......@@ -46,7 +46,7 @@ func (m *mockImageClient) RemoveImage(id string) error {
func TestDockerCoordinator_ConcurrentPulls(t *testing.T) {
t.Parallel()
image := "foo"
imageID := structs.GenerateUUID()
imageID := uuid.Generate()
mapping := map[string]string{imageID: image}
// Add a delay so we can get multiple queued up
......@@ -64,7 +64,7 @@ func TestDockerCoordinator_ConcurrentPulls(t *testing.T) {
id := ""
for i := 0; i < 10; i++ {
go func() {
id, _ = coordinator.PullImage(image, nil, structs.GenerateUUID())
id, _ = coordinator.PullImage(image, nil, uuid.Generate())
}()
}
......@@ -93,7 +93,7 @@ func TestDockerCoordinator_ConcurrentPulls(t *testing.T) {
func TestDockerCoordinator_Pull_Remove(t *testing.T) {
t.Parallel()
image := "foo"
imageID := structs.GenerateUUID()
imageID := uuid.Generate()
mapping := map[string]string{imageID: image}
// Add a delay so we can get multiple queued up
......@@ -111,7 +111,7 @@ func TestDockerCoordinator_Pull_Remove(t *testing.T) {
id := ""
callerIDs := make([]string, 10, 10)
for i := 0; i < 10; i++ {
callerIDs[i] = structs.GenerateUUID()
callerIDs[i] = uuid.Generate()
id, _ = coordinator.PullImage(image, nil, callerIDs[i])
}
......@@ -157,7 +157,7 @@ func TestDockerCoordinator_Pull_Remove(t *testing.T) {
func TestDockerCoordinator_Remove_Cancel(t *testing.T) {
t.Parallel()
image := "foo"
imageID := structs.GenerateUUID()
imageID := uuid.Generate()
mapping := map[string]string{imageID: image}
mock := newMockImageClient(mapping, 1*time.Millisecond)
......@@ -170,7 +170,7 @@ func TestDockerCoordinator_Remove_Cancel(t *testing.T) {
// Create a coordinator
coordinator := NewDockerCoordinator(config)
callerID := structs.GenerateUUID()
callerID := uuid.Generate()
// Pull image
id, _ := coordinator.PullImage(image, nil, callerID)
......@@ -205,7 +205,7 @@ func TestDockerCoordinator_Remove_Cancel(t *testing.T) {
func TestDockerCoordinator_No_Cleanup(t *testing.T) {
t.Parallel()
image := "foo"
imageID := structs.GenerateUUID()
imageID := uuid.Generate()
mapping := map[string]string{imageID: image}
mock := newMockImageClient(mapping, 1*time.Millisecond)
......@@ -218,7 +218,7 @@ func TestDockerCoordinator_No_Cleanup(t *testing.T) {
// Create a coordinator
coordinator := NewDockerCoordinator(config)
callerID := structs.GenerateUUID()
callerID := uuid.Generate()
// Pull image
id, _ := coordinator.PullImage(image, nil, callerID)
......
......@@ -21,6 +21,7 @@ import (
"github.com/hashicorp/nomad/client/driver/env"
cstructs "github.com/hashicorp/nomad/client/structs"
"github.com/hashicorp/nomad/client/testutil"
"github.com/hashicorp/nomad/helper/uuid"
"github.com/hashicorp/nomad/nomad/mock"
"github.com/hashicorp/nomad/nomad/structs"
tu "github.com/hashicorp/nomad/testutil"
......@@ -1234,7 +1235,7 @@ func setupDockerVolumes(t *testing.T, cfg *config.Config, hostpath string) (*str
}
// Build alloc and task directory structure
allocDir := allocdir.NewAllocDir(testLogger(), filepath.Join(cfg.AllocDir, structs.GenerateUUID()))
allocDir := allocdir.NewAllocDir(testLogger(), filepath.Join(cfg.AllocDir, uuid.Generate()))
if err := allocDir.Build(); err != nil {
t.Fatalf("failed to build alloc dir: %v", err)
}
......
......@@ -14,6 +14,7 @@ import (
"github.com/hashicorp/nomad/client/config"
"github.com/hashicorp/nomad/client/driver/env"
"github.com/hashicorp/nomad/helper/testtask"
"github.com/hashicorp/nomad/helper/uuid"
"github.com/hashicorp/nomad/nomad/mock"
"github.com/hashicorp/nomad/nomad/structs"
)
......@@ -92,7 +93,7 @@ type testContext struct {
func testDriverContexts(t *testing.T, task *structs.Task) *testContext {
cfg := testConfig()
cfg.Node = mock.Node()
allocDir := allocdir.NewAllocDir(testLogger(), filepath.Join(cfg.AllocDir, structs.GenerateUUID()))
allocDir := allocdir.NewAllocDir(testLogger(), filepath.Join(cfg.AllocDir, uuid.Generate()))
if err := allocDir.Build(); err != nil {
t.Fatalf("AllocDir.Build() failed: %v", err)
}
......
......@@ -18,6 +18,7 @@ import (
"github.com/hashicorp/nomad/client/stats"
cstructs "github.com/hashicorp/nomad/client/structs"
"github.com/hashicorp/nomad/helper/uuid"
"github.com/hashicorp/nomad/nomad/structs"
)
......@@ -72,7 +73,7 @@ func (e *UniversalExecutor) applyLimits(pid int) error {
func (e *UniversalExecutor) configureCgroups(resources *structs.Resources) error {
e.resConCtx.groups = &cgroupConfig.Cgroup{}
e.resConCtx.groups.Resources = &cgroupConfig.Resources{}
cgroupName := structs.GenerateUUID()
cgroupName := uuid.Generate()
e.resConCtx.groups.Path = filepath.Join("/nomad", cgroupName)
// TODO: verify this is needed for things like network access
......
......@@ -4,6 +4,7 @@ import (
"reflect"
"testing"
"github.com/hashicorp/nomad/helper/uuid"
"github.com/hashicorp/nomad/nomad/mock"
"github.com/hashicorp/nomad/nomad/structs"
)
......@@ -57,7 +58,7 @@ func TestShuffleStrings(t *testing.T) {
// Generate input
inp := make([]string, 10)
for idx := range inp {
inp[idx] = structs.GenerateUUID()
inp[idx] = uuid.Generate()
}
// Copy the input
......
package vaultclient
import (
"github.com/hashicorp/nomad/helper/uuid"
"github.com/hashicorp/nomad/nomad/structs"
vaultapi "github.com/hashicorp/vault/api"
)
......@@ -44,7 +45,7 @@ func (vc *MockVaultClient) DeriveToken(a *structs.Allocation, tasks []string) (m
}
}
tokens[task] = structs.GenerateUUID()
tokens[task] = uuid.Generate()
}
return tokens, nil
......
package uuid
import (
crand "crypto/rand"
"fmt"
)
// Generate is used to generate a random UUID
func Generate() string {
buf := make([]byte, 16)
if _, err := crand.Read(buf); err != nil {
panic(fmt.Errorf("failed to read random bytes: %v", err))
}
return fmt.Sprintf("%08x-%04x-%04x-%04x-%12x",
buf[0:4],
buf[4:6],
buf[6:8],
buf[8:10],
buf[10:16])
}
package uuid
import (
"regexp"
"testing"
)
func TestGenerate(t *testing.T) {
prev := Generate()
for i := 0; i < 100; i++ {
id := Generate()
if prev == id {
t.Fatalf("Should get a new ID!")
}
matched, err := regexp.MatchString(
"[\\da-f]{8}-[\\da-f]{4}-[\\da-f]{4}-[\\da-f]{4}-[\\da-f]{12}", id)
if !matched || err != nil {
t.Fatalf("expected match %s %v %s", id, matched, err)
}
}
}
......@@ -9,6 +9,7 @@ import (
metrics "github.com/armon/go-metrics"
memdb "github.com/hashicorp/go-memdb"
"github.com/hashicorp/nomad/helper/uuid"
"github.com/hashicorp/nomad/nomad/state"
"github.com/hashicorp/nomad/nomad/structs"
)
......@@ -313,8 +314,8 @@ func (a *ACL) Bootstrap(args *structs.ACLTokenBootstrapRequest, reply *structs.A
// Create a new global management token, override any parameter
args.Token = &structs.ACLToken{
AccessorID: structs.GenerateUUID(),
SecretID: structs.GenerateUUID(),
AccessorID: uuid.Generate(),
SecretID: uuid.Generate(),
Name: "Bootstrap Token",
Type: structs.ACLManagementToken,
Global: true,
......@@ -431,8 +432,8 @@ func (a *ACL) UpsertTokens(args *structs.ACLTokenUpsertRequest, reply *structs.A
// Generate an accessor and secret ID if new
if token.AccessorID == "" {
token.AccessorID = structs.GenerateUUID()
token.SecretID = structs.GenerateUUID()
token.AccessorID = uuid.Generate()
token.SecretID = uuid.Generate()
token.CreateTime = time.Now().UTC()
} else {
......
......@@ -10,6 +10,7 @@ import (
"time"
msgpackrpc "github.com/hashicorp/net-rpc-msgpackrpc"
"github.com/hashicorp/nomad/helper/uuid"
"github.com/hashicorp/nomad/nomad/mock"
"github.com/hashicorp/nomad/nomad/structs"
"github.com/hashicorp/nomad/testutil"
......@@ -43,7 +44,7 @@ func TestACLEndpoint_GetPolicy(t *testing.T) {
assert.Equal(t, policy, resp.Policy)
// Lookup non-existing policy
get.Name = structs.GenerateUUID()
get.Name = uuid.Generate()
if err := msgpackrpc.CallWithCodec(codec, "ACL.GetPolicy", get, &resp); err != nil {
t.Fatalf("err: %v", err)
}
......@@ -160,7 +161,7 @@ func TestACLEndpoint_GetPolicies(t *testing.T) {
assert.Equal(t, policy2, resp.Policies[policy2.Name])
// Lookup non-existing policy
get.Names = []string{structs.GenerateUUID()}
get.Names = []string{uuid.Generate()}
resp = structs.ACLPolicySetResponse{}
if err := msgpackrpc.CallWithCodec(codec, "ACL.GetPolicies", get, &resp); err != nil {
t.Fatalf("err: %v", err)
......@@ -503,7 +504,7 @@ func TestACLEndpoint_GetToken(t *testing.T) {
assert.Equal(t, token, resp.Token)
// Lookup non-existing token
get.AccessorID = structs.GenerateUUID()
get.AccessorID = uuid.Generate()
if err := msgpackrpc.CallWithCodec(codec, "ACL.GetToken", get, &resp); err != nil {
t.Fatalf("err: %v", err)
}
......@@ -619,7 +620,7 @@ func TestACLEndpoint_GetTokens(t *testing.T) {
assert.Equal(t, token, resp.Tokens[token.AccessorID])
// Lookup non-existing token
get.AccessorIDS = []string{structs.GenerateUUID()}
get.AccessorIDS = []string{uuid.Generate()}
resp = structs.ACLTokenSetResponse{}
if err := msgpackrpc.CallWithCodec(codec, "ACL.GetTokens", get, &resp); err != nil {
t.Fatalf("err: %v", err)
......@@ -1060,7 +1061,7 @@ func TestACLEndpoint_ResolveToken(t *testing.T) {
assert.Equal(t, token, resp.Token)
// Lookup non-existing token
get.SecretID = structs.GenerateUUID()
get.SecretID = uuid.Generate()
if err := msgpackrpc.CallWithCodec(codec, "ACL.ResolveToken", get, &resp); err != nil {
t.Fatalf("err: %v", err)
}
......
......@@ -6,6 +6,7 @@ import (
lru "github.com/hashicorp/golang-lru"
"github.com/hashicorp/nomad/acl"
"github.com/hashicorp/nomad/helper/uuid"
"github.com/hashicorp/nomad/nomad/mock"
"github.com/hashicorp/nomad/nomad/state"
"github.com/hashicorp/nomad/nomad/structs"
......@@ -41,7 +42,7 @@ func TestResolveACLToken(t *testing.T) {
assert.NotNil(t, aclObj)
// Attempt resolution of unknown token. Should fail.
randID := structs.GenerateUUID()
randID := uuid.Generate()
aclObj, err = resolveTokenFromSnapshotCache(snap, cache, randID)
assert.Equal(t, structs.ErrTokenNotFound, err)
assert.Nil(t, aclObj)
......
......@@ -10,6 +10,7 @@ import (
memdb "github.com/hashicorp/go-memdb"
"github.com/hashicorp/nomad/helper"
"github.com/hashicorp/nomad/helper/uuid"
"github.com/hashicorp/nomad/nomad/state"
"github.com/hashicorp/nomad/nomad/structs"
)
......@@ -445,7 +446,7 @@ func (w *deploymentWatcher) createEvalBatched(forIndex uint64) {
// getEval returns an evaluation suitable for the deployment
func (w *deploymentWatcher) getEval() *structs.Evaluation {
return &structs.Evaluation{
ID: structs.GenerateUUID(),
ID: uuid.Generate(),
Namespace: w.j.Namespace,
Priority: w.j.Priority,
Type: w.j.Type,
......
......@@ -7,6 +7,7 @@ import (
memdb "github.com/hashicorp/go-memdb"
"github.com/hashicorp/nomad/helper"
"github.com/hashicorp/nomad/helper/uuid"
"github.com/hashicorp/nomad/nomad/mock"
"github.com/hashicorp/nomad/nomad/structs"
"github.com/hashicorp/nomad/testutil"
......@@ -83,13 +84,13 @@ func TestWatcher_UnknownDeployment(t *testing.T) {
w.SetEnabled(true, m.state)
// The expected error is that it should be an unknown deployment
dID := structs.GenerateUUID()
dID := uuid.Generate()
expected := fmt.Sprintf("unknown deployment %q", dID)
// Request setting the health against an unknown deployment
req := &structs.DeploymentAllocHealthRequest{
DeploymentID: dID,
HealthyAllocationIDs: []string{structs.GenerateUUID()},
HealthyAllocationIDs: []string{uuid.Generate()},
}
var resp structs.DeploymentUpdateResponse
err := w.SetAllocHealth(req, &resp)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment