зеркало из https://github.com/microsoft/docker.git
Merge pull request #1101 from dotcloud/fix-unit_tests
add sleep in tests and go fmt
This commit is contained in:
Коммит
8f9dd86146
|
@ -1,10 +1,10 @@
|
||||||
package docker
|
package docker
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"sync"
|
"sync"
|
||||||
"testing"
|
"testing"
|
||||||
"fmt"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// mkTestContext generates a build context from the contents of the provided dockerfile.
|
// mkTestContext generates a build context from the contents of the provided dockerfile.
|
||||||
|
@ -104,8 +104,8 @@ func TestBuild(t *testing.T) {
|
||||||
defer nuke(runtime)
|
defer nuke(runtime)
|
||||||
|
|
||||||
srv := &Server{
|
srv := &Server{
|
||||||
runtime: runtime,
|
runtime: runtime,
|
||||||
lock: &sync.Mutex{},
|
lock: &sync.Mutex{},
|
||||||
pullingPool: make(map[string]struct{}),
|
pullingPool: make(map[string]struct{}),
|
||||||
pushingPool: make(map[string]struct{}),
|
pushingPool: make(map[string]struct{}),
|
||||||
}
|
}
|
||||||
|
|
|
@ -511,12 +511,15 @@ func TestKillDifferentUser(t *testing.T) {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
setTimeout(t, "Waiting for the container to be started timed out", 2 * time.Second, func() {
|
setTimeout(t, "Waiting for the container to be started timed out", 2*time.Second, func() {
|
||||||
for !container.State.Running {
|
for !container.State.Running {
|
||||||
time.Sleep(10 * time.Millisecond)
|
time.Sleep(10 * time.Millisecond)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// Even if the state is running, lets give some time to lxc to spawn the process
|
||||||
|
container.WaitTimeout(500 * time.Millisecond)
|
||||||
|
|
||||||
if err := container.Kill(); err != nil {
|
if err := container.Kill(); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -366,14 +366,14 @@ func TestAllocatePortLocalhost(t *testing.T) {
|
||||||
defer container.Kill()
|
defer container.Kill()
|
||||||
|
|
||||||
setTimeout(t, "Waiting for the container to be started timed out", 2*time.Second, func() {
|
setTimeout(t, "Waiting for the container to be started timed out", 2*time.Second, func() {
|
||||||
for {
|
for !container.State.Running {
|
||||||
if container.State.Running {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
time.Sleep(10 * time.Millisecond)
|
time.Sleep(10 * time.Millisecond)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// Even if the state is running, lets give some time to lxc to spawn the process
|
||||||
|
container.WaitTimeout(500 * time.Millisecond)
|
||||||
|
|
||||||
conn, err := net.Dial("tcp",
|
conn, err := net.Dial("tcp",
|
||||||
fmt.Sprintf(
|
fmt.Sprintf(
|
||||||
"localhost:%s", container.NetworkSettings.PortMapping[strconv.Itoa(port)],
|
"localhost:%s", container.NetworkSettings.PortMapping[strconv.Itoa(port)],
|
||||||
|
|
Загрузка…
Ссылка в новой задаче