varnishtest "Check backend connection limit"

barrier b1 cond 2
barrier b2 cond 2

server s1 {
	rxreq
	barrier b1 sync
	barrier b2 sync
	txresp
} -start

varnish v1 -vcl {

	backend default {
		.host = "${s1_addr}";
		.port = "${s1_port}";
		.max_connections = 1;
	}
	sub vcl_recv {
		return(pass);
	}
} -start

client c1 {
	txreq
	rxresp
	expect resp.status == 200
} -start


client c2 {
	barrier b1 sync
	txreq
	rxresp
	expect resp.status == 503
} -run

barrier b2 sync
client c1 -wait

varnish v1 -expect backend_busy == 1
