mirror of
https://github.com/netbirdio/gvisor.git
synced 2026-05-22 17:12:49 -07:00
Add test case to TestCheckpointRestore
TestCheckpointRestore was testing that container can be restored into a new one (e.g. clone) - twice. Change one of the restores to use the same identity, to test the case where the same container is being saved and then resumed at a later time. PiperOrigin-RevId: 552866396
This commit is contained in:
committed by
gVisor bot
parent
aa2c8c33c6
commit
8baec93b4c
@@ -1096,7 +1096,8 @@ func TestCheckpointRestore(t *testing.T) {
|
||||
}
|
||||
defer outputFile2.Close()
|
||||
|
||||
// Restore into a new container.
|
||||
// Restore into a new container with different ID (e.g. clone). Keep the
|
||||
// initial container running to ensure no conflict with it.
|
||||
args2 := Args{
|
||||
ID: testutil.RandomContainerID(),
|
||||
Spec: spec,
|
||||
@@ -1122,14 +1123,19 @@ func TestCheckpointRestore(t *testing.T) {
|
||||
t.Fatalf("error with outputFile: %v", err)
|
||||
}
|
||||
|
||||
// Check that lastNum is one less than firstNum and that the container picks
|
||||
// up from where it left off.
|
||||
// Check that lastNum is one less than firstNum and that the container
|
||||
// picks up from where it left off.
|
||||
if lastNum+1 != firstNum {
|
||||
t.Errorf("error numbers not in order, previous: %d, next: %d", lastNum, firstNum)
|
||||
}
|
||||
cont2.Destroy()
|
||||
cont2 = nil
|
||||
|
||||
// Restore into a container using the same ID (e.g. save/resume). It requires
|
||||
// the original container to cease to exist because they share the same identity.
|
||||
cont.Destroy()
|
||||
cont = nil
|
||||
|
||||
// Restore into another container!
|
||||
// Delete and recreate file before restoring.
|
||||
if err := os.Remove(outputPath); err != nil {
|
||||
t.Fatalf("error removing file")
|
||||
@@ -1140,13 +1146,7 @@ func TestCheckpointRestore(t *testing.T) {
|
||||
}
|
||||
defer outputFile3.Close()
|
||||
|
||||
// Restore into a new container.
|
||||
args3 := Args{
|
||||
ID: testutil.RandomContainerID(),
|
||||
Spec: spec,
|
||||
BundleDir: bundleDir,
|
||||
}
|
||||
cont3, err := New(conf, args3)
|
||||
cont3, err := New(conf, args)
|
||||
if err != nil {
|
||||
t.Fatalf("error creating container: %v", err)
|
||||
}
|
||||
@@ -1166,8 +1166,8 @@ func TestCheckpointRestore(t *testing.T) {
|
||||
t.Fatalf("error with outputFile: %v", err)
|
||||
}
|
||||
|
||||
// Check that lastNum is one less than firstNum and that the container picks
|
||||
// up from where it left off.
|
||||
// Check that lastNum is one less than firstNum and that the container
|
||||
// picks up from where it left off.
|
||||
if lastNum+1 != firstNum2 {
|
||||
t.Errorf("error numbers not in order, previous: %d, next: %d", lastNum, firstNum2)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user