From ed37d09fa0d20b78c12ab078de9559714ed40e84 Mon Sep 17 00:00:00 2001 From: eleonore12345 Date: Wed, 24 Jul 2024 13:57:26 +0200 Subject: [PATCH] test directory complete --- doc/development_explanations.md | 18 +- test/functional_tests/readme | 34 + test/functional_tests/test_git_update.sh | 80 +- test/performance_tests/performance_tests.sh | 1056 +++++++++++++++++ test/performance_tests/readme | 64 +- test/readme | 51 + ...creation_repo.sh => test_repo_creation.sh} | 24 +- 7 files changed, 1228 insertions(+), 99 deletions(-) create mode 100644 test/functional_tests/readme create mode 100755 test/performance_tests/performance_tests.sh create mode 100644 test/readme rename test/{creation_repo.sh => test_repo_creation.sh} (86%) diff --git a/doc/development_explanations.md b/doc/development_explanations.md index 5ffeeec..e7f3da8 100644 --- a/doc/development_explanations.md +++ b/doc/development_explanations.md @@ -142,6 +142,7 @@ The same rules apply to submodules as to the rest of the repository. In the .git ##Tests ### Script description +### README extract The script consists of twenty-nine tests (listed in the results below), based on three functions: generate_random_file, get_storage_used and get_bandwidth. generate_random_file uses the bash command dd and /dev/random. @@ -150,13 +151,16 @@ get_bandwidth retrieves the output of Git commands and extracts the traffic disp The first five tests concern cloning. The following tests involve updating the repository using different commands, with three cases for each command: after adding a file, after deleting a file, after adding then deleting a file. - -### README extract - -NAME performance_tests.sh -SYNOPSIS performance_tests.sh [-a] [-h] [-n number]OPTIONS - -a excutes all the tests. - -n number executes test number -h prints the help. +### Help extract +NAME + performance_tests.sh +SYNOPSIS + performance_tests.sh [-a] [-h] [-n number] +OPTIONS + -a executes all the tests. + -n number executes test number. + - c cleans. + -h prints the help. ### Results ======================================= Tests on the initial populating of the repository diff --git a/test/functional_tests/readme b/test/functional_tests/readme new file mode 100644 index 0000000..2b24771 --- /dev/null +++ b/test/functional_tests/readme @@ -0,0 +1,34 @@ +## Introduction +test_git_update.sh performs functional tests on git_update.sh to verify that it is behaving as planned. + +## Tests +The script consists in nine tests. The three first ones test the cloning and the following test the updating of git_update.sh. + +Each test consists of calling git_update.sh, eventually after some modifications, and compare the result with the expected result. The comparison is done by *_check functions, which modify each a boolean *_result. +If all booleans of checks conducted are true, then the boolean case* is also true and the test is a success. + +## Help extract +NAME + test_git_update.sh +SYNOPSIS + test_git_update.sh [-a] [-h] [-c] [-n number] +OPTIONS + -a excutes all the tests and cleans. + -n number executes test number. + -c cleans. + -h prints the help. +DESCRIPTION + TEST0: git cloned in an empty directory + TEST1: git cloned in an empty directory with tag + TEST2: git cloned in an empty directory with branch + TEST3: git updated fast-forward on main + TEST4: git updated fast-forward on main with untracked file + TEST5: git updated with underlying conflict on main + TEST6: git updated, switching to another branch, deleting and adding files in the process + TEST7: git updated, switching to a tag, deleting and adding files in the process + TEST8: git updated, before and after changing a tag, deleting and adding files in the process + TEST9: git updated fast-forward on submodule on main" + +## Debugging +In case of problem, it is adviced to run test_git_update.sh -c to clean the repository. +This will force test_repo_creation.sh to run again and provide a new test repository. \ No newline at end of file diff --git a/test/functional_tests/test_git_update.sh b/test/functional_tests/test_git_update.sh index eccedbc..503fb6f 100755 --- a/test/functional_tests/test_git_update.sh +++ b/test/functional_tests/test_git_update.sh @@ -1,20 +1,18 @@ #! /bin/bash -#importer driglibash echo "" - Help() { echo " NAME test_git_update.sh SYNOPSIS - test_git_update.sh [-a] [-h] [-n number] + test_git_update.sh [-a] [-h] [-c] [-n number] OPTIONS - -a excutes all the tests. - -n number executes test number + -a excutes all the tests and cleans. + -n number executes test number. + -c cleans. -h prints the help. DESCRIPTION - Tests on the initial cloning TEST0: git cloned in an empty directory TEST1: git cloned in an empty directory with tag TEST2: git cloned in an empty directory with branch @@ -24,8 +22,7 @@ DESCRIPTION TEST6: git updated, switching to another branch, deleting and adding files in the process TEST7: git updated, switching to a tag, deleting and adding files in the process TEST8: git updated, before and after changing a tag, deleting and adding files in the process - TEST9: git updated fast-forward on submodule on main -" + TEST9: git updated fast-forward on submodule on main" } #Variables definitions @@ -33,7 +30,7 @@ WORKING_DIRECTORY=$(pwd) REPO_NAME="git_update_testing" SUBMODULE_NAME="submodule" REMOTE="file://${WORKING_DIRECTORY}/remote/$REPO_NAME" #we must trick git_update.sh into thinking we are not working in local, otherwise depth=1 is not respected -LOCAL_REMOTE="/${WORKING_DIRECTORY}/remote/$REPO_NAME" #cd does not understand file:// +LOCAL_REMOTE="${WORKING_DIRECTORY}/remote/$REPO_NAME" #cd does not understand file:// LOCAL_REMOTE_SUBMODULE="/${WORKING_DIRECTORY}/remote/$SUBMODULE_NAME" FILENAMES=("sample0" "sample1 sample3") FILENAMES_TAG=("sample0 sample1 sample4") @@ -50,13 +47,25 @@ TAG_NAME="tagging_point" TAG_FLAG="tag_flag" BRANCH_NAME="secondary" -bash creation_repo.sh -s #&> /dev/null +#preparing the test repository +bash ../test_repo_creation.sh -s &> /dev/null #output function section(){ echo "------------------------------ $1 ------------------------------" } +#clean +clean(){ + if [ -d remote ]; then + rm -rf remote + fi + if [ -d $REPO_NAME ]; then + rm -rf $REPO_NAME + fi + echo "" +} + #check functions cloning_check(){ local input=("$@") @@ -311,16 +320,17 @@ undo_changing_tag(){ test0 (){ - #CASE 0: git cloned in an empty directory +#CASE 0: git cloned in an empty directory section TEST0 #if it exists, delete the directory if [ -d $REPO_NAME ]; then rm -rf $REPO_NAME fi - ./git_update.sh -d $REPO_NAME $REMOTE &> /dev/null + ../../src/git_update.sh -d $REPO_NAME $REMOTE &> /dev/null #checks cloning_check $REPO_NAME ${FILENAMES[@]} history_check $REPO_NAME + case0=$((history_result+cloning_result)) if [ "$case0" = "0" ]; then echo "case 0, in a empty directory: OK" @@ -330,13 +340,13 @@ test0 (){ } test1(){ - #CASE 1: git cloned in an empty directory with tag +#CASE 1: git cloned in an empty directory with tag section TEST1 #if it exists, delete the directory if [ -d $REPO_NAME ]; then rm -rf $REPO_NAME fi - ./git_update.sh -d $REPO_NAME -r $TAG_NAME $REMOTE &> /dev/null + ../../src/git_update.sh -d $REPO_NAME -r $TAG_NAME $REMOTE &> /dev/null #checks cloning_check $REPO_NAME ${FILENAMES_TAG[@]} history_check $REPO_NAME @@ -357,7 +367,7 @@ test2(){ if [ -d $REPO_NAME ]; then rm -rf $REPO_NAME fi - ./git_update.sh -d $REPO_NAME -r $BRANCH_NAME $REMOTE &> /dev/null + ../../src/git_update.sh -d $REPO_NAME -r $BRANCH_NAME $REMOTE &> /dev/null #checks cloning_check $REPO_NAME ${FILENAMES_BRANCH[@]} history_check $REPO_NAME @@ -384,13 +394,13 @@ test3(){ modification_remote #make git_update.sh update the repository cd $REPO_NAME - ../git_update.sh $REMOTE &> /dev/null + ../../../src/git_update.sh $REMOTE &> /dev/null cd .. #checks modification_check $REPO_NAME history_check $REPO_NAME #cleaning - undo_modification_remote + #undo_modification_remote case3=$((modification_result+history_result)) if [ "$case3" = "0" ]; then @@ -415,7 +425,7 @@ test4(){ add_untracked_file $REPO_NAME #make git_update.sh update the repository cd $REPO_NAME - ../git_update.sh $REMOTE &> /dev/null + ../../../src/git_update.sh $REMOTE &> /dev/null cd .. #checks modification_check $REPO_NAME @@ -448,7 +458,7 @@ test5(){ modification_remote #make git_update.sh update the local repository cd $REPO_NAME - ../git_update.sh $REMOTE &> /dev/null + ../../../src/git_update.sh $REMOTE &> /dev/null cd .. #checks conflict_check $REPO_NAME @@ -474,7 +484,7 @@ test6(){ git clone --recurse-submodules --shallow-submodules --depth 1 $REMOTE &> /dev/null #call git update with another branch cd $REPO_NAME - ../git_update.sh -r $BRANCH_NAME $REMOTE &> /dev/null + ../../../src/git_update.sh -r $BRANCH_NAME $REMOTE &> /dev/null cd .. #checks switching_branch_check $REPO_NAME @@ -498,7 +508,7 @@ test7(){ git clone --recurse-submodules --shallow-submodules --depth 1 $REMOTE &> /dev/null #call git_update.sh with a tag cd $REPO_NAME - ../git_update.sh -r $TAG_NAME $REMOTE &> /dev/null + ../../../src/git_update.sh -r $TAG_NAME $REMOTE &> /dev/null cd .. #checks switching_tag_check $REPO_NAME @@ -522,7 +532,7 @@ test8(){ git clone --recurse-submodules --shallow-submodules --depth 1 $REMOTE &> /dev/null #call git_update.sh with a tag cd $REPO_NAME - ../git_update.sh -r $TAG_NAME $REMOTE &> /dev/null + ../../../src/git_update.sh -r $TAG_NAME $REMOTE &> /dev/null cd .. #intermediate check to make sure that we are starting on the initial position of the tag switching_tag_check $REPO_NAME @@ -530,7 +540,7 @@ test8(){ changing_tag #call git_update.sh again to go to the new position of the tag cd $REPO_NAME - ../git_update.sh -r $TAG_NAME $REMOTE &> /dev/null + ../../../src/git_update.sh -r $TAG_NAME $REMOTE &> /dev/null cd .. #put back the remote in its initial state undo_changing_tag @@ -561,7 +571,7 @@ test9(){ #make git_update.sh update the repository cd $REPO_NAME echo "moment fatidique" - ../git_update.sh $REMOTE #&> /dev/null + ../../../src/git_update.sh $REMOTE &> /dev/null cd .. #checks modification_submodule_check $REPO_NAME @@ -577,18 +587,23 @@ test9(){ fi } -while getopts ":hn:a" option; do +ALL_TESTS="false" +TEST_NUM="" +while getopts ":hcn:a" option; do case $option in h) # display Help - Help - exit;; - n) + Help + exit;; + c) #clean + clean;; + n) #perform specific test TEST_NUM=$OPTARG;; - a) + a) #perform all tests and clean ALL_TESTS="true";; \?) # Invalid option - echo "Error: Invalid option here" - exit;; + echo "Error: Invalid option" + Help + exit;; esac done @@ -603,6 +618,7 @@ if [ "$ALL_TESTS" = "true" ]; then test7 test8 test9 + clean elif [ -n "$TEST_NUM" ]; then #in order to only create the temporary clone once if we execute all tests case $TEST_NUM in @@ -630,6 +646,4 @@ elif [ -n "$TEST_NUM" ]; then echo "Error: Invalid test number" exit;; esac -else - Help fi \ No newline at end of file diff --git a/test/performance_tests/performance_tests.sh b/test/performance_tests/performance_tests.sh new file mode 100755 index 0000000..d06047a --- /dev/null +++ b/test/performance_tests/performance_tests.sh @@ -0,0 +1,1056 @@ +#!/bin/bash +echo "" +Help() +{ + echo " +NAME + performance_tests.sh +SYNOPSIS + performance_tests.sh [-a] [-h] [-n number] +OPTIONS + -a executes all the tests. + -n number executes test number. + - c cleans. + -h prints the help. +DESCRIPTION + This script is in writing. It allows you to measure memory and bandwidth usage. The first four test different cloning methods. Te following apply changes to the local remote before testing fetching and merging commands. + TEST0: classic cloning + TEST1: --single-branch cloning + TEST2: --depth=1 --no-single-branch cloning + TEST3: --depth=1 cloning + TEST4: --depth=1 with reflog and gc cloning + TEST5: sparse-checking 1M sample0 cloning + _________________ + TEST6: classic fetching+checking out after addition of a 1M file + TEST7: classic fetching+checking out after removal of a 1M file + TEST8: classic fetching+checking out after addition then removal of a 1M file + + TEST9: --depth=1 fetching+checking out after addition of a 1M file + TEST10: --depth=1 fetching+checking out after removal of a 1M file + TEST11: --depth=1 fetching+checking out after addition then removal of 1M a file + + TEST12: --depth=1 fetching+checking out with reflog annd gc after addition of a 1M file + TEST13: --depth=1 fetching+checking out with reflog annd gc after removal of a 1M file + TEST14: --depth=1 fetching+checking out with reflog annd gc after addition then removal of a 1M file + + TEST15: --depth=1 fetching+ --reset=hard after addition of a 1M file + TEST16: --depth=1 fetching+ --reset=hard after removal of a 1M file + TEST17: --depth=1 fetching+ --reset=hard after addition then removal of a 1M file + + TEST18: --depth=1 fetching+ --reset=hard and reflog and gc after addition of a 1M file + TEST19: --depth=1 fetching+ --reset=hard and reflog and gc after removal of a 1M file + TEST20: --depth=1 fetching+ --reset=hard and reflog and gc after addition then removal of a 1M file + + TEST21: --depth=1 fetching+checking out after addition of a 1M file in submodule + TEST22: --depth=1 fetching+checking out after removal of a 1M file in submodule + TEST23: --depth=1 fetching+checking out after addition then removal of a 1M file in submodule + + TEST24: --depth=1 fetching+merging -X theirs with reflog and gc after addition of a 1M file + TEST25: --depth=1 fetching+merging -X theirs with reflog and gc after removal of a 1M file + TEST26: --depth=1 fetching+merging -X theirs with reflog and gc after addition then removal of a 1M file + + TEST27: --depth=1 fetching+merging -s ours with reflog and gc after addition of a 1M file + TEST28: --depth=1 fetching+merging -s ours with reflog and gc after removal of a 1M file + TEST29: --depth=1 fetching+merging -s ours with reflog and gc after addition then removal of a 1M file" +} + +REPO_NAME=git_update_testing +REPO_PATH=./remote +WITH_SUBMODULE="true" +SUB_NAME="submodule_for_performance_testing" +FILES_TO_KEEP='sample0' +REMOTE="./remote/performance_testing" + +#preparing the test repository +if [ "$WITH_SUBMODULE" = "true" ]; then + bash test_repo_creation.sh -s &> /dev/null +else + bash test_repo_creation.sh &> /dev/null +fi + +#output function +section(){ + echo "------------------------------ $1 ------------------------------" +} + +#clean +clean(){ + if [ -d remote ]; then + rm -rf remote + fi + if [ -d $REPO_NAME ]; then + rm -rf $REPO_NAME + fi + echo "" +} + +#useful functions for the tests +create_random_file(){ + dd if=/dev/urandom of=$1 bs=$2 count=1 &> /dev/null +} + +get_storage_used(){ + mem=$(du $1 | tail -n1 | tr -cd [:digit:]) +} + +get_bandwidth(){ + bw="unknown" + bw=$(grep -e "Receiving objects:" $1 | grep -o "Receiving objects: [[:alnum:]%/(),. ]*" | tail -n1) + bw=${bw#*,} +} + +#Tests on the initial populating of the repository +section "Tests on the initial populating of the repository" +test0(){ + section TEST0 + echo "TEST 0: classic cloning." + git clone --recurse-submodules --remote-submodules --progress --no-local $1 &> cloning_text + cd $REPO_NAME + git submodule update --init --recursive --force --remote --progress &> /dev/null + cd .. + get_storage_used "./$REPO_NAME" + get_bandwidth cloning_text + echo "memory usage: $mem" + echo "bandwidth usage (submodule excluded): $bw" + rm cloning_text + rm -rf $REPO_NAME +} + +test1(){ + section TEST1 + echo "TEST 1: --single-branch cloning." + git clone --recurse-submodules --remote-submodules --progress --single-branch --no-local $1 &> cloning_text + cd $REPO_NAME + git submodule update --init --recursive --force --remote --progress &> /dev/null + cd .. + get_storage_used ./$REPO_NAME + get_bandwidth cloning_text + echo "memory usage: $mem" + echo "bandwidth usage (submodule excluded): $bw" + rm cloning_text + rm -rf $REPO_NAME +} + +test2(){ + section TEST2 + echo "TEST 2: --depth=1 --no-single-branch" + git clone --recurse-submodules --remote-submodules --progress --depth=1 --no-local --no-single-branch $1 &> cloning_text + cd $REPO_NAME + 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: $mem" + echo "bandwidth usage (submodule excluded): $bw" + rm cloning_text + rm -rf $REPO_NAME +} + +test3(){ + section TEST3 + echo "TEST 3: --depth=1 with single-branch (default))" + git clone --recurse-submodules --remote-submodules --progress --single-branch --no-local --depth=1 $1 &> cloning_text + cd $REPO_NAME + 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: $mem" + echo "bandwidth usage (submodule excluded): $bw" + rm cloning_text + rm -rf $REPO_NAME +} + +test4(){ + section TEST4 + echo "TEST 4: --depth=1 with single-branch (default) and reflog and gc" + git clone --recurse-submodules --remote-submodules --progress --single-branch --no-local --depth=1 $1 &> cloning_text + cd $REPO_NAME + git submodule update --init --recursive --force --remote --progress --depth=1 &> /dev/null + git reset --hard + cd .. + get_storage_used ./$REPO_NAME + get_bandwidth cloning_text + echo "memory usage: $mem" + echo "bandwidth usage (submodule excluded): $bw" + rm cloning_text + rm -rf $REPO_NAME +} + +test5(){ + section TEST5 + mkdir $REPO_NAME + echo "TEST 5 : sparse-checking only $FILES_TO_KEEP with depth=1" + #creating a git repo with sparse-checking settings + cd $REPO_NAME + git init -q + git config core.sparsecheckout true + echo $FILES_TO_KEEP >> .git/info/sparse-checkout + #pulling from the remote with sparse-checking enabled + git remote add -f origin ../$1 &> /dev/null + git submodule update --init --recursive --force --depth=1 --remote &> /dev/null + git fetch --progress --tags --depth=1 --prune --prune-tags origin &> /dev/null + git checkout -f origin/main &> /dev/null + get_storage_used . + echo "memory usage: $mem" + echo "bandwidth usage (submodule excluded): unknown" + cd .. + rm -rf $REPO_NAME +} + +#Tests on the updating of the repository +#classic fetching +test6(){ + section TEST6 + echo 'TEST 6: after addition of a 1M file' + #initialization + git clone --recurse-submodules --remote-submodules --progress --depth=1 --no-local $1 &> /dev/null + cd $REPO_NAME + get_storage_used . + mem_before=$mem + #modification of the remote repo + cd ../$REMOTE + create_random_file 'sample5' '1M' #adding a 1M file + git add sample5 + git commit --quiet -m"fourth 1M sample created" + cd ../../$REPO_NAME + #fetching + git submodule update --init --recursive --force --remote &> /dev/null + git fetch --progress --tags --prune --prune-tags 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 ../$REMOTE + git reset --hard -q HEAD~1 + cd ../.. + rm -rf performance_testing +} +test7(){ + section TEST7 + echo 'TEST 7: after removal of a 1M file' + #initialization + git clone --recurse-submodules --remote-submodules --progress --depth=1 --no-local $1 &> /dev/null + cd $REPO_NAME + get_storage_used . + mem_before=$mem + #modification of the remote repo + cd ../$REMOTE + rm sample0 + git add sample0 + git commit --quiet -m"1M sample0 deleted" + cd ../../$REPO_NAME + #fetching + git submodule update --init --recursive --force --remote &> /dev/null + git fetch --progress --tags --prune --prune-tags 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 ../$REMOTE + git reset --hard -q HEAD~1 + git clean -df + cd ../.. + rm -rf performance_testing +} +test8(){ + section TEST8 + echo 'TEST 8: after addition then removal of a 1M file' + #initialization + git clone --recurse-submodules --remote-submodules --progress --depth=1 --no-local $1 &> /dev/null + cd $REPO_NAME + get_storage_used . + mem_before=$mem + #modification of the remote repo + cd ../$REMOTE + create_random_file 'sample5' '1M' #adding a 1M file + git add sample5 + git commit --quiet -m"fourth 1M sample created" + rm sample5 + git add sample5 + git commit --quiet -m"1M "sample5" deleted" + cd ../../$REPO_NAME + #fetching + git submodule update --init --recursive --force --remote &> /dev/null + git fetch --progress --tags --prune --prune-tags 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 ../$REMOTE + git reset --hard -q HEAD~2 + cd ../.. + rm -rf performance_testing +} + +#fetching with --depth=1 +test9(){ + section TEST9 + echo 'TEST 9: after addition of a 1M file' + #initialization + git clone --recurse-submodules --remote-submodules --progress --depth=1 --no-local $1 &> /dev/null + cd $REPO_NAME + get_storage_used . + mem_before=$mem + #modification of the remote repo + cd ../$REMOTE + create_random_file 'sample5' '1M' #adding a 1M file + git add sample5 + git commit --quiet -m"fourth 1M sample created" + cd ../../$REPO_NAME + git submodule update --init --recursive --force --depth=1 --remote &> /dev/null + git fetch --progress --tags --depth=1 --prune --prune-tags 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 ../$REMOTE + git reset --hard -q HEAD~1 + cd ../.. + rm -rf performance_testing +} +test10(){ + section TEST10 + echo 'TEST 10: after removal of a 1M file' + #initialization + git clone --recurse-submodules --remote-submodules --progress --depth=1 --no-local $1 &> /dev/null + cd $REPO_NAME + get_storage_used . + mem_before=$mem + #modification of the remote repo + cd ../$REMOTE + rm sample0 + git add sample0 + git commit --quiet -m"1M sample0 deleted" + cd ../../$REPO_NAME + #fetching + git submodule update --init --recursive --force --depth=1 --remote &> /dev/null + git fetch --progress --tags --depth=1 --prune --prune-tags 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 ../$REMOTE + git reset --hard -q HEAD~1 + cd ../.. + rm -rf performance_testing +} +test11(){ + section TEST11 + echo 'TEST 11: after addition then removal of a 1M file' + git clone --recurse-submodules --remote-submodules --progress --depth=1 --no-local $1 &> /dev/null + cd $REPO_NAME + get_storage_used . + mem_before=$mem + #modification of the remote repo + cd ../$REMOTE + create_random_file 'sample5' '1M' #adding a 1M file + git add sample5 + git commit --quiet -m"fourth 1M sample created" + rm sample5 + git add sample5 + git commit --quiet -m"1M "sample5" deleted" + cd ../../$REPO_NAME + #fetching + git submodule update --init --recursive --force --depth=1 --remote &> /dev/null + git fetch --progress --tags --depth=1 --prune --prune-tags 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 ../$REMOTE + git reset --hard -q HEAD~2 + cd ../.. + rm -rf performance_testing +} + +# --depth=1 fetching with reflog and gc +test12(){ + section TEST12 + echo 'TEST 12: after addition of a 1M file' + #initialization + git clone --recurse-submodules --remote-submodules --progress --depth=1 --no-local $1 &> /dev/null + cd $REPO_NAME + get_storage_used . + mem_before=$mem + #modification of the remote repo + cd ../$REMOTE + create_random_file 'sample5' '1M' #adding a 1M file + git add sample5 + git commit --quiet -m"fourth 1M sample created" + cd ../../$REPO_NAME + git submodule update --init --recursive --force --depth=1 --remote &> /dev/null + git fetch --progress --tags --depth=1 --prune --prune-tags origin &> /dev/null + git checkout -f origin/main &> /dev/null + git reflog expire --expire=now --all &> /dev/null + git gc --aggressive --prune=now &> /dev/null + get_storage_used . + mem_after=$mem + mem=$(($mem_after-$mem_before)) + echo "memory usage: +$mem" + cd ../$REMOTE + git reset --hard -q HEAD~1 + cd ../.. + rm -rf performance_testing +} +test13(){ + section TEST13 + echo 'TEST 13: after removal of a 1M file' + #initialization + git clone --recurse-submodules --remote-submodules --progress --depth=1 --no-local $1 &> /dev/null + cd $REPO_NAME + get_storage_used . + mem_before=$mem + #modification of the remote repo + cd ../$REMOTE + rm sample0 + git add sample0 + git commit --quiet -m"1M sample0 deleted" + cd ../../$REPO_NAME + #fetching + git submodule update --init --recursive --force --depth=1 --remote &> /dev/null + git fetch --progress --tags --depth=1 --prune --prune-tags origin &> /dev/null + git checkout -f origin/main &> /dev/null + git reflog expire --expire=now --all &> /dev/null + git gc --aggressive --prune=now &> /dev/null + get_storage_used . + mem_after=$mem + mem=$(($mem_after-$mem_before)) + echo "memory usage: $mem" + cd ../$REMOTE + git reset --hard -q HEAD~1 + cd ../.. + rm -rf performance_testing +} +test14(){ + section TEST14 + echo 'TEST 14: after addition then removal of a 1M file' + git clone --recurse-submodules --remote-submodules --progress --depth=1 --no-local $1 &> /dev/null + cd $REPO_NAME + get_storage_used . + mem_before=$mem + #modification of the remote repo + cd ../$REMOTE + create_random_file 'sample5' '1M' #adding a 1M file + git add sample5 + git commit --quiet -m"fourth 1M sample created" + rm sample5 + git add sample5 + git commit --quiet -m"1M "sample5" deleted" + cd ../../$REPO_NAME + #fetching + git submodule update --init --recursive --force --depth=1 --remote &> /dev/null + git fetch --progress --tags --depth=1 --prune --prune-tags origin &> /dev/null + git checkout -f origin/main &> /dev/null + git reflog expire --expire=now --all &> /dev/null + git gc --aggressive --prune=now &> /dev/null + get_storage_used . + mem_after=$mem + mem=$(($mem_after-$mem_before)) + echo "memory usage: $mem" + cd ../$REMOTE + git reset --hard -q HEAD~2 + cd ../.. + rm -rf performance_testing +} + +#--depth=1 fetching with reset --hard +test15(){ + section TEST15 + echo 'TEST 15: after addition of a 1M file' + #initialization + git clone --recurse-submodules --remote-submodules --progress --depth=1 --no-local $1 &> /dev/null + cd $REPO_NAME + get_storage_used . + mem_before=$mem + #modification of the remote repo + cd ../$REMOTE + create_random_file 'sample5' '1M' #adding a 1M file + git add sample5 + git commit --quiet -m"fourth 1M sample created" + cd ../../$REPO_NAME + git submodule update --init --recursive --force --depth=1 --remote &> /dev/null + git fetch --progress --tags --depth=1 --prune --prune-tags origin &> /dev/null + git reset --hard origin/main &> /dev/null + get_storage_used . + mem_after=$mem + mem=$(($mem_after-$mem_before)) + echo "memory usage: +$mem" + cd ../$REMOTE + git reset --hard -q HEAD~1 + cd ../.. + rm -rf performance_testing +} +test16(){ + section TEST16 + echo 'TEST 16: after removal of a 1M file' + #initialization + git clone --recurse-submodules --remote-submodules --progress --depth=1 --no-local $1 &> /dev/null + cd $REPO_NAME + get_storage_used . + mem_before=$mem + #modification of the remote repo + cd ../$REMOTE + rm sample0 + git add sample0 + git commit --quiet -m"1M sample0 deleted" + cd ../../$REPO_NAME + #fetching + git submodule update --init --recursive --force --depth=1 --remote &> /dev/null + git fetch --progress --tags --depth=1 --prune --prune-tags origin &> /dev/null + git reset --hard origin/main &> /dev/null + get_storage_used . + mem_after=$mem + mem=$(($mem_after-$mem_before)) + echo "memory usage: $mem" + cd ../$REMOTE + git reset --hard -q HEAD~1 + cd ../.. + rm -rf performance_testing +} +test17(){ + section TEST17 + echo 'TEST 17: after addition then removal of a 1M file' + git clone --recurse-submodules --remote-submodules --progress --depth=1 --no-local $1 &> /dev/null + cd $REPO_NAME + get_storage_used . + mem_before=$mem + #modification of the remote repo + cd ../$REMOTE + create_random_file 'sample5' '1M' #adding a 1M file + git add sample5 + git commit --quiet -m"fourth 1M sample created" + rm sample5 + git add sample5 + git commit --quiet -m"1M "sample5" deleted" + cd ../../$REPO_NAME + #fetching + git submodule update --init --recursive --force --depth=1 --remote &> /dev/null + git fetch --progress --tags --depth=1 --prune --prune-tags origin &> /dev/null + git reset --hard origin/main &> /dev/null + get_storage_used . + mem_after=$mem + mem=$(($mem_after-$mem_before)) + echo "memory usage: $mem" + cd ../$REMOTE + git reset --hard -q HEAD~2 + cd ../.. + rm -rf performance_testing +} +#--depth=1 fetching with reset --hard and reflog and gc +test18(){ + section TEST18 + echo 'TEST 18: after addition of a 1M file' + git clone --recurse-submodules --remote-submodules --progress --depth=1 --no-local $1 &> /dev/null + cd $REPO_NAME + get_storage_used . + mem_before=$mem + #modification of the remote repo + cd ../$REMOTE + create_random_file 'sample5' '1M' #adding a 1M file + git add sample5 + git commit --quiet -m"fourth 1M sample created" + cd ../../$REPO_NAME + #fetching + git submodule update --init --recursive --force --depth=1 --remote &> /dev/null + git fetch --progress --tags --depth=1 --prune --prune-tags origin &> /dev/null + git reset --hard origin/main &> /dev/null + git reflog expire --expire=now --all &> /dev/null + git gc --aggressive --prune=now &> /dev/null + get_storage_used . + mem_after=$mem + mem=$(($mem_after-$mem_before)) + echo "memory usage: $mem" + cd ../$REMOTE + git reset --hard -q HEAD~1 + cd ../.. + rm -rf performance_testing +} +test19(){ + section TEST19 + echo 'TEST 19: after removal of a 1M file' + #initialization + git clone --recurse-submodules --remote-submodules --progress --depth=1 --no-local $1 &> /dev/null + cd $REPO_NAME + get_storage_used . + mem_before=$mem + #modification of the remote repo + cd ../$REMOTE + rm sample0 + git add sample0 + git commit --quiet -m"1M sample0 deleted" + cd ../../$REPO_NAME + #fetching + git submodule update --init --recursive --force --depth=1 --remote &> /dev/null + git fetch --progress --tags --depth=1 --prune --prune-tags origin &> /dev/null + git reset --hard origin/main &> /dev/null + git reflog expire --expire=now --all &> /dev/null + git gc --aggressive --prune=now &> /dev/null + get_storage_used . + mem_after=$mem + mem=$(($mem_after-$mem_before)) + echo "memory usage: $mem" + cd ../$REMOTE + git reset --hard -q HEAD~1 + cd ../.. + rm -rf performance_testing +} +test20(){ + section TEST20 + echo 'TEST 20: after addition then removal of a 1M file' + git clone --recurse-submodules --remote-submodules --progress --depth=1 --no-local $1 &> /dev/null + cd $REPO_NAME + get_storage_used . + mem_before=$mem + #modification of the remote repo + cd ../$REMOTE + create_random_file 'sample5' '1M' #adding a 1M file + git add sample5 + git commit --quiet -m"fourth 1M sample created" + rm sample5 + git add sample5 + git commit --quiet -m"1M "sample5" deleted" + cd ../../$REPO_NAME + #fetching + git submodule update --init --recursive --force --depth=1 --remote &> /dev/null + git fetch --progress --tags --depth=1 --prune --prune-tags origin &> /dev/null + git reset --hard origin/main &> /dev/null + git reflog expire --expire=now --all &> /dev/null + git gc --aggressive --prune=now &> /dev/null + get_storage_used . + mem_after=$mem + mem=$(($mem_after-$mem_before)) + echo "memory usage: $mem" + cd ../$REMOTE + git reset --hard -q HEAD~2 + cd ../.. + rm -rf performance_testing +} +#--depth=1 fetching after modification applied in submodule +test21(){ + section TEST21 + echo 'TEST 21: after addition of a 1M file' + if [ "$WITH_SUBMODULE" = "true" ]; then + git clone --recurse-submodules --remote-submodules --progress --depth=1 --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 + git submodule update --init --recursive --force --depth=1 --remote &> /dev/null + git fetch --progress --tags --depth=1 --prune --prune-tags 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 +} + +test22(){ + section TEST22 + echo 'TEST 22: after removal of a 1M file' + if [ "$WITH_SUBMODULE" = "true" ]; then + git clone --recurse-submodules --remote-submodules --progress --depth=1 --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 + git submodule update --init --recursive --force --depth=1 --remote &> /dev/null + git fetch --progress --tags --depth=1 --prune --prune-tags 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 +} + +test23(){ + section TEST23 + echo 'TEST 23: after addition then removal of a 1M file' + if [ "$WITH_SUBMODULE" = "true" ]; then + git clone --recurse-submodules --remote-submodules --progress --depth=1 --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 + git submodule update --init --recursive --force --depth=1 --remote &> /dev/null + git fetch --progress --tags --depth=1 --prune --prune-tags 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 +} + +# --depth=1 fetching+merging -X theirs with reflog and gc +test24(){ + section TEST24 + echo 'TEST 24: after addition of a 1M file' + #initialization + git clone --recurse-submodules --remote-submodules --progress --depth=1 --no-local $1 &> /dev/null + cd $REPO_NAME + get_storage_used . + mem_before=$mem + #modification of the remote repo + cd ../$REMOTE + create_random_file 'sample5' '1M' #adding a 1M file + git add sample5 + git commit --quiet -m"fourth 1M sample created" + cd ../../$REPO_NAME + git submodule update --init --recursive --force --depth=1 --remote &> /dev/null + git fetch --progress --tags --depth=1 --prune --prune-tags origin &> /dev/null + git merge -X theirs --allow-unrelated-histories &> /dev/null + git reflog expire --expire=now --all &> /dev/null + git gc --aggressive --prune=now &> /dev/null + get_storage_used . + mem_after=$mem + mem=$(($mem_after-$mem_before)) + echo "memory usage: +$mem" + cd ../$REMOTE + git reset --hard -q HEAD~1 + cd ../.. + rm -rf performance_testing +} +test25(){ + section TEST25 + echo 'TEST 25: after removal of a 1M file' + #initialization + git clone --recurse-submodules --remote-submodules --progress --depth=1 --no-local $1 &> /dev/null + cd $REPO_NAME + get_storage_used . + mem_before=$mem + #modification of the remote repo + cd ../$REMOTE + rm sample0 + git add sample0 + git commit --quiet -m"1M sample0 deleted" + cd ../../$REPO_NAME + #fetching + git submodule update --init --recursive --force --depth=1 --remote &> /dev/null + git fetch --progress --tags --depth=1 --prune --prune-tags origin &> /dev/null + git merge -X theirs --allow-unrelated-histories &> /dev/null + git reflog expire --expire=now --all &> /dev/null + git gc --aggressive --prune=now &> /dev/null + get_storage_used . + mem_after=$mem + mem=$(($mem_after-$mem_before)) + echo "memory usage: $mem" + cd ../$REMOTE + git reset --hard -q HEAD~1 + cd ../.. + rm -rf performance_testing +} +test26(){ + section TEST26 + echo 'TEST 26: after addition then removal of a 1M file' + git clone --recurse-submodules --remote-submodules --progress --depth=1 --no-local $1 &> /dev/null + cd $REPO_NAME + get_storage_used . + mem_before=$mem + #modification of the remote repo + cd ../$REMOTE + create_random_file 'sample5' '1M' #adding a 1M file + git add sample5 + git commit --quiet -m"fourth 1M sample created" + rm sample5 + git add sample5 + git commit --quiet -m"1M "sample5" deleted" + cd ../../$REPO_NAME + #fetching + git submodule update --init --recursive --force --depth=1 --remote &> /dev/null + git fetch --progress --tags --depth=1 --prune --prune-tags origin &> /dev/null + git merge -X theirs --allow-unrelated-histories &> /dev/null + git reflog expire --expire=now --all &> /dev/null + git gc --aggressive --prune=now &> /dev/null + get_storage_used . + mem_after=$mem + mem=$(($mem_after-$mem_before)) + echo "memory usage: $mem" + cd ../$REMOTE + git reset --hard -q HEAD~2 + cd ../.. + rm -rf performance_testing +} + +# --depth=1 fetching+merging -s ours with reflog and gc +test27(){ + section TEST27 + echo 'TEST 27: after addition of a 1M file' + #initialization + git clone --recurse-submodules --remote-submodules --progress --depth=1 --no-local $1 &> /dev/null + cd $REPO_NAME + get_storage_used . + mem_before=$mem + #modification of the remote repo + cd ../$REMOTE + create_random_file 'sample5' '1M' #adding a 1M file + git add sample5 + git commit --quiet -m"fourth 1M sample created" + cd ../../$REPO_NAME + git submodule update --init --recursive --force --depth=1 --remote &> /dev/null + git fetch --progress --tags --depth=1 --prune --prune-tags origin &> /dev/null + git switch -c temp origin/main &> /dev/null #creating a temporary branch identical to origin/main + git merge -s ours --allow-unrelated-histories main &> /dev/null + git checkout main &> /dev/null + git merge --allow-unrelated-histories temp &> /dev/null + git branch -D temp &> /dev/null + git reflog expire --expire=now --all &> /dev/null + git gc --aggressive --prune=now &> /dev/null + get_storage_used . + mem_after=$mem + mem=$(($mem_after-$mem_before)) + echo "memory usage: +$mem" + cd ../$REMOTE + git reset --hard -q HEAD~1 + cd ../.. + rm -rf performance_testing +} +test28(){ + section TEST28 + echo 'TEST 28: after removal of a 1M file' + #initialization + git clone --recurse-submodules --remote-submodules --progress --depth=1 --no-local $1 &> /dev/null + cd $REPO_NAME + get_storage_used . + mem_before=$mem + #modification of the remote repo + cd ../$REMOTE + rm sample0 + git add sample0 + git commit --quiet -m"1M sample0 deleted" + cd ../../$REPO_NAME + #fetching + git submodule update --init --recursive --force --depth=1 --remote &> /dev/null + git fetch --progress --tags --depth=1 --prune --prune-tags origin &> /dev/null + git switch -c temp origin/main &> /dev/null #creating a temporary branch identical to origin/main + git merge -s ours --allow-unrelated-histories main &> /dev/null + git checkout main &> /dev/null + git merge --allow-unrelated-histories temp &> /dev/null + git branch -D temp &> /dev/null + git reflog expire --expire=now --all &> /dev/null + git gc --aggressive --prune=now &> /dev/null + get_storage_used . + mem_after=$mem + mem=$(($mem_after-$mem_before)) + echo "memory usage: $mem" + cd ../$REMOTE + git reset --hard -q HEAD~1 + cd ../.. + rm -rf performance_testing +} +test29(){ + section TEST29 + echo 'TEST 29: after addition then removal of a 1M file' + git clone --recurse-submodules --remote-submodules --progress --depth=1 --no-local $1 &> /dev/null + cd $REPO_NAME + get_storage_used . + mem_before=$mem + #modification of the remote repo + cd ../$REMOTE + create_random_file 'sample5' '1M' #adding a 1M file + git add sample5 + git commit --quiet -m"fourth 1M sample created" + rm sample5 + git add sample5 + git commit --quiet -m"1M "sample5" deleted" + cd ../../$REPO_NAME + #fetching + git submodule update --init --recursive --force --depth=1 --remote &> /dev/null + git fetch --progress --tags --depth=1 --prune --prune-tags origin &> /dev/null + git switch -c temp origin/main &> /dev/null #creating a temporary branch identical to origin/main + git merge -s ours --allow-unrelated-histories main &> /dev/null + git checkout main &> /dev/null + #git merge --allow-unrelated-histories temp &> /dev/null + git branch -D temp &> /dev/null + git reflog expire --expire=now --all &> /dev/null + git gc --aggressive --prune=now &> /dev/null + get_storage_used . + mem_after=$mem + mem=$(($mem_after-$mem_before)) + echo "memory usage: $mem" + cd ../$REMOTE + git reset --hard -q HEAD~2 + cd ../.. + rm -rf performance_testing +} + + +while getopts ":hn:a" option; do + case $option in + h) # display Help + Help + exit;; + c) # clean + clean + n) # perform a specific test + TEST_NUM=$OPTARG;; + a) # perform all tests + ALL_TESTS=true;; + \?) # invalid option + echo "Error: Invalid option" + Help + exit;; + esac +done + +if [ "$ALL_TESTS" = "true" ]; then + test0 $REMOTE + test1 $REMOTE + test2 $REMOTE + test3 $REMOTE + test4 $REMOTE + test5 $REMOTE + echo $(section "Tests on the updating of the repository") + section "classic fetching+checking out" + test6 $REMOTE + test7 $REMOTE + test8 $REMOTE + echo $(section "fetching+checking out with --depth=1") + test9 $REMOTE + test10 $REMOTE + test11 $REMOTE + echo $(section "--depth=1 fetching+checking out reflog and gc") + test12 $REMOTE + test13 $REMOTE + test14 $REMOTE + echo $(section "--depth=1 fetching+ reset --hard") + test15 $REMOTE + test16 $REMOTE + test17 $REMOTE + echo $(section "--depth=1 fetching+ reset --hard and reflog and gc") + test18 $REMOTE + test19 $REMOTE + test20 $REMOTE + echo $(section "--depth=1 fetching+checking out after modification applied in submodule") + test21 $REMOTE + test22 $REMOTE + test23 $REMOTE + echo $(section "--depth=1 fetching+merging -X theirs with reflog and gc") + test24 $REMOTE + test25 $REMOTE + test26 $REMOTE + echo $(section "--depth=1 fetching+merging -s ours with reflog and gc") + test27 $REMOTE + test28 $REMOTE + test29 $REMOTE + + +elif [ -n "$TEST_NUM" ]; then + case $TEST_NUM in + 0) + test0 $REMOTE;; + 1) + test1 $REMOTE;; + 2) + test2 $REMOTE;; + 3) + test3 $REMOTE;; + 4) + test4 $REMOTE;; + 5) + test5 $REMOTE;; + 6) + test6 $REMOTE;; + 7) + test7 $REMOTE;; + 8) + test8 $REMOTE;; + 9) + test9 $REMOTE;; + 10) + test10 $REMOTE;; + 11) + test11 $REMOTE;; + 12) + test12 $REMOTE;; + 13) + test13 $REMOTE;; + 14) + test14 $REMOTE;; + 15) + test15 $REMOTE;; + 16) + test16 $REMOTE;; + 17) + test17 $REMOTE;; + 18) + test18 $REMOTE;; + 19) + test19 $REMOTE;; + 20) + test20 $REMOTE;; + 21) + test21 $REMOTE;; + 22) + test22 $REMOTE;; + 23) + test23 $REMOTE;; + 24) + test24 $REMOTE;; + 25) + test25 $REMOTE;; + 26) + test26 $REMOTE;; + 26) + test26 $REMOTE;; + 27) + test27 $REMOTE;; + 28) + test28 $REMOTE;; + 29) + test29 $REMOTE;; + *) + echo "Error: Invalid test number" + exit;; + esac +fi \ No newline at end of file diff --git a/test/performance_tests/readme b/test/performance_tests/readme index 3c8f7cc..cb4aed9 100644 --- a/test/performance_tests/readme +++ b/test/performance_tests/readme @@ -1,60 +1,27 @@ -## Testing of different cloning methods +## Introduction Our objective is to find the least-consuming method in terms of memory and bandwidth resources. -We are interested in cloning one specific state of the repository. We are not interested in its history or the possibility to change it from the server where it has been cloned. The first step is done by the script creation_repo.sh which creates an adequate repository to act as a local remote. The testing in itself is done by performance_tests.sh. +We are interested in cloning one specific state of the repository. We are not interested in its history or the possibility to change it from the server where it has been cloned. +The tests rely on a repository created by test_repo_creation.sh. It measures memory and bandwidth usage for different git commande. -## Creation of the test repository -The script creation_repo.sh creates a remote/performance_testing repository. -NAME - creation_repo.sh -SYNOPSIS - creation_repo.sh [-h] [-s] -DESCRIPTION - This script creates a ./remote directory in the current directory, then creates a remote/performance_testing git repository. - This git repository is filled with randomly generated binary files described in the readme.md. -OPTIONS - -h prints the help. - -s creates a submodule remote/submodule_for_performance_testing and includes it in remote/performance_testing. " +## Tests +The script consists of twenty-nine tests (listed in the results below), based on three functions: generate_random_file, get_storage_used and get_bandwidth. -Here is a history of the commits: -### branch main -commit sample0 1M created (tag: start) -commit sample1 1M created -commit sample3 1M created -commit sample4 5M created -commit sample4 5M deleted -[if -s is selected] commit adding submodule_for_performance_testing module -### branch secondary -commit sample0 1M created -commit sample1 1M created -commit sample2 500K created +generate_random_file uses the bash command dd and /dev/random. +get_storage_used uses the bash command du. +get_bandwidth retrieves the output of Git commands and extracts the traffic displayed. This does not take submodule traffic into account. -Which gives the latest state: -### branch main -sample0 1M -sample1 1M -sample3 1M -### branch secondary -sample0 1M -sample1 1M -sample2 500K +The first five tests concern cloning. +The following tests involve updating the repository using different commands, with three cases for each command: after adding a file, after deleting a file, after adding then deleting a file. -If the -s option is selected, submodule_for_performance_testing is created with this history of commits: -### branch main -commit first 1M sample created - -which gives the latest state: -### branch main -sub_sample0 - -## Testing -The script performance_tests.sh measures memory and bandwidth usage for different git commands. It sources the script driglibash-base. It executes creation_repo.sh in order to have an adequate repository to test on. +## Help extract NAME performance_tests.sh SYNOPSIS performance_tests.sh [-a] [-h] [-n number] OPTIONS - -a excutes all the tests. - -n number executes test number + -a executes all the tests. + -n number executes test number. + -c cleans. -h prints the help. DESCRIPTION This script allows you to measure memory and bandwidth usage. The first five test different cloning methods. Te following apply changes to the local remote before testing fetching and merging commands. @@ -96,3 +63,6 @@ DESCRIPTION TEST27: --depth=1 fetching+merging -s ours with reflog and gc after addition of a 1M file TEST28: --depth=1 fetching+merging -s ours with reflog and gc after removal of a 1M file TEST29: --depth=1 fetching+merging -s ours with reflog and gc after addition then removal of a 1M file" + +## To go further +To learn more about the process of testing different git methods conducted, please refer to doc/developement_explanations.md. \ No newline at end of file diff --git a/test/readme b/test/readme new file mode 100644 index 0000000..c456c7b --- /dev/null +++ b/test/readme @@ -0,0 +1,51 @@ +# Introduction +performance_tests contains tests who compare the memory and bandwidth usage of different Git commande in order to compare them. +functional_tests contains tests who verify that git_update.sh is behaving as expected. +Both rely on the same test repository that is created by test_repo_creation.sh. + +# Creation of the test repository +The script test_repo_creation.sh creates a remote/$REPO_NAME repository. +## Help extract +NAME + test_repo_creation.sh +SYNOPSIS + test_repo_creation.sh [-h] [-l] [-s] +DESCRIPTION + This script creates a ./remote directory in the current directory, then creates a remote/$REPO_NAME git repository. + This git repository is filled with randomly generated binary files described in the readme.md. +OPTIONS + -h prints the help. + -l [link] adds the linked online repository as remote and pushes changes to it. Must be en empty repository. + -s creates a submodule remote/$SUB_NAME and includes it in remote/$REPO_NAME. + +# Description of the created repository +Here is a history of the commits: +### branch main +commit sample0 1M created +commit sample1 1M created +commit sample3 5M created +commit sample4 1M created +commit sample3 5M deleted (tag : tagging_point) +[if -s is selected] commit adding $SUB_NAME module +### branch secondary +commit sample0 1M created +commit sample1 1M created +commit sample2 500K created + +Which gives the latest state: +### branch main +sample0 1M +sample1 1M +sample4 1M +### branch secondary +sample0 1M +sample1 1M +sample2 500K + +If the -s option is selected, the submodule is created, and integrated in the last commit of main, with this history of commits: +### branch main +commit first 1M sample created + +which gives the latest state: +### branch main +sub_sample0 \ No newline at end of file diff --git a/test/creation_repo.sh b/test/test_repo_creation.sh similarity index 86% rename from test/creation_repo.sh rename to test/test_repo_creation.sh index 346a792..962df35 100755 --- a/test/creation_repo.sh +++ b/test/test_repo_creation.sh @@ -3,16 +3,16 @@ Help() { echo " NAME - creation_repo.sh + test_repo_creation.sh SYNOPSIS - creation_repo.sh [-h] [-s] + test_repo_creation.sh [-h] [-l] [-s] DESCRIPTION - This script creates a ./remote directory in the current directory, then creates a remote/performance_testing git repository. + This script creates a ./remote directory in the current directory, then creates a remote/$REPO_NAME git repository. This git repository is filled with randomly generated binary files described in the readme.md. OPTIONS -h prints the help. -l [link] adds the linked online repository as remote and pushes changes to it. Must be en empty repository. - -s creates a submodule remote/submodule_for_performance_testing and includes it in remote/performance_testing. " + -s creates a submodule remote/$SUB_NAME and includes it in remote/$REPO_NAME. " } create_random_file(){ @@ -47,7 +47,7 @@ if [ ! -d $REPO_PATH ]; then fi cd $REPO_PATH if [ ! -d $REPO_NAME ]; then - echo "remote/performance testing will be created" + echo "remote/$REPO_NAME will be created" mkdir $REPO_NAME cd $REPO_NAME git init @@ -64,16 +64,16 @@ if [ ! -d $REPO_NAME ]; then git add sample2 git commit -m"first 500K sample created in branch secondary" git checkout main - create_random_file 'sample4' '5M' - git add sample4 + create_random_file 'sample3' '5M' + git add sample3 git commit -m"first 5M sample created" git tag tagging_point - create_random_file 'sample3' '1M' - git add sample3 - git commit -m"third 1M sample created" - rm sample4 + create_random_file 'sample4' '1M' git add sample4 - git commit -m"sample4 deleted" + git commit -m"third 1M sample created" + rm sample3 + git add sample3 + git commit -m"sample3 deleted" cd .. if [ "$WITH_SUBMODULE" = "true" ]; then mkdir $SUB_NAME