@@ -3683,6 +3683,56 @@ function e2e::exechook_git_archive() {
36833683 assert_tgz_archive " $ROOT /link/archive.tgz"
36843684}
36853685
3686+ # #############################################
3687+ # Test init-period uses faster interval for initial sync
3688+ # #############################################
3689+ function e2e::init_period_faster_initial_sync() {
3690+ # First sync
3691+ echo " ${FUNCNAME[0]} 1" > " $REPO /file"
3692+ git -C " $REPO " commit -qam " ${FUNCNAME[0]} 1"
3693+
3694+ GIT_SYNC \
3695+ --period=100s \
3696+ --init-period=100ms \
3697+ --repo=" file://$REPO " \
3698+ --root=" $ROOT " \
3699+ --link=" link" \
3700+ &
3701+ # With init-period=100ms, sync should happen quickly even though
3702+ # period=100s. If init-period were not working, this would time out.
3703+ wait_for_sync " ${MAXWAIT} "
3704+ assert_link_exists " $ROOT /link"
3705+ assert_file_exists " $ROOT /link/file"
3706+ assert_file_eq " $ROOT /link/file" " ${FUNCNAME[0]} 1"
3707+ assert_metric_eq " ${METRIC_GOOD_SYNC_COUNT} " 1
3708+
3709+ # After initial sync, period should switch to the normal 100s.
3710+ # Make a new commit and verify it does NOT sync quickly (because
3711+ # we're now using the slow period).
3712+ echo " ${FUNCNAME[0]} 2" > " $REPO /file"
3713+ git -C " $REPO " commit -qam " ${FUNCNAME[0]} 2"
3714+ # Wait a bit - should NOT have synced since normal period is 100s
3715+ sleep 3
3716+ assert_file_eq " $ROOT /link/file" " ${FUNCNAME[0]} 1"
3717+ assert_metric_eq " ${METRIC_GOOD_SYNC_COUNT} " 1
3718+ }
3719+
3720+ # #############################################
3721+ # Test init-timeout exits on timeout
3722+ # #############################################
3723+ function e2e::init_timeout_expires() {
3724+ assert_fail \
3725+ GIT_SYNC \
3726+ --git=" /$SLOW_GIT_FETCH " \
3727+ --period=100ms \
3728+ --init-timeout=1s \
3729+ --max-failures=-1 \
3730+ --repo=" file://$REPO " \
3731+ --root=" $ROOT " \
3732+ --link=" link"
3733+ assert_file_absent " $ROOT /link/file"
3734+ }
3735+
36863736#
36873737# main
36883738#
0 commit comments