varnishtest "test startup_timeout vs. stevedore init / open"

# we test with vtc_varnish and vtc_process because of different code
# paths in mgr for implicit start vs. cli start

####
# startup_timeout used, delay in stevedore init
varnish v1 -arg "-sdebug=debug,dinit=5s -pstartup_timeout=3s -pcli_timeout=2s" \
	-arg "-p feature=+no_coredump" \
	-vcl "backend none none;" \
	-expectexit 0x40
varnish v1 -cliexpect \
	"Child failed on launch within startup_timeout=3.00s" \
	"start"
# v1 registers a panic on some systems, but not others
shell {varnishadm -n ${v1_name} panic.clear || true }
varnish v1 -wait


process p1 { varnishd \
	-sdebug=debug,dinit=5s \
	-pstartup_timeout=3s -pcli_timeout=2s \
	-n ${tmpdir}/p1 -a :0 -b none 2>&1
} -expect-exit 0x2 -run
# expect-text does not work if a panic info pushes the
# error out of the emulated terminal's view.
shell {grep -q "Child failed on launch within startup_timeout=3.00s" ${p1_out}}

####
# cli_timeout used, delay in stevedore open

varnish v2 -arg "-sdebug=debug,dopen=5s -pstartup_timeout=2s -pcli_timeout=3s" \
	-arg "-p feature=+no_coredump" \
	-vcl "backend none none;" \
	-expectexit 0x40
varnish v2 -cliexpect \
	"launch within cli_timeout=3.00s .tip: set startup_" \
	"start"
# "time for the big quit"
varnish v2 -cliok "panic.clear"
varnish v2 -wait

process p2 { varnishd \
	-sdebug=debug,dopen=5s \
	-pstartup_timeout=2s -pcli_timeout=3s \
	-n ${tmpdir}/p2 -a :0 -b none
} -expect-exit 0x2 -run

# XXX not reliably the only failure mode
#shell {grep -q "time for the big quit" ${p2_err}}

# see explanation of previous shell grep
shell {grep -q "launch within cli_timeout=3.00s (tip: set startup_" ${p2_err}}
