Vous avez reçu un message "Your GitLab account has been locked ..." ? Pas d'inquiétude : lisez cet article https://docs.gricad-pages.univ-grenoble-alpes.fr/help/unlock/

Commit e5a88891 authored by Jonathan Schaeffer's avatar Jonathan Schaeffer
Browse files

Test un dixieme des fichiers de l'archive

parent caa6153b
...@@ -69,29 +69,35 @@ else ...@@ -69,29 +69,35 @@ else
printf "\033[0;32mOK\033[0m\n" printf "\033[0;32mOK\033[0m\n"
fi fi
echo === Extracting one random file === nbtests=$(( $(tar -tf latest.tar | wc -l) / 10 ))
target_line=$(tar tvf latest.tar | grep -e '[0-9]$' | shuf -n 1) for i in $(seq nbtests); do
target_file=$(echo "$target_line"| awk '{print $NF}') test_random_file
echo $target_file done
tar -xf latest.tar $target_file
target_file_date=$(date +%s -d $(stat $target_file --print %z | awk '{print $1}')) function test_random_file {
fname=$(echo $target_file | awk -F'/' '{print $NF}') echo === Extracting one random file ===
echo $fname target_line=$(tar tvf latest.tar | grep -e '[0-9]$' | shuf -n 1)
regex="([A-Z0-9]+)\.([A-Z]+)\.[0-9]*\.([A-Z0-9]{3}\.D)\.([12][0-9]{3})\.[0-3][0-9]{2}" target_file=$(echo "$target_line"| awk '{print $NF}')
archive_file="" echo $target_file
if [[ $fname =~ $regex ]]; then tar -xf latest.tar $target_file
target_file_date=$(date +%s -d $(stat $target_file --print %z | awk '{print $1}'))
fname=$(echo $target_file | awk -F'/' '{print $NF}')
echo $fname
regex="([A-Z0-9]+)\.([A-Z]+)\.[0-9]*\.([A-Z0-9]{3}\.D)\.([12][0-9]{3})\.[0-3][0-9]{2}"
archive_file=""
if [[ $fname =~ $regex ]]; then
archive_file="$archivedir/${BASH_REMATCH[4]}/${BASH_REMATCH[1]}/${BASH_REMATCH[2]}/${BASH_REMATCH[3]}/$fname"; archive_file="$archivedir/${BASH_REMATCH[4]}/${BASH_REMATCH[1]}/${BASH_REMATCH[2]}/${BASH_REMATCH[3]}/$fname";
if [[ ! -r $archive_file ]]; then if [[ ! -r $archive_file ]]; then
printf "\033[1;33mWARNING\033[0m $archive_file not preset\n" printf "\033[1;33mWARNING\033[0m $archive_file not preset\n"
exit 1 exit 1
fi fi
fi fi
echo $archive_file echo $archive_file
archive_file_date=$(date +%s -d $(stat $archive_file --print %z | awk '{print $1}')) archive_file_date=$(date +%s -d $(stat $archive_file --print %z | awk '{print $1}'))
if [ $archive_file_date -gt $target_file_date ]; then if [ $archive_file_date -gt $target_file_date ]; then
echo "File in archive is newer than remote file. Skipping md5 test" echo "File in archive is newer than remote file. Skipping md5 test"
else else
echo === Checking md5 === echo === Checking md5 ===
dumped_md5=$(md5sum $target_file | awk '{print $1}') dumped_md5=$(md5sum $target_file | awk '{print $1}')
data_md5=$(md5sum $archive_file | awk '{print $1}') data_md5=$(md5sum $archive_file | awk '{print $1}')
...@@ -103,18 +109,19 @@ else ...@@ -103,18 +109,19 @@ else
printf "\033[0;31mError\033[0m Files $target_file and $archive_file mismatch\n" printf "\033[0;31mError\033[0m Files $target_file and $archive_file mismatch\n"
exit 1 exit 1
fi fi
fi fi
echo === Compare msi traces === echo === Compare msi traces ===
dumped_msi=$(msi $target_file) dumped_msi=$(msi $target_file)
data_msi=$(msi $archive_file) data_msi=$(msi $archive_file)
if [[ $(md5sum <<< $dumped_msi | awk '{print $1}') == $(md5sum <<< $data_msi | awk '{print $1}') ]]; then if [[ $(md5sum <<< $dumped_msi | awk '{print $1}') == $(md5sum <<< $data_msi | awk '{print $1}') ]]; then
printf "\033[0;32mOK\033[0m Traces match\n" printf "\033[0;32mOK\033[0m Traces match\n"
else else
echo "Traces of remote file $target_file" echo "Traces of remote file $target_file"
echo "$dumped_msi" echo "$dumped_msi"
echo "Traces of local file $archive_file" echo "Traces of local file $archive_file"
echo "$data_msi" echo "$data_msi"
printf "\033[1;33mWARNING\033[0m Traces mismatch\n" printf "\033[1;33mWARNING\033[0m Traces mismatch\n"
fi fi
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment