... | ... |
@@ -1,10 +1,10 @@ |
1 | 1 |
package docker |
2 | 2 |
|
3 | 3 |
import ( |
4 |
+ "fmt" |
|
4 | 5 |
"io/ioutil" |
5 | 6 |
"sync" |
6 | 7 |
"testing" |
7 |
- "fmt" |
|
8 | 8 |
) |
9 | 9 |
|
10 | 10 |
// mkTestContext generates a build context from the contents of the provided dockerfile. |
... | ... |
@@ -104,8 +104,8 @@ func TestBuild(t *testing.T) { |
104 | 104 |
defer nuke(runtime) |
105 | 105 |
|
106 | 106 |
srv := &Server{ |
107 |
- runtime: runtime, |
|
108 |
- lock: &sync.Mutex{}, |
|
107 |
+ runtime: runtime, |
|
108 |
+ lock: &sync.Mutex{}, |
|
109 | 109 |
pullingPool: make(map[string]struct{}), |
110 | 110 |
pushingPool: make(map[string]struct{}), |
111 | 111 |
} |
... | ... |
@@ -511,12 +511,15 @@ func TestKillDifferentUser(t *testing.T) { |
511 | 511 |
t.Fatal(err) |
512 | 512 |
} |
513 | 513 |
|
514 |
- setTimeout(t, "Waiting for the container to be started timed out", 2 * time.Second, func() { |
|
514 |
+ setTimeout(t, "Waiting for the container to be started timed out", 2*time.Second, func() { |
|
515 | 515 |
for !container.State.Running { |
516 | 516 |
time.Sleep(10 * time.Millisecond) |
517 | 517 |
} |
518 | 518 |
}) |
519 | 519 |
|
520 |
+ // Even if the state is running, lets give some time to lxc to spawn the process |
|
521 |
+ container.WaitTimeout(500 * time.Millisecond) |
|
522 |
+ |
|
520 | 523 |
if err := container.Kill(); err != nil { |
521 | 524 |
t.Fatal(err) |
522 | 525 |
} |
... | ... |
@@ -366,14 +366,14 @@ func TestAllocatePortLocalhost(t *testing.T) { |
366 | 366 |
defer container.Kill() |
367 | 367 |
|
368 | 368 |
setTimeout(t, "Waiting for the container to be started timed out", 2*time.Second, func() { |
369 |
- for { |
|
370 |
- if container.State.Running { |
|
371 |
- break |
|
372 |
- } |
|
369 |
+ for !container.State.Running { |
|
373 | 370 |
time.Sleep(10 * time.Millisecond) |
374 | 371 |
} |
375 | 372 |
}) |
376 | 373 |
|
374 |
+ // Even if the state is running, lets give some time to lxc to spawn the process |
|
375 |
+ container.WaitTimeout(500 * time.Millisecond) |
|
376 |
+ |
|
377 | 377 |
conn, err := net.Dial("tcp", |
378 | 378 |
fmt.Sprintf( |
379 | 379 |
"localhost:%s", container.NetworkSettings.PortMapping[strconv.Itoa(port)], |