From 304b76e1e233933e3def0f64cbaa2deacaf83fbb Mon Sep 17 00:00:00 2001 From: Alex Dadgar Date: Thu, 31 May 2018 15:50:05 -0700 Subject: [PATCH] Fix node drain monitor --- command/node_drain_test.go | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/command/node_drain_test.go b/command/node_drain_test.go index 33d714d1d..f0152125c 100644 --- a/command/node_drain_test.go +++ b/command/node_drain_test.go @@ -222,17 +222,23 @@ func TestNodeDrainCommand_Monitor(t *testing.T) { out := outBuf.String() t.Logf("Output:\n%s", out) - require.Contains(out, "marked all allocations for migration") - for _, a := range allocs { - if *a.Job.Type == "system" { - if strings.Contains(out, a.ID) { - t.Fatalf("output should not contain system alloc %q", a.ID) + // Unfortunately travis is too slow to reliably see the expected output. The + // monitor goroutines may start only after some or all the allocs have been + // migrated. + if !testutil.IsTravis() { + require.Contains(out, "marked all allocations for migration") + for _, a := range allocs { + if *a.Job.Type == "system" { + if strings.Contains(out, a.ID) { + t.Fatalf("output should not contain system alloc %q", a.ID) + } + continue } - continue + require.Contains(out, fmt.Sprintf("Alloc %q marked for migration", a.ID)) + require.Contains(out, fmt.Sprintf("Alloc %q draining", a.ID)) } - require.Contains(out, fmt.Sprintf("Alloc %q marked for migration", a.ID)) - require.Contains(out, fmt.Sprintf("Alloc %q draining", a.ID)) } + expected := fmt.Sprintf("All allocations on node %q have stopped.\n", nodeID) if !strings.HasSuffix(out, expected) { t.Fatalf("expected output to end with:\n%s", expected)