Merge pull request #494 from thockin/master

Set repoReady even when there wasn't a 1st clone (v4 branch)
This commit is contained in:
Kubernetes Prow Robot 2022-02-14 04:33:30 -08:00 committed by GitHub
commit 7768c58e93
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 63 additions and 10 deletions

View File

@ -614,17 +614,20 @@ func main() {
cancel()
time.Sleep(*flPeriod)
continue
} else if changed {
if webhookRunner != nil {
webhookRunner.Send(hash)
}
if exechookRunner != nil {
exechookRunner.Send(hash)
}
updateSyncMetrics(metricKeySuccess, start)
} else {
updateSyncMetrics(metricKeyNoOp, start)
// this might have been called before, but also might not have
setRepoReady()
if changed {
if webhookRunner != nil {
webhookRunner.Send(hash)
}
if exechookRunner != nil {
exechookRunner.Send(hash)
}
updateSyncMetrics(metricKeySuccess, start)
} else {
updateSyncMetrics(metricKeyNoOp, start)
}
}
if initialSync {

View File

@ -1431,6 +1431,56 @@ function e2e::http() {
fi
}
##############################################
# Test http handler after restart
##############################################
function e2e::http_after_restart() {
BINDPORT=8888
echo "$FUNCNAME" > "$REPO"/file
git -C "$REPO" commit -qam "$FUNCNAME 1"
# Sync once to set up the repo
GIT_SYNC \
--one-time \
--repo="file://$REPO" \
--branch="$MAIN_BRANCH" \
--root="$ROOT" \
--link="link" \
>> "$1" 2>&1
assert_link_exists "$ROOT"/link
assert_file_exists "$ROOT"/link/file
assert_file_eq "$ROOT"/link/file "$FUNCNAME"
# Sync again and prove readiness.
GIT_SYNC \
--repo="file://$REPO" \
--branch="$MAIN_BRANCH" \
--root="$ROOT" \
--http-bind=":$BINDPORT" \
--link="link" \
>> "$1" 2>&1 &
# do nothing, just wait for the HTTP to come up
for i in $(seq 1 5); do
sleep 1
if curl --silent --output /dev/null http://localhost:$BINDPORT; then
break
fi
if [[ "$i" == 5 ]]; then
fail "HTTP server failed to start"
fi
done
sleep 2
# check that health endpoint is alive
if [[ $(curl --write-out %{http_code} --silent --output /dev/null http://localhost:$BINDPORT) -ne 200 ]] ; then
fail "health endpoint failed"
fi
assert_link_exists "$ROOT"/link
assert_file_exists "$ROOT"/link/file
assert_file_eq "$ROOT"/link/file "$FUNCNAME"
}
##############################################
# Test submodule sync
##############################################