Skip to content
Snippets Groups Projects
Commit 19a84b50 authored by ghuter's avatar ghuter
Browse files

1st prototype of a g5k's testing system: add core files

parent 40e443b2
Branches
No related tags found
No related merge requests found
#!/bin/sh
try() { "$@" || die "cannot $*"; }
die() { yell "$*"; exit 111; }
yell() { echo "$0: $*" >&2; }
echo() { printf '%s\n' "$*"; }
base=$(dirname "$0")
configf=${base}/config
ssh_conf_pre=${base}/ssh.pre.config
ssh_conf=${base}/ssh.config
usage() {
printf 'usage: %s -u <user> -i <identity_file> [<test_name_re> ...]\n' "$(basename "$0")" >&2
exit 1
}
sanitize_config() {
sed '/^#/d; /^$/d'
}
while [ "$1" ]; do
case $1 in
-u)
shift
[ "$1" ] || usage
user=$1
;;
-i)
shift
[ "$1" ] || usage
[ -r "$1" ] || { yell "file not readable: $1"; usage; }
idfile=$1
;;
*)
test_name_re=$1
break;
;;
esac
shift
done
[ -z "$user" ] && { yell 'missing user parameter'; usage; }
[ -z "$idfile" ] && { yell 'missing identity_file parameter'; usage; }
if [ $# -eq 0 ]; then
# grab all available tests by default
config=$(sanitize_config < "$configf")
else
re='('
for test_name_re; do
re="${re}${test_name_re}|"
done
re="${re%|})"
config=$(grep -E "$re" "$configf" | sanitize_config)
fi
[ -n "$config" ] || die 'no valid sensors specified. exiting..'
config=$(echo "$config" | sort -u)
sed "
s,USER,$user,
s,IDFILE,$idfile,
" "$ssh_conf_pre" > "$ssh_conf"
sites=$(echo "$config" | cut -d ':' -f 1 | sort -u)
for site in $sites; do
site_runner=${base}/${site}-run.sh
clusters=$(echo "$config" | grep "^${site}:" | cut -d ':' -f 2 | sort -u)
try cp -f "${base}/site-runner-common.sh" "$site_runner"
for cluster in $clusters; do
files=$(echo "$config" | grep "^${site}:${cluster}:" | cut -d ':' -f 3 | sort -u)
cluster_runner=${base}/${site}-${cluster}-run.sh
echo '#!/bin/sh' > "$cluster_runner"
for f in $files; do
[ -r "$f" ] || {
yell "warning: file not readable: $f"
continue
}
destf=${cluster}-${f}
scp -F "$ssh_conf" "$f" "${site}.g5k:${destf}" || continue
echo "chmod +x \"\$HOME/$destf\"" >> "$cluster_runner"
echo "~/$destf" >> "$cluster_runner"
done
scp -F "$ssh_conf" "$cluster_runner" "${site}.g5k:${cluster}-run.sh" ||
continue
{
echo "chmod +x \"\$HOME/${cluster}-run.sh\""
echo "eval \"\$(oarsub -p ${cluster} \"~/${cluster}-run.sh\")\""
echo "echo \$OAR_JOB_ID"
} >> "$site_runner"
done
scp -F "$ssh_conf" "$site_runner" "${site}.g5k:${site}-run.sh" ||
continue
oar_job_ids=$(ssh -F "$ssh_conf" "${site}.g5k" "./${site}-run.sh")
sleep 3
while {
for id in $oar_job_ids; do
# job is no longer running
if ssh -F "$ssh_conf" "${site}.g5k" \
"! { oarstat -u \"$user\" | grep -q \"$id\"; }"
then
scp -F "$ssh_conf" "${site}.g5k:OAR.${id}.stderr" "OAR.${id}.stderr"
scp -F "$ssh_conf" "${site}.g5k:OAR.${id}.stdout" "OAR.${id}.stdout"
oar_job_ids=$(echo "$oar_job_ids" | grep -vF "$id")
fi
done
echo "oar_job_ids: \"$oar_job_ids\""
[ -n "$oar_job_ids" ]
}; do
sleep 3
done
done
exit
#!/bin/sh
echo() { printf '%s\n' "$*"; }
try() { "$@" || die "cannot $*"; }
die() { yell "$*"; exit 111; }
yell() { echo "$0: $*" >&2; }
repo_dir=mojitos
repo_url=https://gitlab.irit.fr/sepia-pub/mojitos.git
branch=test
if [ -d "$repo_dir" ]; then
fetch_url=$(git -C "$repo_dir" remote -v | awk 'NR == 1 {print $2}')
if [ "$fetch_url" != "$repo_url" ]; then
echo 'bad fetch url. recloning..'
rm -rf "$repo_dir"
try git clone -b "$branch" "$repo_url" "$repo_dir"
fi
else
try git clone -b "$branch" "$repo_url" "$repo_dir"
fi
Host g5k
User USER
Hostname access.grid5000.fr
IdentityFile IDFILE
ForwardAgent no
Host *.g5k
User USER
ProxyCommand ssh g5k -W "$(basename %h .g5k):%p"
IdentityFile IDFILE
ForwardAgent no
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment