Skip to content

Instantly share code, notes, and snippets.

@kylemanna
Last active May 17, 2019 03:13
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kylemanna/3b78b94e1ae85b3ff4ca34c33fb3bd34 to your computer and use it in GitHub Desktop.
Save kylemanna/3b78b94e1ae85b3ff4ca34c33fb3bd34 to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
#export GIT_TRACE=1
#export GIT_CURL_VERBOSE=1
set -ex
lfs_explode() {
cd "$i"
while true; do
echo "Starting git fetch $BASHPID"
rm -rf .git/lfs
git lfs fetch 2>&1 || break
echo "Completed git fetch $BASHPID"
done
echo
echo
echo EXITED $BASHID
exit 1
}
repo=$1
cnt=${2:-2}
dest=$(basename $repo)
trap "killall background" EXIT
if [ ! -d $dest ]; then
git clone --depth 1 $repo $dest
fi
work=()
for i in $(seq $cnt); do
work+=("${dest}${i}")
done
for i in ${work[*]}; do
echo Fixing $i
rm -rf ${i}
cp -al ${dest} ${i}
git -C ${i} config lfs.transfer.maxretries 10
git -C ${i} lfs env
git --no-pager -C ${i} config -l
lfs_explode "$i" &
done
time wait -n
killall background
wait
#!/usr/bin/env bash
# Bitbucket appears to rate limit ssh connections, launch several connections
# that repeatedly connect to ssh and exit until each returns a bad status.
#export GIT_TRACE_PACKET=1
#export GIT_TRACE=1
#export GIT_SSH_COMMAND="ssh -vvv"
#export GIT_CURL_VERBOSE=1
spin_bitbucket() {
i=0
t0=$(date +%s.%N)
while true; do
ssh -Tvvv git@bitbucket.org || break
t1=$(date +%s.%N)
i=$(($i + 1))
rate=$(echo "scale=3; $i/($t1 - $t0)" | bc)
echo ":: $(date) $0($BASHPID): iteration $i, rate = $rate req/s"
done
}
trap "killall background" EXIT
# Default to 5 parallel processes
cnt=${1:-5}
for i in $(seq $cnt); do
spin_bitbucket &
done
wait
@kylemanna
Copy link
Author

Update, bitbucket wasn't an issue, a Palo Alto Network Firewall had overly aggressive application settings. Sigh.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment