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

View File

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