-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Start test containers in privileged mode to avoid
skipping cache dir out of space checks Fix small cache test Signed-off-by: Shreenidhi Shedi <[email protected]>
- Loading branch information
Showing
4 changed files
with
47 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,7 @@ | ||
#!/usr/bin/env bash | ||
#!/bin/bash | ||
|
||
## file: mount-small-cache.sh | ||
## brief: mounts an intentionally small directory for out-of-diskspace tests. | ||
## author: Preston Narchetti <[email protected]> | ||
|
||
if [ ${EUID} -ne 0 ]; then | ||
echo "Script must be run as root." 1>&2 | ||
|
@@ -13,29 +12,34 @@ fi | |
small_cache_path="@CMAKE_CURRENT_BINARY_DIR@/small_cache/" | ||
quota_size="1M" | ||
|
||
## used to check return code for each command. | ||
function check_err { | ||
rc=$? | ||
check_err() { | ||
local rc=$? | ||
if [ $rc -ne 0 ]; then | ||
echo $1 | ||
exit $rc | ||
echo "$1" 1>&2 | ||
exit $rc | ||
fi | ||
} | ||
|
||
echo "Creating mount point." | ||
rm -rf ./virtual_disks | ||
mkdir -p ./virtual_disks | ||
rm -rf ${small_cache_path} | ||
mkdir -p ${small_cache_path} | ||
check_err "Failed to mkdir ${small_cache_path}." | ||
|
||
echo "Creating tmpfs." | ||
touch ./virtual_disks/fs.ext4 | ||
dd if=/dev/zero of=./virtual_disks/fs.ext4 bs=${quota_size} count=1 | ||
check_err "Failed to make exf4 tmpfs: dd" | ||
mkfs.ext4 ./virtual_disks/fs.ext4 | ||
check_err "Failed to make exf4 tmpfs: mkfs.ext4" | ||
|
||
echo "Mounting tmpfs at ${small_cache_path}." | ||
mount -o loop,rw,usrquota,grpquota ./virtual_disks/fs.ext4 ${small_cache_path} | ||
check_err "Failed to mount exf4 tmpfs." | ||
vdisk="virtual_disks" | ||
ext4_fn="${vdisk}/fs.ext4" | ||
|
||
echo "Creating mount point ..." | ||
if mountpoint ${small_cache_path} &> /dev/null; then | ||
umount ${small_cache_path} | ||
check_err "ERROR: umount ${small_cache_path}" | ||
sync | ||
fi | ||
rm -rf ${vdisk} ${small_cache_path} | ||
mkdir -p ${vdisk} ${small_cache_path} | ||
check_err "ERROR: failed to mkdir ${vdisk} ${small_cache_path}" | ||
|
||
echo "Creating tmpfs ..." | ||
dd if=/dev/zero of=${ext4_fn} bs=${quota_size} count=1 | ||
check_err "ERROR: dd failed" | ||
|
||
mkfs.ext4 ${ext4_fn} | ||
check_err "ERROR: mkfs.ext4 failed" | ||
|
||
echo "Mounting tmpfs at ${small_cache_path} ..." | ||
mount -o loop,rw,usrquota,grpquota ${ext4_fn} ${small_cache_path} | ||
check_err "ERROR: failed to mount exf4 tmpfs" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters