Skip to content

Commit 0c36cb3

Browse files
committed
fork test: assert mem-file at snapshot-base after firecracker restore
Firecracker enables snapshot base reuse, which renames the post-restore snapshot dir from snapshot-latest to snapshot-base. The hardlink survives the rename (same inode), so the test just needs the right path.
1 parent bf1807f commit 0c36cb3

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

lib/instances/firecracker_test.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -622,10 +622,15 @@ func TestFirecrackerForkFromTemplate(t *testing.T) {
622622
// (b) The fork's mem-file must share the source's inode (hardlink), not
623623
// be a copy. We can't compare paths because the link is by inode; we
624624
// compare st_ino + st_dev between the two instances' mem-files.
625-
forkMemPath := filepath.Join(p.InstanceSnapshotLatest(forkID), templateSharedMemFileName)
625+
//
626+
// Firecracker retains the post-restore snapshot dir as snapshot-base
627+
// (see restoreRetainedSnapshotBase), so after the Standby -> Running
628+
// transition the hardlink lives under snapshot-base/, not snapshot-latest/.
629+
// Hardlinks survive the rename because they bind to the inode.
630+
forkMemPath := filepath.Join(p.InstanceSnapshotBase(forkID), templateSharedMemFileName)
626631
srcMemPath := filepath.Join(p.InstanceSnapshotLatest(sourceID), templateSharedMemFileName)
627632
forkInfo, err := os.Stat(forkMemPath)
628-
require.NoError(t, err, "fork mem-file should exist at snapshot-latest/memory")
633+
require.NoError(t, err, "fork mem-file should exist at snapshot-base/memory after restore")
629634
assert.True(t, forkInfo.Mode().IsRegular(), "fork mem-file should be a regular file (hardlink), not a symlink")
630635
srcInfo, err := os.Stat(srcMemPath)
631636
require.NoError(t, err)

0 commit comments

Comments
 (0)