mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Merge branch 'master' of ssh://github.com/dotcloud/docker
This commit is contained in:
commit
dbc7fb7575
2 changed files with 28 additions and 8 deletions
|
@ -70,10 +70,14 @@ func loadContainer(containerPath string) (*Container, error) {
|
|||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
container := &Container{}
|
||||
container := &Container{
|
||||
stdout: newWriteBroadcaster(),
|
||||
stderr: newWriteBroadcaster(),
|
||||
}
|
||||
if err := json.Unmarshal(data, container); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
container.State = newState()
|
||||
return container, nil
|
||||
}
|
||||
|
||||
|
|
|
@ -179,23 +179,32 @@ func TestRestore(t *testing.T) {
|
|||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
docker, err := NewFromDirectory(root)
|
||||
|
||||
// Create a container with one instance of docker
|
||||
docker1, err := NewFromDirectory(root)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
container, err := docker.Create(
|
||||
"test",
|
||||
container1, err := docker1.Create(
|
||||
"restore_test",
|
||||
"ls",
|
||||
[]string{"-al"},
|
||||
[]string{"/var/lib/docker/images/ubuntu"},
|
||||
&Config{},
|
||||
)
|
||||
if len(docker.List()) != 1 {
|
||||
t.Errorf("Expected 1 container, %v found", len(docker.List()))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer docker1.Destroy(container1)
|
||||
if len(docker1.List()) != 1 {
|
||||
t.Errorf("Expected 1 container, %v found", len(docker1.List()))
|
||||
}
|
||||
if err := container1.Run(); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
defer docker.Destroy(container)
|
||||
|
||||
// Here are are simulating a docker restart - that is, reloading all containers
|
||||
// from scratch
|
||||
docker2, err := NewFromDirectory(root)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
|
@ -203,4 +212,11 @@ func TestRestore(t *testing.T) {
|
|||
if len(docker2.List()) != 1 {
|
||||
t.Errorf("Expected 1 container, %v found", len(docker2.List()))
|
||||
}
|
||||
container2 := docker2.Get("restore_test")
|
||||
if container2 == nil {
|
||||
t.Fatal("Unable to Get container")
|
||||
}
|
||||
if err := container2.Run(); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue