vtest "Check that a pass transaction works"

server s1 {
	rxreq
	expect req.proto == HTTP/1.1
	txresp -hdr "Cache-Control: max-age=120" -hdr "Connection: close" -nodate -body "012345\n"
} -start

vinyl v1 -arg "-sTransient=default,1m" -vcl+backend {
	sub vcl_recv {
		return(pass);
	}
	sub vcl_backend_response {
		set beresp.http.x-ttl = beresp.ttl;
	}
	sub vcl_deliver {
		set resp.http.o_uncacheable = obj.uncacheable;
		set resp.http.xport = req.transport;
	}
} -start

# check that there are no TTL LogTags between the
# last header and VCL_return b deliver
logexpect l1 -v v1 -g request {
	  expect * 1002 Begin
	  expect * =	BerespHeader	{^Date:}
	  expect 0 =	VCL_call	{^BACKEND_RESPONSE}
	  expect 0 =	BerespHeader	{^x-ttl: 0.000}
	  expect 0 =	VCL_return	{^deliver}
} -start

client c1 {
	txreq -proto HTTP/1.0 -url "/"
	rxresp
	expect resp.proto == HTTP/1.1
	expect resp.status == 200
	expect resp.http.connection == close
	expect resp.http.x-ttl == 0.000
	expect resp.http.o_uncacheable == true
	expect resp.http.xport == HTTP/1
} -run

vinyl v1 -expect n_object == 0
vinyl v1 -expect SM?.Transient.g_alloc == 0
vinyl v1 -expect sess_conn == 1
vinyl v1 -expect client_req == 1
vinyl v1 -expect s_sess == 1
vinyl v1 -expect s_pass == 1

logexpect l1 -wait
