overlay files for new MDQ in test environment
This commit is contained in:
parent
979735e28d
commit
c62c908a3e
3 changed files with 66 additions and 0 deletions
14
natmd-test-common/overlay/opt/mdqp/pre.d/00-daily-clean
Executable file
14
natmd-test-common/overlay/opt/mdqp/pre.d/00-daily-clean
Executable file
|
@ -0,0 +1,14 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
set -e
|
||||
|
||||
sync_file="/opt/mdqp/work/full_sync"
|
||||
if [ -f ${sync_file} ]; then
|
||||
|
||||
if [ "$(date -r ${sync_file} +%Y-%m-%d)" != "$(date +%Y-%m-%d)" ]; then
|
||||
rm "${sync_file}"
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
|
18
natmd-test-common/overlay/opt/mdqp/pre.d/10-fetching-metadata
Executable file
18
natmd-test-common/overlay/opt/mdqp/pre.d/10-fetching-metadata
Executable file
|
@ -0,0 +1,18 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
set -e
|
||||
|
||||
# Verify and update the repo. Previously run by cron but to mitigate/remove
|
||||
# race condion it moved here.
|
||||
cd /var/cache/metadata_r1.komreg.net && make update
|
||||
|
||||
cd /opt/metadata
|
||||
|
||||
incoming_dir=/opt/mdqp/work/incoming_metadata
|
||||
mkdir -p ${incoming_dir}
|
||||
tmp_dir=$(mktemp -d)
|
||||
|
||||
rsync -a test-idp/*.xml test-sp/*.xml ${tmp_dir}/
|
||||
rsync -a --delete ${tmp_dir}/ ${incoming_dir}/
|
||||
|
||||
rm -rf "${tmp_dir}"
|
34
natmd-test-common/overlay/opt/mdqp/pre.d/20-restart-pyff
Executable file
34
natmd-test-common/overlay/opt/mdqp/pre.d/20-restart-pyff
Executable file
|
@ -0,0 +1,34 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
set -e
|
||||
|
||||
metadata_dir="/opt/mdqp/work/incoming_metadata/"
|
||||
entities_on_disk=$(find ${metadata_dir} -type f -printf "%f\n" |sort |uniq | wc -l)
|
||||
|
||||
systemctl restart sunet-pyff.service
|
||||
|
||||
# Pyff is never faster then 20 sec. Prevent exceptions in log by not trying
|
||||
# earlier.
|
||||
sleep 25
|
||||
|
||||
# Give pyff some time to start
|
||||
happy_pyff=0
|
||||
for try in {1..30}; do
|
||||
entitites=$(curl -s 'localhost:8080/api/status' | jq .store.size 2> /dev/null || echo 0)
|
||||
if [ -n "${entitites}" ] && [ "${entitites}" != "0" ]; then
|
||||
loaded_entites_in_percent=$(python3 -c "print(int(${entitites} / ${entities_on_disk} * 100))")
|
||||
if [ "${loaded_entites_in_percent}" -ge "96" ]; then
|
||||
happy_pyff=200
|
||||
break
|
||||
fi
|
||||
fi
|
||||
sleep "${try}";
|
||||
done
|
||||
|
||||
if [ "${happy_pyff}" != "200" ]; then
|
||||
echo "couldn't restart pyff - exit"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Hängslen och livrem
|
||||
sleep 10
|
Loading…
Add table
Reference in a new issue