vtest "test startup_timeout vs. stevedore init / open"

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

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


process p1 { vinyld \
	-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

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

process p2 { vinyld \
	-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}}
