Skip to content

Commit dd59296

Browse files
pb8ozulinx86
authored andcommitted
test: Use tmpfs for all the chroots
Currently /srv is a Docker volume backed by an overlay filesystem on top of whatever the rootfs block device. The overlay filesystem is slow, so rather than having tests opt-in to using a ramfs, do this by default for all tests. This also simplifies the ramfs logic. Signed-off-by: Pablo Barbáchano <[email protected]>
1 parent 2208672 commit dd59296

File tree

4 files changed

+5
-74
lines changed

4 files changed

+5
-74
lines changed

.buildkite/pipeline_perf.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"block": {
1111
"label": "🖴 Block Performance",
1212
"test_path": "integration_tests/performance/test_block_performance.py",
13-
"devtool_opts": "-r 16834m -c 1-10 -m 0",
13+
"devtool_opts": "-c 1-10 -m 0",
1414
"timeout_in_minutes": 240,
1515
},
1616
"snapshot-latency": {

tests/conftest.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,6 @@ def test_fc_session_root_path():
169169
prefix="fctest-", dir=defs.DEFAULT_TEST_SESSION_ROOT_PATH
170170
)
171171
yield fc_session_root_path
172-
shutil.rmtree(fc_session_root_path)
173172

174173

175174
@pytest.fixture(scope="session")
@@ -315,6 +314,7 @@ def kill(self):
315314
for vm in self.vms:
316315
vm.kill()
317316
vm.jailer.cleanup()
317+
shutil.rmtree(vm.jailer.chroot_base_with_id())
318318
shutil.rmtree(self.tmp_path)
319319

320320
uvm_factory = MicroVMFactory(fc_tmp_path, bin_cloner_path)

tests/framework/jailer.py

-3
Original file line numberDiff line numberDiff line change
@@ -248,9 +248,6 @@ def cleanup(self):
248248
if self._ramfs_path:
249249
utils.run_cmd("umount {}".format(self._ramfs_path), ignore_return_code=True)
250250

251-
if self.jailer_id is not None:
252-
shutil.rmtree(self.chroot_base_with_id(), ignore_errors=True)
253-
254251
if self.netns and os.path.exists("/var/run/netns/{}".format(self.netns)):
255252
try:
256253
utils.run_cmd("ip netns del {}".format(self.netns))

tools/devtool

+3-69
Original file line numberDiff line numberDiff line change
@@ -137,9 +137,6 @@ OPT_UNATTENDED=false
137137
# Get the target prefix to avoid repeated calls to uname -m
138138
TARGET_PREFIX="$(uname -m)-unknown-linux-"
139139

140-
DEFAULT_TEST_SESSION_ROOT_PATH=/srv
141-
DEFAULT_RAMDISK_PATH=/mnt/devtool-ramdisk
142-
143140

144141
# Check if Docker is available and exit if it's not.
145142
# Upon returning from this call, the caller can be certain Docker is available.
@@ -312,6 +309,8 @@ run_devctr() {
312309
--rm \
313310
--volume /dev:/dev \
314311
--volume "$FC_ROOT_DIR:$CTR_FC_ROOT_DIR:z" \
312+
--tmpfs /srv:exec,dev,size=32G \
313+
-v /boot:/boot \
315314
--env PYTHONDONTWRITEBYTECODE=1 \
316315
"$DEVCTR_IMAGE" "${ctr_args[@]}"
317316
}
@@ -410,11 +409,6 @@ cmd_help() {
410409
echo " will be passed through to pytest."
411410
echo " -c, --cpuset-cpus cpulist Set a dedicated cpulist to be used by the tests."
412411
echo " -m, --cpuset-mems memlist Set a dedicated memlist to be used by the tests."
413-
echo " -r, --ramdisk size[k|m|g] Use a ramdisk of 'size' MB for
414-
the entire test session (e.g
415-
stored artifacts, Firecracker
416-
binaries, logs/metrics FIFOs
417-
and test created device files)."
418412
echo ""
419413
}
420414

@@ -511,34 +505,6 @@ cmd_distclean() {
511505
fi
512506
}
513507

514-
mount_ramdisk() {
515-
local ramdisk_size="$1"
516-
umount_ramdisk
517-
DEFAULT_RAMDISK_PATH=$(sudo mktemp -d /mnt/devtool-ramdisk.XXXXXX)
518-
ok_or_die "Could not create ramdisk directory"
519-
sudo mkdir -p ${DEFAULT_RAMDISK_PATH} && \
520-
sudo mount -t tmpfs -o size=${ramdisk_size} tmpfs ${DEFAULT_RAMDISK_PATH}
521-
ok_or_die "Failed to mount ramdisk to ${DEFAULT_RAMDISK_PATH}. Check the permission."
522-
sudo mkdir -p ${DEFAULT_RAMDISK_PATH}/srv
523-
sudo mkdir -p ${DEFAULT_RAMDISK_PATH}/tmp
524-
525-
say "Using ramdisk: ${DEFAULT_RAMDISK_PATH}"
526-
}
527-
528-
umount_ramdisk() {
529-
if [ ! -e "${DEFAULT_RAMDISK_PATH}" ]; then
530-
return 0
531-
fi
532-
if [ ! -d "${DEFAULT_RAMDISK_PATH}" ]; then
533-
die "${DEFAULT_RAMDISK_PATH} is not a directory."
534-
fi
535-
if [ ! -w "${DEFAULT_RAMDISK_PATH}" ]; then
536-
die "Failed to unmount ${DEFAULT_RAMDISK_PATH}. Check the permission."
537-
fi
538-
sudo umount ${DEFAULT_RAMDISK_PATH} &>/dev/null
539-
sudo rmdir ${DEFAULT_RAMDISK_PATH} &>/dev/null
540-
}
541-
542508
ensure_ci_artifacts() {
543509
# Fetch all the artifacts so they are local
544510
say "Fetching CI artifacts from S3"
@@ -570,11 +536,6 @@ cmd_test() {
570536
shift
571537
local cpuset_mems="$1"
572538
;;
573-
"-r"|"--ramdisk")
574-
shift
575-
local ramdisk_size="$1"
576-
local ramdisk=true
577-
;;
578539
"--") { shift; break; } ;;
579540
*)
580541
die "Unknown argument: $1. Please use --help for help."
@@ -594,11 +555,6 @@ cmd_test() {
594555
say "$(lscpu)"
595556
say "Starting test run ..."
596557

597-
if [[ $ramdisk = true ]]; then
598-
mount_ramdisk ${ramdisk_size}
599-
ramdisk_args="--env TMPDIR=${DEFAULT_TEST_SESSION_ROOT_PATH}/tmp --volume ${DEFAULT_RAMDISK_PATH}:${DEFAULT_TEST_SESSION_ROOT_PATH}"
600-
fi
601-
602558
# Testing (running Firecracker via the jailer) needs root access,
603559
# in order to set-up the Firecracker jail (manipulating cgroups, net
604560
# namespaces, etc).
@@ -628,19 +584,13 @@ cmd_test() {
628584
--cpuset-cpus="$cpuset_cpus" \
629585
--cpuset-mems="$cpuset_mems" \
630586
--env-file env.list \
631-
-v /boot:/boot \
632-
${ramdisk_args} \
633587
-- \
634588
./tools/test.sh "$@"
635589

636590
ret=$?
637591

638592
say "Finished test run ..."
639593

640-
if [[ $ramdisk = true ]]; then
641-
umount_ramdisk
642-
fi
643-
644594
# Running as root would have created some root-owned files under the build
645595
# dir. Let's fix that.
646596
cmd_fix_perms
@@ -664,12 +614,7 @@ cmd_shell() {
664614
case "$1" in
665615
"-h"|"--help") { cmd_help; exit 1; } ;;
666616
"-p"|"--privileged") { privileged=true; } ;;
667-
"-r"|"--ramdisk")
668-
shift
669-
local ramdisk_size="$1"
670-
local ramdisk=true
671-
;;
672-
"--") { shift; break; } ;;
617+
"--") { shift; break; } ;;
673618
*)
674619
die "Unknown argument: $1. Please use --help for help."
675620
;;
@@ -681,11 +626,6 @@ cmd_shell() {
681626
ensure_devctr
682627
ensure_build_dir
683628

684-
if [[ $ramdisk = true ]]; then
685-
mount_ramdisk ${ramdisk_size}
686-
ramdisk_args="--volume ${DEFAULT_RAMDISK_PATH}:${DEFAULT_TEST_SESSION_ROOT_PATH}"
687-
fi
688-
689629
if [[ $privileged = true ]]; then
690630
# If requested, spin up a privileged container.
691631
#
@@ -699,8 +639,6 @@ cmd_shell() {
699639
--ulimit memlock=-1:-1 \
700640
--security-opt seccomp=unconfined \
701641
--workdir "$CTR_FC_ROOT_DIR" \
702-
-v /boot:/boot \
703-
${ramdisk_args} \
704642
-- \
705643
bash
706644
ret=$?
@@ -732,10 +670,6 @@ cmd_shell() {
732670
ret=$?
733671
fi
734672

735-
if [[ $ramdisk = true ]]; then
736-
umount_ramdisk
737-
fi
738-
739673
return $ret
740674
}
741675

0 commit comments

Comments
 (0)