From 0757a52737b283e56c9a8f5597e8b52c365ce1f6 Mon Sep 17 00:00:00 2001 From: Aaron Lehmann Date: Mon, 11 Jan 2016 09:46:34 -0800 Subject: [PATCH] Fix flaky test TestSuccessfulDownload One of the things this test checks is that the progress indicator completes for each download. Some progress messages may be lost because only one message is buffered for each download, but the last progress message is guaranteed not to be lost. The test therefore checks for a 10/10 progress indication. However, the assumption that this is the last progress message to be sent is incorrect. The last message is actually "Pull complete". So check for this instead. Signed-off-by: Aaron Lehmann --- distribution/xfer/download_test.go | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/distribution/xfer/download_test.go b/distribution/xfer/download_test.go index 5d42703e63..521b0b6e01 100644 --- a/distribution/xfer/download_test.go +++ b/distribution/xfer/download_test.go @@ -250,15 +250,11 @@ func TestSuccessfulDownload(t *testing.T) { progressChan := make(chan progress.Progress) progressDone := make(chan struct{}) - receivedProgress := make(map[string]int64) + receivedProgress := make(map[string]progress.Progress) go func() { for p := range progressChan { - if p.Action == "Downloading" { - receivedProgress[p.ID] = p.Current - } else if p.Action == "Already exists" { - receivedProgress[p.ID] = -1 - } + receivedProgress[p.ID] = p } close(progressDone) }() @@ -293,11 +289,11 @@ func TestSuccessfulDownload(t *testing.T) { descriptor := d.(*mockDownloadDescriptor) if descriptor.diffID != "" { - if receivedProgress[d.ID()] != -1 { - t.Fatalf("did not get 'already exists' message for %v", d.ID()) + if receivedProgress[d.ID()].Action != "Already exists" { + t.Fatalf("did not get 'Already exists' message for %v", d.ID()) } - } else if receivedProgress[d.ID()] != 10 { - t.Fatalf("missing or wrong progress output for %v (got: %d)", d.ID(), receivedProgress[d.ID()]) + } else if receivedProgress[d.ID()].Action != "Pull complete" { + t.Fatalf("did not get 'Pull complete' message for %v", d.ID()) } if rootFS.DiffIDs[i] != descriptor.expectedDiffID {