varnishtest "Test hit for miss (beresp.uncacheable = true)"

server s1 {
	rxreq
	expect req.url == "/foo"
	txresp -body foobar
	rxreq
	expect req.url == "/foo"
	txresp -body foobar1
} -start

varnish v1 -vcl+backend {
	sub vcl_backend_response {
		set beresp.uncacheable = true;
	}
	sub vcl_deliver {
		set resp.http.o_uncacheable = obj.uncacheable;
		set resp.http.o_age = obj.age;
		set resp.http.o_ttl = obj.ttl;
		set resp.http.o_grace = obj.grace;
		set resp.http.o_keep = obj.keep;
	}
} -start

logexpect l1 -v v1 -g vxid {
	expect * 1003	HitMiss "^1002 119"
} -start

client c1 {
	txreq -url "/foo"
	rxresp
	expect resp.status == 200
	expect resp.bodylen == 6
	expect resp.http.x-varnish == "1001"
	expect resp.http.o_age >= 0
	expect resp.http.o_age < 0.5
	expect resp.http.o_ttl > 119.5
	expect resp.http.o_ttl <= 120
	expect resp.http.o_grace == "10.000"
	expect resp.http.o_keep == "0.000"

	txreq -url "/foo"
	rxresp
	expect resp.status == 200
	expect resp.bodylen == 7
	expect resp.http.x-varnish == "1003"
	expect resp.http.o_age >= 0
	expect resp.http.o_age < 0.5
	expect resp.http.o_ttl > 119.5
	expect resp.http.o_ttl <= 120
	expect resp.http.o_grace == "10.000"
	expect resp.http.o_keep == "0.000"
}

client c1 -run

logexpect l1 -wait
