vtest "Test -h critbit a bit"

server s1 {
	rxreq
	expect req.url == "/"
	txresp -hdr "ID: slash" -hdr "Connection: close" -body "012345\n"
} -start

vinyl v1 -arg "-hcritbit" -vcl+backend { } -start

client c1 {
	txreq -url "/"
	rxresp
	expect resp.status == 200
	expect resp.http.X-Vinyl == "1001"
	expect resp.http.ID == "slash"
} -run
delay .1

client c2 {
	txreq -url "/"
	rxresp
	expect resp.status == 200
	expect resp.http.X-Vinyl == "1004 1002"
	expect resp.http.ID == "slash"
} -run
delay .1

server s1 {
	rxreq
	expect req.url == "/foo"
	txresp -hdr "ID: foo" -body "012345\n"
	rxreq
	expect req.url == "/bar"
	txresp -hdr "ID: bar" -body "012345\n"
} -start

client c1 {
	txreq -url "/foo"
	rxresp
	expect resp.status == 200
	expect resp.http.X-Vinyl == "1006"
	expect resp.http.ID == "foo"
	delay .1

	txreq -url "/"
	rxresp
	expect resp.status == 200
	expect resp.http.X-Vinyl == "1008 1002"
	expect resp.http.ID == "slash"
	delay .1

	txreq -url "/bar"
	rxresp
	expect resp.status == 200
	expect resp.http.X-Vinyl == "1009"
	expect resp.http.ID == "bar"
	delay .1

	txreq -url "/foo"
	rxresp
	expect resp.status == 200
	expect resp.http.X-Vinyl == "1011 1007"
	expect resp.http.ID == "foo"
} -run

vinyl v1 -expect sess_conn == 3
vinyl v1 -expect cache_hit == 3
vinyl v1 -expect cache_miss == 3
vinyl v1 -expect client_req == 6
vinyl v1 -expect s_sess == 3
vinyl v1 -expect s_fetch == 3
