vtest "SLT_Hit ongoing fetch"

barrier b1 cond 2 -cyclic
barrier b2 cond 2 -cyclic

server s1 {
	rxreq
	txresp -nolen -hdr "Content-Length: 10"
	send hello
	barrier b1 sync
	barrier b2 sync
	send world

	rxreq
	txresp -nolen -hdr "Transfer-Encoding: chunked"
	chunked hello
	barrier b1 sync
	barrier b2 sync
	chunked world
	chunked ""
} -start

vinyl v1 -cliok "param.set debug +syncvsl"
vinyl v1 -cliok "param.set thread_pools 1"
vinyl v1 -vcl+backend "" -start

client c1 {
	txreq
	rxresp
	expect resp.body == helloworld
} -start

barrier b1 sync

logexpect l1 -v v1 -g raw {
	#                   vxid TTL     grace     keep     fetch length
	expect * 1004 Hit "^1002 [0-9.]+ 10.000000 0.000000 [0-5] 10$"
} -start

client c2 {
	txreq
	rxresp
	expect resp.body == helloworld
} -start

logexpect l1 -wait

barrier b2 sync

client c1 -wait
client c2 -wait

# Recycle almost everything for the chunked variant

vinyl v1 -cliok "ban obj.status != 0"

client c1 -start

barrier b1 sync

logexpect l2 -v v1 -g raw {
	#                   vxid TTL     grace     keep     fetch
	expect * 1009 Hit "^1007 [0-9.]+ 10.000000 0.000000 [0-5]$"
} -start

client c2 -start

logexpect l2 -wait

barrier b2 sync

client c1 -wait
client c2 -wait
