varnishtest "Hit-for-pass (mk II)"

server s1 {
	rxreq
	txresp -hdr "foo: 1"
	rxreq
	txresp -hdr "foo: 2"
	rxreq
	txresp -hdr "foo: 3"
} -start

varnish v1 -vcl+backend {

	sub vcl_miss {
		set req.http.miss = true;
	}
	sub vcl_pass {
		set req.http.hitpass = req.is_hitpass;
	}

	sub vcl_backend_response {
		return (pass(2s));
	}

	sub vcl_deliver {
		set resp.http.miss = req.http.miss;
		set resp.http.hitpass = req.http.hitpass;
	}

} -start

logexpect l1 -v v1 -g vxid {
	expect * 1003	HitPass "^1002 1"
} -start

client c1 {
	txreq
	rxresp
	expect resp.http.miss == true

	txreq
	rxresp
	expect resp.http.hitpass == true

	delay 3

	txreq
	rxresp
	expect resp.http.miss == true
} -run

logexpect l1 -wait

varnish v1 -expect MAIN.cache_hitpass == 1
varnish v1 -expect MAIN.cache_miss == 2
varnish v1 -expect MAIN.cache_hitmiss == 0
