mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
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 <aaron.lehmann@docker.com>
This commit is contained in:
parent
2892de760f
commit
0757a52737
1 changed files with 6 additions and 10 deletions
|
@ -250,15 +250,11 @@ func TestSuccessfulDownload(t *testing.T) {
|
||||||
|
|
||||||
progressChan := make(chan progress.Progress)
|
progressChan := make(chan progress.Progress)
|
||||||
progressDone := make(chan struct{})
|
progressDone := make(chan struct{})
|
||||||
receivedProgress := make(map[string]int64)
|
receivedProgress := make(map[string]progress.Progress)
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
for p := range progressChan {
|
for p := range progressChan {
|
||||||
if p.Action == "Downloading" {
|
receivedProgress[p.ID] = p
|
||||||
receivedProgress[p.ID] = p.Current
|
|
||||||
} else if p.Action == "Already exists" {
|
|
||||||
receivedProgress[p.ID] = -1
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
close(progressDone)
|
close(progressDone)
|
||||||
}()
|
}()
|
||||||
|
@ -293,11 +289,11 @@ func TestSuccessfulDownload(t *testing.T) {
|
||||||
descriptor := d.(*mockDownloadDescriptor)
|
descriptor := d.(*mockDownloadDescriptor)
|
||||||
|
|
||||||
if descriptor.diffID != "" {
|
if descriptor.diffID != "" {
|
||||||
if receivedProgress[d.ID()] != -1 {
|
if receivedProgress[d.ID()].Action != "Already exists" {
|
||||||
t.Fatalf("did not get 'already exists' message for %v", d.ID())
|
t.Fatalf("did not get 'Already exists' message for %v", d.ID())
|
||||||
}
|
}
|
||||||
} else if receivedProgress[d.ID()] != 10 {
|
} else if receivedProgress[d.ID()].Action != "Pull complete" {
|
||||||
t.Fatalf("missing or wrong progress output for %v (got: %d)", d.ID(), receivedProgress[d.ID()])
|
t.Fatalf("did not get 'Pull complete' message for %v", d.ID())
|
||||||
}
|
}
|
||||||
|
|
||||||
if rootFS.DiffIDs[i] != descriptor.expectedDiffID {
|
if rootFS.DiffIDs[i] != descriptor.expectedDiffID {
|
||||||
|
|
Loading…
Reference in a new issue