varnishtest "Test req.hash_ignore_busy in vcl_recv"

barrier b1 cond 2

server s1 {
	rxreq
	barrier b1 sync
	delay 1
	txresp -hdr "Server: 1"
} -start

server s2 {
	rxreq
	txresp -hdr "Server: 2"
} -start

varnish v1 -vcl+backend {
	sub vcl_recv {
		if (req.http.x-ignorebusy == "1") {
			set req.hash_ignore_busy = true;
		}
	}
	sub vcl_backend_fetch {
		if (bereq.http.x-client == "1") {
			set bereq.backend = s1;
		}
		if (bereq.http.x-client == "2") {
			set bereq.backend = s2;
		}
	}
} -start

client c1 {
	txreq -url "/" -hdr "x-client: 1"
	rxresp
	expect resp.status == 200
	expect resp.http.Server == "1"
} -start

client c2 {
	barrier b1 sync
	txreq -url "/" -hdr "x-client: 2" -hdr "x-ignorebusy: 1"
	txreq -url "/" -hdr "x-client: 2"
	rxresp
	expect resp.status == 200
	expect resp.http.Server == "2"
} -start

client c1 -wait
client c2 -wait
