vtest "Test ban_lurker_sleep vs failed ban lurker"

# The idea here is that the ban lurker should always wait 1 second when it
# can't proceed, as per documentation and original intent. The
# ban_lurker_sleep should not affect sleep-times when the lurker fails.

server s1 {
	rxreq
	txresp -status 200

	rxreq
	txresp -status 200
} -start

vinyl v1 -vcl+backend {
	sub vcl_recv {
		if (req.method == "BAN") {
			ban("obj.http.url ~ /");
			return (synth(201,"banned"));
		}
		return (hash);
	}
	sub vcl_backend_response {
		set beresp.http.url = bereq.url;
	}
} -start

vinyl v1 -cliok "param.set ban_lurker_age 0"
vinyl v1 -expect bans_tests_tested == 0

delay 0.01
client c1 {
	txreq -req GET
	rxresp
	expect resp.status == 200

	txreq -req BAN
	rxresp
	expect resp.status == 201
} -run

#delay 0.1
#vinyl v1 -expect bans_lurker_tests_tested == 0

#delay 1.5
vinyl v1 -expect bans_lurker_tests_tested >= 1

vinyl v1 -cliok "param.set ban_lurker_sleep 5.01"

client c2 {
	txreq -req GET
	rxresp
	expect resp.status == 200

	txreq -req BAN
	rxresp
	expect resp.status == 201
} -run

#delay 0.1
#vinyl v1 -expect bans_lurker_tests_tested == 1

#delay 1.1
vinyl v1 -expect bans_lurker_tests_tested == 2
