vtest "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

vinyl 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-Vinyl == "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"
	expect resp.http.o_uncacheable == "true"

	txreq -url "/foo"
	rxresp
	expect resp.status == 200
	expect resp.bodylen == 7
	expect resp.http.X-Vinyl == "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"
	expect resp.http.o_uncacheable == "true"
}

client c1 -run

logexpect l1 -wait
