vtest "Test parking second request on backend delay (waitinglist)"

barrier b1 cond 2
barrier b2 cond 2

server s1 {
	rxreq
	expect req.url == "/foo"
	send "HTTP/1.0 200 OK\r\nConnection: close\r\n\r\n"
	delay .2
	barrier b1 sync
	delay .2
	send "line1\n"
	delay .2
	barrier b2 sync
	send "line2\n"
} -start

vinyl v1 -vcl+backend {
	sub vcl_backend_response {
		set beresp.do_stream = false;
	}
} -start

vinyl v1 -cliok "param.set debug +syncvsl"

client c1 {
	txreq -url "/foo" -hdr "client: c1"
	rxresp
	expect resp.status == 200
	expect resp.bodylen == 12
	expect resp.http.X-Vinyl == "1001"
} -start

barrier b1 sync

client c2 {
	txreq -url "/foo" -hdr "client: c2"
	delay .2
	barrier b2 sync
	rxresp
	expect resp.status == 200
	expect resp.bodylen == 12
	expect resp.http.X-Vinyl == "1004 1002"
} -run

client c1 -wait

vinyl v1 -vsl_catchup
vinyl v1 -expect client_req == 2
vinyl v1 -expect busy_sleep >= 1
vinyl v1 -expect busy_wakeup >= 1
vinyl v1 -stop
