tout fonctionne et peut se répéter. plus qu'à clean, réécrire le help, readme

This commit is contained in:
eleonore12345 2024-07-08 16:18:37 +02:00
parent 6ff18efe34
commit f504022d99
2 changed files with 140 additions and 118 deletions

View File

@ -22,7 +22,7 @@ create_random_file(){
REPO_NAME=performance_testing REPO_NAME=performance_testing
REPO_PATH=./remote REPO_PATH=./remote
WITH_SUBMODULE="false" #"true" WITH_SUBMODULE="false"
SUB_NAME="submodule_for_performance_testing" SUB_NAME="submodule_for_performance_testing"
while getopts ":h:s" option; do while getopts ":h:s" option; do
case $option in case $option in
@ -42,6 +42,7 @@ if [ ! -d $REPO_PATH ]; then
fi fi
cd $REPO_PATH cd $REPO_PATH
if [ ! -d $REPO_NAME ]; then if [ ! -d $REPO_NAME ]; then
echo "remote/performance testing va devoir être créé"
mkdir $REPO_NAME mkdir $REPO_NAME
cd $REPO_NAME cd $REPO_NAME
git init git init
@ -83,6 +84,7 @@ if [ ! -d $REPO_NAME ]; then
fi fi
cd .. cd ..
else # $REPO_NAME exists else # $REPO_NAME exists
echo "remote/performance testing existe"
if [[ "$WITH_SUBMODULE" = "true" && ! -d $SUB_NAME ]]; then if [[ "$WITH_SUBMODULE" = "true" && ! -d $SUB_NAME ]]; then
mkdir $SUB_NAME mkdir $SUB_NAME
cd $SUB_NAME cd $SUB_NAME
@ -95,8 +97,9 @@ else # $REPO_NAME exists
git submodule add ../submodule_for_performance_testing git submodule add ../submodule_for_performance_testing
git commit -am "adding $SUB_NAME module" git commit -am "adding $SUB_NAME module"
elif [[ "$WITH_SUBMODULE" != "true" && -d $SUB_NAME ]]; then elif [[ "$WITH_SUBMODULE" != "true" && -d $SUB_NAME ]]; then
cd $SUB_NAME cd $REPO_NAME
git rm submodule_for_performance_testing git reset --hard HEAD~1 &> /dev/null
rm -rf $SUB_NAME &> /dev/null
cd .. cd ..
rm -rf $SUB_NAME rm -rf $SUB_NAME
fi fi

View File

@ -52,19 +52,18 @@ get_storage_used(){
get_bandwidth(){ get_bandwidth(){
bw="unknown" bw="unknown"
if [ "$1" = "cloning_text" ]; then
bw=$(grep -e "Receiving objects:" $1 | grep -o "Receiving objects: [[:alnum:]%/(),. ]*" | tail -n1) bw=$(grep -e "Receiving objects:" $1 | grep -o "Receiving objects: [[:alnum:]%/(),. ]*" | tail -n1)
bw=${bw#*,} bw=${bw#*,}
elif [ "$1" = "fetching_text" ]; then
bw=$(grep -e "\->" fetching_text| grep -o "[[:digit:].]* -> [[:digit:].]* [[:alpha:]]*")
fi
} }
#TESTS ON THE INITIAL POPULATING OF THE REPO #TESTS ON THE INITIAL POPULATING OF THE REPO
test0(){ test0(){
section TEST0 section TEST0
echo "TEST 0 : case of classic cloning." echo "TEST 0 : case of classic cloning."
git clone --recurse-submodules --progress --no-local $1 2> cloning_text git clone --recurse-submodules --progress --no-local $1 &> cloning_text
cd $REPO_NAME
run git submodule update --init --recursive --force --remote --progress &> /dev/null
cd ..
get_storage_used "./$REPO_NAME" get_storage_used "./$REPO_NAME"
get_bandwidth cloning_text get_bandwidth cloning_text
echo "memory usage in a classic cloning : $mem" echo "memory usage in a classic cloning : $mem"
@ -76,7 +75,10 @@ test0(){
test1(){ test1(){
section TEST1 section TEST1
echo "TEST 1 : case of --single-branch cloning." echo "TEST 1 : case of --single-branch cloning."
git clone --recurse-submodules --progress --single-branch --no-local $1 2> cloning_text git clone --recurse-submodules --progress --single-branch --no-local $1 &> cloning_text
cd $REPO_NAME
run git submodule update --init --recursive --force --remote --progress &> /dev/null
cd ..
get_storage_used ./$REPO_NAME get_storage_used ./$REPO_NAME
get_bandwidth cloning_text get_bandwidth cloning_text
echo "memory usage in a --single-branch cloning : $mem" echo "memory usage in a --single-branch cloning : $mem"
@ -88,7 +90,10 @@ test1(){
test2(){ test2(){
section TEST2 section TEST2
echo "TEST 2 : case of --depth=1 --no-single-branch" echo "TEST 2 : case of --depth=1 --no-single-branch"
git clone --recurse-submodules --progress --depth=1 --no-local --no-single-branch $1 2> cloning_text git clone --recurse-submodules --progress --depth=1 --no-local --no-single-branch $1 &> cloning_text
cd $REPO_NAME
run git submodule update --init --recursive --force --remote --progress --depth=1 --no-single-branch &> /dev/null
cd ..
get_storage_used ./$REPO_NAME get_storage_used ./$REPO_NAME
get_bandwidth cloning_text get_bandwidth cloning_text
echo "memory usage in a --depth=1 --no-single-branch cloning : $mem" echo "memory usage in a --depth=1 --no-single-branch cloning : $mem"
@ -100,7 +105,10 @@ test2(){
test3(){ test3(){
section TEST3 section TEST3
echo "TEST 3 : case of --depth=1 with single-branch (default))" echo "TEST 3 : case of --depth=1 with single-branch (default))"
git clone --recurse-submodules --recurse-submodules --progress --single-branch --no-local --depth=1 $1 2> cloning_text git clone --recurse-submodules --recurse-submodules --progress --single-branch --no-local --depth=1 $1 &> cloning_text
cd $REPO_NAME
run git submodule update --init --recursive --force --remote --progress --depth=1 &> /dev/null
cd ..
get_storage_used ./$REPO_NAME get_storage_used ./$REPO_NAME
get_bandwidth cloning_text get_bandwidth cloning_text
echo "memory usage in a --depth=1 with single-branch cloning : $mem" echo "memory usage in a --depth=1 with single-branch cloning : $mem"
@ -120,7 +128,9 @@ test4(){
run echo $FILES_TO_KEEP >> .git/info/sparse-checkout run echo $FILES_TO_KEEP >> .git/info/sparse-checkout
#pulling from the remote with sparse-checking enabled #pulling from the remote with sparse-checking enabled
run git remote add -f origin ../$1 &> /dev/null run git remote add -f origin ../$1 &> /dev/null
run git pull origin main &> /dev/null run git submodule update --init --recursive --force --depth=1 --remote &> /dev/null
run git fetch --progress --tags --depth=1 origin &> /dev/null
git checkout -f origin/main &> /dev/null
get_storage_used . get_storage_used .
echo "memory usage: $mem" echo "memory usage: $mem"
echo "bandwidth usage : unknown" echo "bandwidth usage : unknown"
@ -134,11 +144,9 @@ test5(){
section TEST5 section TEST5
run echo 'TEST 5 : case of classic fetching and merging, after addition of a 1M file' run echo 'TEST 5 : case of classic fetching and merging, after addition of a 1M file'
#initialization #initialization
run git clone --recurse-submodules $1 &> /dev/null git clone --recurse-submodules --progress --no-local $1 &> /dev/null
cd $REPO_NAME cd $REPO_NAME
#run git submodule update --init --recursive --force --recommend-shallow #run git submodule update --init --recursive --force --depth=1
run git fetch --progress origin &> /dev/null
run git merge --progress origin &> /dev/null
get_storage_used . get_storage_used .
mem_before=$mem mem_before=$mem
#modification of the remote repo #modification of the remote repo
@ -148,12 +156,12 @@ test5(){
run git commit --quiet -m"fourth 1M sample created" run git commit --quiet -m"fourth 1M sample created"
cd ../../$REPO_NAME cd ../../$REPO_NAME
#fetching #fetching
run git fetch --progress --tags --depth=1 --recurse-submodules origin &> /dev/null run git submodule update --init --recursive --force --remote &> /dev/null
git checkout -f --recurse-submodules origin/main &> /dev/null run git fetch --progress --tags origin &> /dev/null
git checkout -f origin/main &> /dev/null
get_storage_used . get_storage_used .
mem_after=$mem mem_after=$mem
mem=$(($mem_after-$mem_before)) mem=$(($mem_after-$mem_before))
#get_bandwidth fetching_text
echo "memory usage: +$mem" echo "memory usage: +$mem"
cd ../$REMOTE cd ../$REMOTE
git reset --hard -q HEAD~1 git reset --hard -q HEAD~1
@ -165,7 +173,7 @@ test6(){
section TEST6 section TEST6
run echo 'TEST 6 : case of classic fetching and merging, after removal of a 1M file' run echo 'TEST 6 : case of classic fetching and merging, after removal of a 1M file'
#initialization #initialization
run git clone --recurse-submodules $1 #&> /dev/null git clone --recurse-submodules --progress --no-local $1 &> /dev/null
cd $REPO_NAME cd $REPO_NAME
get_storage_used . get_storage_used .
mem_before=$mem mem_before=$mem
@ -176,8 +184,9 @@ test6(){
run git commit --quiet -m"1M sample0 deleted" run git commit --quiet -m"1M sample0 deleted"
cd ../../$REPO_NAME cd ../../$REPO_NAME
#fetching #fetching
run git fetch --progress --tags --depth=1 --recurse-submodules origin &> /dev/null run git submodule update --init --recursive --force --remote &> /dev/null
git checkout -f --recurse-submodules origin/main &> /dev/null run git fetch --progress --tags origin &> /dev/null
git checkout -f origin/main &> /dev/null
get_storage_used . get_storage_used .
mem_after=$mem mem_after=$mem
mem=$(($mem_after-$mem_before)) mem=$(($mem_after-$mem_before))
@ -193,7 +202,7 @@ test7(){
section TEST7 section TEST7
run echo 'TEST 7 : case of classic fetching and merging, after addition then removal of a 1M file' run echo 'TEST 7 : case of classic fetching and merging, after addition then removal of a 1M file'
#initialization #initialization
run git clone --recurse-submodules $1 &> /dev/null git clone --recurse-submodules --progress --no-local $1 &> /dev/null
cd $REPO_NAME cd $REPO_NAME
get_storage_used . get_storage_used .
mem_before=$mem mem_before=$mem
@ -207,8 +216,9 @@ test7(){
run git commit --quiet -m"1M "sample5" deleted" run git commit --quiet -m"1M "sample5" deleted"
cd ../../$REPO_NAME cd ../../$REPO_NAME
#fetching #fetching
run git fetch --progress --tags --depth=1 --recurse-submodules origin &> /dev/null run git submodule update --init --recursive --force --remote &> /dev/null
git checkout -f --recurse-submodules origin/main &> /dev/null run git fetch --progress --tags origin &> /dev/null
git checkout -f origin/main &> /dev/null
get_storage_used . get_storage_used .
mem_after=$mem mem_after=$mem
mem=$(($mem_after-$mem_before)) mem=$(($mem_after-$mem_before))
@ -223,8 +233,7 @@ test8(){
section TEST8 section TEST8
run echo 'TEST 8 : case of fetching --depth=1 and merging, after addition of a 1M file' run echo 'TEST 8 : case of fetching --depth=1 and merging, after addition of a 1M file'
#initialization #initialization
echo $(pwd) git clone --recurse-submodules --progress --no-local $1 &> /dev/null
run git clone --recurse-submodules $1 &> /dev/null
cd $REPO_NAME cd $REPO_NAME
echo "un truc écrit en plus" >> untexte echo "un truc écrit en plus" >> untexte
get_storage_used . get_storage_used .
@ -235,8 +244,9 @@ test8(){
run git add sample5 run git add sample5
run git commit --quiet -m"fourth 1M sample created" run git commit --quiet -m"fourth 1M sample created"
cd ../../$REPO_NAME cd ../../$REPO_NAME
run git fetch --progress --tags --depth=1 --recurse-submodules origin &> /dev/null run git submodule update --init --recursive --force --depth=1 --remote &> /dev/null
git checkout -f --recurse-submodules origin/main &> /dev/null run git fetch --progress --tags --depth=1 origin &> /dev/null
git checkout -f origin/main &> /dev/null
get_storage_used . get_storage_used .
mem_after=$mem mem_after=$mem
mem=$(($mem_after-$mem_before)) mem=$(($mem_after-$mem_before))
@ -251,7 +261,7 @@ test9(){
section TEST9 section TEST9
run echo 'TEST 9 : case of --depth=1 fetching and merging, after removal of a 1M file' run echo 'TEST 9 : case of --depth=1 fetching and merging, after removal of a 1M file'
#initialization #initialization
run git clone --recurse-submodules $1 &> /dev/null git clone --recurse-submodules --progress --no-local $1 &> /dev/null
cd $REPO_NAME cd $REPO_NAME
get_storage_used . get_storage_used .
mem_before=$mem mem_before=$mem
@ -262,8 +272,9 @@ test9(){
run git commit --quiet -m"1M sample0 deleted" run git commit --quiet -m"1M sample0 deleted"
cd ../../$REPO_NAME cd ../../$REPO_NAME
#fetching #fetching
run git fetch --progress --tags --depth=1 --recurse-submodules origin &> /dev/null run git submodule update --init --recursive --force --depth=1 --remote &> /dev/null
git checkout -f --recurse-submodules origin/main &> /dev/null run git fetch --progress --tags --depth=1 origin &> /dev/null
git checkout -f origin/main &> /dev/null
get_storage_used . get_storage_used .
mem_after=$mem mem_after=$mem
mem=$(($mem_after-$mem_before)) mem=$(($mem_after-$mem_before))
@ -277,11 +288,10 @@ test9(){
test10(){ test10(){
section TEST10 section TEST10
run echo 'TEST 10 : case of --depth=1 fetching and merging, after addition then removal of a 1M file' run echo 'TEST 10 : case of --depth=1 fetching and merging, after addition then removal of a 1M file'
run git clone --recurse-submodules $1 &> /dev/null git clone --recurse-submodules --progress --no-local $1 &> /dev/null
cd $REPO_NAME cd $REPO_NAME
get_storage_used . get_storage_used .
mem_before=$mem mem_before=$mem
pwd
#modification of the remote repo #modification of the remote repo
cd ../$REMOTE cd ../$REMOTE
create_random_file 'sample5' '1M' #adding a 1M file create_random_file 'sample5' '1M' #adding a 1M file
@ -292,8 +302,9 @@ test10(){
run git commit --quiet -m"1M "sample5" deleted" run git commit --quiet -m"1M "sample5" deleted"
cd ../../$REPO_NAME cd ../../$REPO_NAME
#fetching #fetching
run git fetch --progress --tags --depth=1 --recurse-submodules origin &> /dev/null run git submodule update --init --recursive --force --depth=1 --remote &> /dev/null
git checkout -f --recurse-submodules origin/main &> /dev/null run git fetch --progress --tags --depth=1 origin &> /dev/null
git checkout -f origin/main &> /dev/null
get_storage_used . get_storage_used .
mem_after=$mem mem_after=$mem
mem=$(($mem_after-$mem_before)) mem=$(($mem_after-$mem_before))
@ -307,11 +318,11 @@ test10(){
test11(){ test11(){
section TEST11 section TEST11
run echo 'TEST 11 : case of --depth=1 fetching and merging, after addition of a 1M file in submodule' run echo 'TEST 11 : case of --depth=1 fetching and merging, after addition of a 1M file in submodule'
run git clone --recurse-submodules $1 &> /dev/null if [ "$WITH_SUBMODULE" = "true" ]; then
git clone --recurse-submodules --progress --no-local $1 &> /dev/null
cd $REPO_NAME cd $REPO_NAME
get_storage_used . get_storage_used .
mem_before=$mem mem_before=$mem
echo "mem before vaut $mem_before"
#modification of the remote submodule #modification of the remote submodule
cd .. cd ..
cd $REPO_PATH/$SUB_NAME cd $REPO_PATH/$SUB_NAME
@ -321,8 +332,8 @@ test11(){
cd ../../$REPO_NAME cd ../../$REPO_NAME
#fetching #fetching
run git submodule update --init --recursive --force --depth=1 --remote &> /dev/null run git submodule update --init --recursive --force --depth=1 --remote &> /dev/null
run git fetch --progress --tags --depth=1 origin #&> /dev/null run git fetch --progress --tags --depth=1 origin &> /dev/null
git checkout -f origin/main #&> /dev/null git checkout -f origin/main &> /dev/null
get_storage_used . get_storage_used .
mem_after=$mem mem_after=$mem
mem=$(($mem_after-$mem_before)) mem=$(($mem_after-$mem_before))
@ -331,16 +342,19 @@ test11(){
git reset --hard -q HEAD~1 git reset --hard -q HEAD~1
cd ../.. cd ../..
rm -rf performance_testing rm -rf performance_testing
else
echo "This test will not be performed because we are in no-submodule mode. Change boolean \$WITH_SUBMODULE to switch."
fi
} }
test12(){ test12(){
section TEST12 section TEST12
run echo 'TEST 12 : case of --depth=1 fetching and merging, after removal of a 1M file in submodule' run echo 'TEST 12 : case of --depth=1 fetching and merging, after removal of a 1M file in submodule'
run git clone --recurse-submodules $1 &> /dev/null if [ "$WITH_SUBMODULE" = "true" ]; then
git clone --recurse-submodules --progress --no-local $1 &> /dev/null
cd $REPO_NAME cd $REPO_NAME
get_storage_used . get_storage_used .
mem_before=$mem mem_before=$mem
echo "mem before vaut $mem_before"
#modification of the remote submodule #modification of the remote submodule
cd .. cd ..
cd $REPO_PATH/$SUB_NAME cd $REPO_PATH/$SUB_NAME
@ -350,8 +364,8 @@ test12(){
cd ../../$REPO_NAME cd ../../$REPO_NAME
#fetching #fetching
run git submodule update --init --recursive --force --depth=1 --remote &> /dev/null run git submodule update --init --recursive --force --depth=1 --remote &> /dev/null
run git fetch --progress --tags --depth=1 origin #&> /dev/null run git fetch --progress --tags --depth=1 origin &> /dev/null
git checkout -f origin/main #&> /dev/null git checkout -f origin/main &> /dev/null
get_storage_used . get_storage_used .
mem_after=$mem mem_after=$mem
mem=$(($mem_after-$mem_before)) mem=$(($mem_after-$mem_before))
@ -360,17 +374,19 @@ test12(){
git reset --hard -q HEAD~1 git reset --hard -q HEAD~1
cd ../.. cd ../..
rm -rf performance_testing rm -rf performance_testing
else
echo "This test will not be performed because we are in no-submodule mode. Change boolean \$WITH_SUBMODULE to switch."
fi
} }
test13(){ test13(){
section TEST13 section TEST13
run echo 'TEST 13 : case of --depth=1 fetching and merging, after addition then removal of a 1M file in submodule' run echo 'TEST 13 : case of --depth=1 fetching and merging, after addition then removal of a 1M file in submodule'
run git clone --recurse-submodules $1 &> /dev/null if [ "$WITH_SUBMODULE" = "true" ]; then
git clone --recurse-submodules --progress --no-local $1 &> /dev/null
cd $REPO_NAME cd $REPO_NAME
get_storage_used . get_storage_used .
mem_before=$mem mem_before=$mem
echo "mem before vaut $mem_before"
#modification of the remote submodule #modification of the remote submodule
cd .. cd ..
cd $REPO_PATH/$SUB_NAME cd $REPO_PATH/$SUB_NAME
@ -383,8 +399,8 @@ test13(){
cd ../../$REPO_NAME cd ../../$REPO_NAME
#fetching #fetching
run git submodule update --init --recursive --force --depth=1 --remote &> /dev/null run git submodule update --init --recursive --force --depth=1 --remote &> /dev/null
run git fetch --progress --tags --depth=1 origin #&> /dev/null run git fetch --progress --tags --depth=1 origin &> /dev/null
git checkout -f origin/main #&> /dev/null git checkout -f origin/main &> /dev/null
get_storage_used . get_storage_used .
mem_after=$mem mem_after=$mem
mem=$(($mem_after-$mem_before)) mem=$(($mem_after-$mem_before))
@ -393,6 +409,9 @@ test13(){
git reset --hard -q HEAD~2 git reset --hard -q HEAD~2
cd ../.. cd ../..
rm -rf performance_testing rm -rf performance_testing
else
echo "This test will not be performed because we are in no-submodule mode. Change boolean \$WITH_SUBMODULE to switch."
fi
} }
while getopts ":hn:a" option; do while getopts ":hn:a" option; do
@ -410,7 +429,7 @@ while getopts ":hn:a" option; do
esac esac
done done
if [ "$ALL_TESTS" = true ]; then if [ "$ALL_TESTS" = "true" ]; then
test0 $REMOTE test0 $REMOTE
test1 $REMOTE test1 $REMOTE
test2 $REMOTE test2 $REMOTE
@ -465,5 +484,5 @@ else
Help Help
fi fi
#optimize in case all tests are run #add the submodules management to the cloning
#adapt in case of different units #add run