varnishtest "Test grace object not replaced by ttl = 0s"

server s1 {
	rxreq
	txresp -bodylen 3
	rxreq
	txresp -bodylen 6
	# bgfetch fails
} -start

varnish v1 -vcl+backend {
	sub vcl_recv {
		if (req.http.X-Force-Miss) {
			set req.hash_always_miss = true;
		}
	}
	sub vcl_backend_response {
		if (beresp.status != 200 || bereq.http.X-Force-Miss) {
			set beresp.ttl = 0s;
		} else {
			set beresp.ttl = 0.001s;
		}
		set beresp.grace = 10s;
		return (deliver);
	}
} -start


client c1 {
	txreq
	rxresp
	expect resp.status == 200
	expect resp.bodylen == 3

	txreq -hdr "X-Force-Miss: 1"
	rxresp
	expect resp.status == 200
	expect resp.bodylen == 6

	txreq
	rxresp
	expect resp.status == 200
	expect resp.bodylen == 3
} -run
