Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support of slow drive #8

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions atf_parallels/loop.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,45 @@ _lockfile=.lock
_image_name=atf_worker
_container_name=$(basename $_tmpdirname)

_loop_device=""
_loop_device_file="loop_device_file_"$_container_name".img"

####################################################################
# The following code has to be run in several different processes
# i.e. `screen -d -m 'script_to_run.sh'`
####################################################################

function get_param_from_file {
for i in `sed 's/=/ /g' $1 | grep "^$2 " | awk '{print $2}'`; do echo $i | sed 's/"//g'; done
}

function create_loop_device {
echo "Create Loop Device"
dd if=/dev/zero of=$_loop_device_file bs=1024k count=10
mkfs -b 1024 $_loop_device_file
losetup -fP $_loop_device_file
_loop_device=$(losetup -l -n -j $_loop_device_file | awk '{print $1}')
echo "Loop Device:" $_loop_device
}

function delete_loop_device {
echo "Delete Loop Device"
losetup -d $_loop_device
rm -f $_loop_device_file
}

function docker_run {
local docker_options=""
local is_loop_device_required=$(get_param_from_file $1 "config.isLoopDeviceRequired")
if [ "$is_loop_device_required" = true ]; then
create_loop_device
docker_options+=" -e LOOP_DEVICE=$_loop_device"
local _loop_device_write_rate=$(get_param_from_file $1 "config.loopDeviceWriteRate")
if [ -n "$_loop_device_write_rate" ]; then
echo "Loop Device write rate:" $_loop_device_write_rate
docker_options+=" --device-write-bps $_loop_device:$_loop_device_write_rate"
fi
fi
docker run --rm \
--name $_container_name \
--cap-add NET_ADMIN \
Expand All @@ -28,7 +61,9 @@ function docker_run {
-v $_atf_ts_dir:/home/developer/atf_ts \
-v $_tmpdirname:/home/developer/sdl \
-v $_sdl_prepared:/home/developer/sdl_ext \
$docker_options \
$_image_name "$@"
if [ "$is_loop_device_required" = true ]; then delete_loop_device; fi
}

function docker_stop {
Expand Down