nixosTests.overlayfs: Port tests to python
This commit is contained in:
parent
5425557214
commit
5ae92144ba
|
@ -1,4 +1,4 @@
|
||||||
import ./make-test.nix ({ pkgs, ... }: {
|
import ./make-test-python.nix ({ pkgs, ... }: {
|
||||||
name = "overlayfs";
|
name = "overlayfs";
|
||||||
meta.maintainers = with pkgs.stdenv.lib.maintainers; [ bachp ];
|
meta.maintainers = with pkgs.stdenv.lib.maintainers; [ bachp ];
|
||||||
|
|
||||||
|
@ -9,49 +9,42 @@ import ./make-test.nix ({ pkgs, ... }: {
|
||||||
};
|
};
|
||||||
|
|
||||||
testScript = ''
|
testScript = ''
|
||||||
$machine->succeed("ls /dev");
|
machine.succeed("ls /dev")
|
||||||
|
|
||||||
$machine->succeed("mkdir -p /tmp/mnt");
|
machine.succeed("mkdir -p /tmp/mnt")
|
||||||
|
|
||||||
# Test ext4 + overlayfs
|
# Test ext4 + overlayfs
|
||||||
$machine->succeed(
|
machine.succeed(
|
||||||
|
"""
|
||||||
"mkfs.ext4 -F -L overlay-ext4 /dev/vdb",
|
mkfs.ext4 -F -L overlay-ext4 /dev/vdb
|
||||||
"mount -t ext4 /dev/vdb /tmp/mnt",
|
mount -t ext4 /dev/vdb /tmp/mnt
|
||||||
|
mkdir -p /tmp/mnt/upper /tmp/mnt/lower /tmp/mnt/work /tmp/mnt/merged
|
||||||
"mkdir -p /tmp/mnt/upper /tmp/mnt/lower /tmp/mnt/work /tmp/mnt/merged",
|
# Setup some existing files
|
||||||
|
echo 'Replace' > /tmp/mnt/lower/replace.txt
|
||||||
# Setup some existing files
|
echo 'Append' > /tmp/mnt/lower/append.txt
|
||||||
"echo 'Replace' > /tmp/mnt/lower/replace.txt",
|
echo 'Overwrite' > /tmp/mnt/lower/overwrite.txt
|
||||||
"echo 'Append' > /tmp/mnt/lower/append.txt",
|
mount -t overlay overlay -o lowerdir=/tmp/mnt/lower,upperdir=/tmp/mnt/upper,workdir=/tmp/mnt/work /tmp/mnt/merged
|
||||||
"echo 'Overwrite' > /tmp/mnt/lower/overwrite.txt",
|
# Test new
|
||||||
|
echo 'New' > /tmp/mnt/merged/new.txt
|
||||||
"mount -t overlay overlay -o lowerdir=/tmp/mnt/lower,upperdir=/tmp/mnt/upper,workdir=/tmp/mnt/work /tmp/mnt/merged",
|
[[ "\$(cat /tmp/mnt/merged/new.txt)" == "New" ]]
|
||||||
|
# Test replace
|
||||||
# Test new
|
[[ "\$(cat /tmp/mnt/merged/replace.txt)" == "Replace" ]]
|
||||||
"echo 'New' > /tmp/mnt/merged/new.txt",
|
echo 'Replaced' > /tmp/mnt/merged/replace-tmp.txt
|
||||||
"[[ \"\$(cat /tmp/mnt/merged/new.txt)\" == \"New\" ]]",
|
mv /tmp/mnt/merged/replace-tmp.txt /tmp/mnt/merged/replace.txt
|
||||||
|
[[ "\$(cat /tmp/mnt/merged/replace.txt)" == "Replaced" ]]
|
||||||
# Test replace
|
# Overwrite
|
||||||
"[[ \"\$(cat /tmp/mnt/merged/replace.txt)\" == \"Replace\" ]]",
|
[[ "\$(cat /tmp/mnt/merged/overwrite.txt)" == "Overwrite" ]]
|
||||||
"echo 'Replaced' > /tmp/mnt/merged/replace-tmp.txt",
|
echo 'Overwritten' > /tmp/mnt/merged/overwrite.txt
|
||||||
"mv /tmp/mnt/merged/replace-tmp.txt /tmp/mnt/merged/replace.txt",
|
[[ "\$(cat /tmp/mnt/merged/overwrite.txt)" == "Overwritten" ]]
|
||||||
"[[ \"\$(cat /tmp/mnt/merged/replace.txt)\" == \"Replaced\" ]]",
|
# Test append
|
||||||
|
[[ "\$(cat /tmp/mnt/merged/append.txt)" == "Append" ]]
|
||||||
# Overwrite
|
echo 'ed' >> /tmp/mnt/merged/append.txt
|
||||||
"[[ \"\$(cat /tmp/mnt/merged/overwrite.txt)\" == \"Overwrite\" ]]",
|
#"cat /tmp/mnt/merged/append.txt && exit 1
|
||||||
"echo 'Overwritten' > /tmp/mnt/merged/overwrite.txt",
|
[[ "\$(cat /tmp/mnt/merged/append.txt)" == "Append\ned" ]]
|
||||||
"[[ \"\$(cat /tmp/mnt/merged/overwrite.txt)\" == \"Overwritten\" ]]",
|
umount /tmp/mnt/merged
|
||||||
|
umount /tmp/mnt
|
||||||
# Test append
|
udevadm settle
|
||||||
"[[ \"\$(cat /tmp/mnt/merged/append.txt)\" == \"Append\" ]]",
|
"""
|
||||||
"echo 'ed' >> /tmp/mnt/merged/append.txt",
|
)
|
||||||
#"cat /tmp/mnt/merged/append.txt && exit 1",
|
|
||||||
"[[ \"\$(cat /tmp/mnt/merged/append.txt)\" == \"Append\ned\" ]]",
|
|
||||||
|
|
||||||
"umount /tmp/mnt/merged",
|
|
||||||
"umount /tmp/mnt",
|
|
||||||
"udevadm settle"
|
|
||||||
);
|
|
||||||
'';
|
'';
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in a new issue