From 96baafebd36532adea9b41b3ccce6cfc6b86f1f7 Mon Sep 17 00:00:00 2001 From: Michael Schurter Date: Fri, 21 Jul 2017 16:17:23 -0700 Subject: [PATCH] Minor test race fix --- client/alloc_runner_test.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/client/alloc_runner_test.go b/client/alloc_runner_test.go index 498a6d532..b1fed0e16 100644 --- a/client/alloc_runner_test.go +++ b/client/alloc_runner_test.go @@ -559,6 +559,9 @@ func TestAllocRunner_Destroy(t *testing.T) { func TestAllocRunner_Update(t *testing.T) { _, ar := testAllocRunner(false) + // Deep copy the alloc to avoid races when updating + newAlloc := ar.Alloc().Copy() + // Ensure task takes some time task := ar.alloc.Job.TaskGroups[0].Tasks[0] task.Driver = "mock_driver" @@ -567,8 +570,6 @@ func TestAllocRunner_Update(t *testing.T) { defer ar.Destroy() // Update the alloc definition - newAlloc := new(structs.Allocation) - *newAlloc = *ar.alloc newAlloc.Name = "FOO" newAlloc.AllocModifyIndex++ ar.Update(newAlloc)