vtest "Test Backend Polling"

barrier b1 cond 2

server s1 {
	# Probes
	loop 8 {
		rxreq
		expect req.url == "/"
		txresp -hdr "Bar: foo" -body "foobar"
		accept
	}

	loop 3 {
		rxreq
		expect req.url == "/"
		txresp -status 404 -hdr "Bar: foo" -body "foobar"
		accept
	}
	loop 2 {
		rxreq
		expect req.url == "/"
		txresp -proto "FROBOZ" -status 200 -hdr "Bar: foo" -body "foobar"
		accept
	}
	loop 2 {
		rxreq
		expect req.url == "/"
		send "HTTP/1.1 200 \r\n"
		accept
	}

	barrier b1 sync
} -start

vinyl v1 -vcl {

	backend foo {
		.host = "${s1_addr}";
		.port = "${s1_port}";
		.probe = {
			.timeout = 1 s;
			.interval = 0.1 s;
		}
	}

} -start

barrier b1 sync

vinyl v1 -cliexpect "^CLI RX|  -+H{10}-{5}H{2}-{0,5} Happy" "backend.list -p"
