diff options
author | Maxim Kuvyrkov <maxim.kuvyrkov@linaro.org> | 2017-08-09 13:48:01 +0000 |
---|---|---|
committer | Maxim Kuvyrkov <maxim.kuvyrkov@linaro.org> | 2017-08-09 14:15:22 +0000 |
commit | f43d03d9ca433954f82c1f14dc46f6540fb8cf40 (patch) | |
tree | 5b7dd3326b82e298ef39f531169f61880adefafb /jenkins-helpers.sh | |
parent | e505112c2bf616d1edfc6d73ad3ea350d86a677c (diff) |
jenkins-helpers.sh: Generalize code into helpers.
Add print_cpu_shares, print_memory_limit, print_pids_limit, and
print_bind_mounts. These helpers will also be used in upcoming
start-container-qemu.sh.
Change-Id: I7a442eb1a959fde70003dc2f693df0e3848509a0
Diffstat (limited to 'jenkins-helpers.sh')
-rw-r--r-- | jenkins-helpers.sh | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/jenkins-helpers.sh b/jenkins-helpers.sh index 3295fa92..9dc30143 100644 --- a/jenkins-helpers.sh +++ b/jenkins-helpers.sh @@ -260,3 +260,71 @@ wait_for_ssh_server () return 0 ) } + +# Print CPU share allocation for $task and $weight. +# $1: task +# $2: weight +print_cpu_shares () +{ + ( + set -euf -o pipefail + local task="$1" + local weight="$2" + local cpus + cpus=$(( $weight * 1000 )) # 1000 cpu shares per executor + echo "$cpus" + ) +} + +# Print memory allocation for $task and $weight. +# $1: task +# $2: weight +print_memory_limit () +{ + ( + set -euf -o pipefail + local task="$1" + local weight="$2" + local memory + case "$task" in + build) memory=$(( $weight * 7500 )) ;; # 7.5GB per executor + test) memory=$(( $weight * 750 )) ;; # 0.75GB per executor + esac + echo "$memory" + ) +} + +# Print PID allocation for $task and $weight. +# $1: task +# $2: weight +print_pids_limit () +{ + ( + set -euf -o pipefail + local task="$1" + local weight="$2" + local pids + pids=$(( $weight * 5000 )) # 5000 processes per executor + echo "$pids" + ) +} + +# Print default bind mounts for $task +# $1: task +print_bind_mounts () +{ + ( + set -euf -o pipefail + local task="$1" + local -a bind_mounts + case $task in + build) + bind_mounts=( + $HOME/snapshots-ref:$HOME/snapshots-ref:ro + $HOME/llvm-reference:$HOME/llvm-reference:ro + $WORKSPACE:$WORKSPACE + ) + esac + echo "${bind_mounts[@]}" + ) +} |