Skip to content

Commit

Permalink
checking that the git daemons are set up before running integration t…
Browse files Browse the repository at this point in the history
…ests
  • Loading branch information
shawnHartsell committed Apr 5, 2024
1 parent 23ff827 commit 09d0eed
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions script/test-build
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,18 @@ function before_suite() {
--base-path=test/tmp/dest &>$DEST_GIT_DAEMON_OUTPUT &
DEST_GIT_DAEMON_PID=$!

# wait for the git daemons to start before continuing

if ! check_git_daemon $SRC_GIT_DAEMON_PORT; then
echo "timeout waiting for src git daemon to start"
exit 1
fi

if ! check_git_daemon $DEST_GIT_DAEMON_PORT; then
echo "timeout waiting for dest git daemon to start"
exit 1
fi

go run test/github.go \
-p "$DEST_API_PORT" \
-git-daemon-url "git://localhost:$DEST_GIT_DAEMON_PORT/" &>$DEST_API_OUTPUT &
Expand Down Expand Up @@ -383,6 +395,23 @@ function fail() {
exit 1
}

function check_git_daemon {
port=$1

for _ in {1..10}; do
process=$(lsof -i ":$port" | grep 'git-daemon')
if [ -z "$process" ]; then
echo "Waiting for git daemon to start on port $port..."
sleep 1
else
echo "Git daemon is running on port $port"
return 0
fi
done
echo "Git daemon did not start within the expected time."
return 1
}

test_version
before_suite
test_pull
Expand Down

0 comments on commit 09d0eed

Please sign in to comment.