remote local
This commit is contained in:
parent
5241d2168b
commit
7b0ffbf6a1
@ -1,5 +1,4 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
#prend en entrée un lien ssh vers un répertoire remote git vide prêt à être rempli
|
|
||||||
|
|
||||||
Help()
|
Help()
|
||||||
{
|
{
|
||||||
@ -14,7 +13,7 @@ DESCRIPTION
|
|||||||
OPTIONS
|
OPTIONS
|
||||||
-h prints the help. "
|
-h prints the help. "
|
||||||
}
|
}
|
||||||
|
if [[ "${BASH_SOURCE[0]}" = "${0}" ]]; then
|
||||||
while getopts ":h" option; do
|
while getopts ":h" option; do
|
||||||
case $option in
|
case $option in
|
||||||
h) # display Help
|
h) # display Help
|
||||||
@ -25,47 +24,43 @@ while getopts ":h" option; do
|
|||||||
exit;;
|
exit;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
return 0
|
||||||
|
|
||||||
if [ -d performance_testing ]; then
|
|
||||||
rm -rf performance_testing
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
mkdir performance_testing
|
|
||||||
cd performance_testing
|
REPO_NAME=performance_testing
|
||||||
|
REPO_PATH=./remote
|
||||||
|
|
||||||
|
if [ ! -d $REPO_PATH ]; then
|
||||||
|
mkdir $REPO_PATH
|
||||||
|
fi
|
||||||
|
cd $REPO_PATH
|
||||||
|
if [ ! -d $REPO_NAME ]; then
|
||||||
|
mkdir $REPO_NAME
|
||||||
|
cd $REPO_NAME
|
||||||
git init
|
git init
|
||||||
git branch -m main
|
git branch -m main
|
||||||
git remote add origin $1
|
|
||||||
git fetch origin
|
|
||||||
git merge
|
|
||||||
dd if=/dev/urandom of=sample0 bs=1M count=1
|
dd if=/dev/urandom of=sample0 bs=1M count=1
|
||||||
git add .
|
git add .
|
||||||
git commit -m"first 1M sample created"
|
git commit -m"first 1M sample created"
|
||||||
git push -u origin main
|
|
||||||
git tag start
|
git tag start
|
||||||
git push origin start
|
|
||||||
dd if=/dev/urandom of=sample1 bs=1M count=1
|
dd if=/dev/urandom of=sample1 bs=1M count=1
|
||||||
git add sample1
|
git add sample1
|
||||||
git commit -m"second 1M sample created"
|
git commit -m"second 1M sample created"
|
||||||
git push
|
|
||||||
git branch secondary
|
git branch secondary
|
||||||
git checkout secondary
|
git checkout secondary
|
||||||
dd if=/dev/urandom of=sample2 bs=500K count=1
|
dd if=/dev/urandom of=sample2 bs=500K count=1
|
||||||
git add sample2
|
git add sample2
|
||||||
git commit -m"first 500K sample created in branch secondary"
|
git commit -m"first 500K sample created in branch secondary"
|
||||||
git push -u origin secondary
|
|
||||||
git checkout main
|
git checkout main
|
||||||
dd if=/dev/urandom of=sample3 bs=1M count=1
|
dd if=/dev/urandom of=sample3 bs=1M count=1
|
||||||
git add sample3
|
git add sample3
|
||||||
git commit -m"third 1M sample created"
|
git commit -m"third 1M sample created"
|
||||||
git push
|
|
||||||
dd if=/dev/urandom of=sample4 bs=5M count=1
|
dd if=/dev/urandom of=sample4 bs=5M count=1
|
||||||
git add sample4
|
git add sample4
|
||||||
git commit -m"first 5M sample created"
|
git commit -m"first 5M sample created"
|
||||||
git push
|
|
||||||
rm sample4
|
rm sample4
|
||||||
git add sample4
|
git add sample4
|
||||||
git commit -m"sample4 deleted"
|
git commit -m"sample4 deleted"
|
||||||
git push
|
fi
|
||||||
|
cd ..
|
||||||
#optional: tests to check if it has initialized correctly
|
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
. driglibash-base
|
. driglibash-base
|
||||||
|
. creation_repo.sh &> /dev/null
|
||||||
#prerequisite: creation_repo.sh has been run
|
#prerequisite: creation_repo.sh has been run
|
||||||
FILES_TO_KEEP='sample0'
|
FILES_TO_KEEP='sample0'
|
||||||
REPO_NAME='performance_testing'
|
REMOTE="./remote/performance_testing"
|
||||||
Help()
|
Help()
|
||||||
{
|
{
|
||||||
echo "
|
echo "
|
||||||
@ -24,71 +25,66 @@ DESCRIPTION
|
|||||||
test0(){
|
test0(){
|
||||||
section TEST0
|
section TEST0
|
||||||
echo "TEST 0 : case of classic cloning."
|
echo "TEST 0 : case of classic cloning."
|
||||||
git clone --progress $1 2> cloning_text
|
git clone --progress --no-local $1 2> cloning_text
|
||||||
mem0=$(du ./$REPO_NAME | tail -n1 | tr -cd [:digit:])
|
mem0=$(du ./$REPO_NAME | tail -n1 | tr -cd [:digit:])
|
||||||
bw0=$(grep -e "Receiving objects:" cloning_text| grep -o "[[:digit:].]* MiB " | tail -n1)
|
bw0=$(grep -e "Receiving objects:" cloning_text| grep -o "[[:digit:].]* MiB " | tail -n1)
|
||||||
echo "memory usage in a classic cloning : $mem0"
|
echo "memory usage in a classic cloning : $mem0"
|
||||||
echo "bandwidth usage : $bw0"
|
echo "bandwidth usage : $bw0"
|
||||||
|
run rm cloning_text
|
||||||
run rm -rf $REPO_NAME
|
run rm -rf $REPO_NAME
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
test1(){
|
test1(){
|
||||||
section TEST1
|
section TEST1
|
||||||
echo "TEST 1 : case of --single-branch cloning."
|
echo "TEST 1 : case of --single-branch cloning."
|
||||||
git clone --progress --single-branch $1 2> cloning_text
|
git clone --progress --single-branch --no-local $1 2> cloning_text
|
||||||
mem1=$(du ./$REPO_NAME| tail -n1 | tr -cd [:digit:])
|
mem1=$(du ./$REPO_NAME| tail -n1 | tr -cd [:digit:])
|
||||||
bw1=$(grep -e "Receiving objects:" cloning_text| grep -o "[[:digit:].]* MiB " | tail -n1)
|
bw1=$(grep -e "Receiving objects:" cloning_text| grep -o "[[:digit:].]* MiB " | tail -n1)
|
||||||
echo "memory usage in a --single-branch cloning : $mem1"
|
echo "memory usage in a --single-branch cloning : $mem1"
|
||||||
echo "bandwidth usage : $bw1"
|
echo "bandwidth usage : $bw1"
|
||||||
run
|
run rm cloning_text
|
||||||
rm -rf $REPO_NAME
|
run rm -rf $REPO_NAME
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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 --progress --depth=1 --no-single-branch $1 2> cloning_text
|
git clone --progress --depth=1 --no-local --no-single-branch $1 2> cloning_text
|
||||||
mem2=$(du ./$REPO_NAME| tail -n1 | tr -cd [:digit:])
|
mem2=$(du ./$REPO_NAME| tail -n1 | tr -cd [:digit:])
|
||||||
bw2=$(grep -e "Receiving objects:" cloning_text| grep -o "[[:digit:].]* MiB " | tail -n1)
|
bw2=$(grep -e "Receiving objects:" cloning_text| grep -o "[[:digit:].]* MiB " | tail -n1)
|
||||||
echo "memory usage in a --depth=1 --no-single-branch cloning : $mem2"
|
echo "memory usage in a --depth=1 --no-single-branch cloning : $mem2"
|
||||||
echo "bandwidth usage : $bw2"
|
echo "bandwidth usage : $bw2"
|
||||||
run
|
run rm cloning_text
|
||||||
rm -rf $REPO_NAME
|
run rm -rf $REPO_NAME
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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 --progress --single-branch --depth=1 $1 2> cloning_text
|
git clone --progress --single-branch --no-local --depth=1 $1 2> cloning_text
|
||||||
mem3=$(du ./$REPO_NAME| tail -n1 | tr -cd [:digit:])
|
mem3=$(du ./$REPO_NAME| tail -n1 | tr -cd [:digit:])
|
||||||
bw3=$(grep -e "Receiving objects:" cloning_text| grep -o "[[:digit:].]* MiB " | tail -n1)
|
bw3=$(grep -e "Receiving objects:" cloning_text| grep -o "[[:digit:].]* MiB " | tail -n1)
|
||||||
echo "memory usage in a --depth=1 with single-branch cloning : $mem3"
|
echo "memory usage in a --depth=1 with single-branch cloning : $mem3"
|
||||||
echo "bandwidth usage : $bw3"
|
echo "bandwidth usage : $bw3"
|
||||||
rm -rf $REPO_NAME
|
run rm cloning_text
|
||||||
|
run rm -rf $REPO_NAME
|
||||||
}
|
}
|
||||||
|
|
||||||
test4(){
|
test4(){
|
||||||
section TEST4
|
section TEST4
|
||||||
run mkdir $REPO_NAME
|
run mkdir $REPO_NAME
|
||||||
|
|
||||||
run echo 'TEST 4 : case of sparse-checking only some files with depth=1'
|
run echo 'TEST 4 : case of sparse-checking only some files with depth=1'
|
||||||
run cd $REPO_NAME
|
run cd $REPO_NAME
|
||||||
|
|
||||||
run git init -q
|
run git init -q
|
||||||
run git config core.sparsecheckout true
|
run git config core.sparsecheckout true
|
||||||
run echo $FILES_TO_KEEP >> .git/info/sparse-checkout
|
run echo $FILES_TO_KEEP >> .git/info/sparse-checkout
|
||||||
run git remote add -f origin $1 &> /dev/null
|
run git remote add -f origin file://$1 #&> /dev/null
|
||||||
run git pull origin main &> /dev/null
|
run git pull origin main #&> /dev/null
|
||||||
mem4=$(du . | tail -n1 | tr -cd [:digit:])
|
mem4=$(du . | tail -n1 | tr -cd [:digit:])
|
||||||
echo "memory usage with sparse checking only $FILES_TO_KEEP : $mem4"
|
echo "memory usage with sparse checking only $FILES_TO_KEEP : $mem4"
|
||||||
echo "The bandwidth usage is not available through the Git commands."
|
echo "The bandwidth usage is not available through the Git commands."
|
||||||
cd ..
|
run rm cloning_text
|
||||||
run rm -rf $REPO_NAME
|
run rm -rf $REPO_NAME
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#TESTS ON THE UPDATING OF THE REPOSITORY
|
#TESTS ON THE UPDATING OF THE REPOSITORY
|
||||||
@ -98,12 +94,21 @@ test5(){
|
|||||||
run echo 'TEST 5 : case of classic fetching and merging'
|
run echo 'TEST 5 : case of classic fetching and merging'
|
||||||
run git clone $1 &> /dev/null
|
run git clone $1 &> /dev/null
|
||||||
cd $REPO_NAME
|
cd $REPO_NAME
|
||||||
mem5temp=$(du . | tail -n1 | tr -cd [:digit:])
|
|
||||||
run git fetch -v origin &> fetching_text
|
run git fetch -v origin &> fetching_text
|
||||||
run git merge -v &> merging_text
|
run git merge -v &> merging_text
|
||||||
mem5=$(du . | tail -n1 | tr -cd [:digit:])
|
mem5before=$(du . | tail -n1 | tr -cd [:digit:])
|
||||||
|
#modification of the remote repo
|
||||||
|
cd $REMOTE
|
||||||
|
run dd if=/dev/urandom of=sample5 bs=1M count=1 #adding a 1M file
|
||||||
|
run git add sample5
|
||||||
|
run git commit -m"fourth 1M sample created"
|
||||||
|
cd -
|
||||||
|
run git fetch -v origin &> fetching_text
|
||||||
|
run git merge -v &> merging_text
|
||||||
|
mem5after=$(du . | tail -n1 | tr -cd [:digit:])
|
||||||
|
mem5=$(($mem5after-$mem5before))
|
||||||
echo "memory usage in a classic fetching and merging : $mem5"
|
echo "memory usage in a classic fetching and merging : $mem5"
|
||||||
echo "bandwidth usage : $bw5"
|
#echo "bandwidth usage : $bw5"
|
||||||
}
|
}
|
||||||
|
|
||||||
#test 6 : shallow exclude
|
#test 6 : shallow exclude
|
||||||
@ -113,47 +118,38 @@ while getopts ":hn:a" option; do
|
|||||||
h) # display Help
|
h) # display Help
|
||||||
Help
|
Help
|
||||||
exit;;
|
exit;;
|
||||||
\?) # Invalid option
|
|
||||||
echo "Error: Invalid option"
|
|
||||||
exit;;
|
|
||||||
n)
|
n)
|
||||||
TEST_NUM=$OPTARG;;
|
TEST_NUM=$OPTARG;;
|
||||||
a)
|
a)
|
||||||
ALL_TESTS=true;;
|
ALL_TESTS=true;;
|
||||||
|
\?) # Invalid option
|
||||||
|
echo "Error: Invalid option here"
|
||||||
|
exit;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
shift "$(($OPTIND -1))" #so that the cloning link is in $1 no matter how many options were used
|
|
||||||
if [ -z "$1" ]; then
|
|
||||||
echo "Error: No repository link provided"
|
|
||||||
Help
|
|
||||||
die
|
|
||||||
else
|
|
||||||
REPO_LINK=$1
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ "$ALL_TESTS" = true ]; then
|
if [ "$ALL_TESTS" = true ]; then
|
||||||
test0 $REPO_LINK
|
test0 $REMOTE
|
||||||
test1 $REPO_LINK
|
test1 $REMOTE
|
||||||
test2 $REPO_LINK
|
test2 $REMOTE
|
||||||
test3 $REPO_LINK
|
test3 $REMOTE
|
||||||
test4 $REPO_LINK
|
test4 $REMOTE
|
||||||
test5 $REPO_LINK
|
test5 $REMOTE
|
||||||
|
|
||||||
elif [ -n "$TEST_NUM" ]; then
|
elif [ -n "$TEST_NUM" ]; then
|
||||||
case $TEST_NUM in
|
case $TEST_NUM in
|
||||||
0)
|
0)
|
||||||
test0 $REPO_LINK;;
|
test0 $REMOTE;;
|
||||||
1)
|
1)
|
||||||
test1 $REPO_LINK;;
|
test1 $REMOTE;;
|
||||||
2)
|
2)
|
||||||
test2 $REPO_LINK;;
|
test2 $REMOTE;;
|
||||||
3)
|
3)
|
||||||
test3 $REPO_LINK;;
|
test3 $REMOTE;;
|
||||||
4)
|
4)
|
||||||
test4 $REPO_LINK;;
|
test4 $REMOTE;;
|
||||||
5)
|
5)
|
||||||
test5 $REPO_LINK;;
|
test5 $REMOTE;;
|
||||||
*)
|
*)
|
||||||
echo "Error: Invalid test number"
|
echo "Error: Invalid test number"
|
||||||
die;;
|
die;;
|
||||||
@ -162,5 +158,4 @@ else
|
|||||||
Help
|
Help
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#to do : use a local remote
|
|
||||||
#optimize in case all tests are run
|
#optimize in case all tests are run
|
||||||
|
Loading…
Reference in New Issue
Block a user