vtest "Transient-salvaged objects ttl should be shortened - #1140"

server s1 {
	# This response should almost completely fill the storage
	rxreq
	expect req.url == /url1
	txresp -noserver -bodylen 1048400

	# The next one should not fit in the storage, ending up in transient
	# with zero ttl (=shortlived)
	rxreq
	expect req.url == /url2
	txresp -noserver -bodylen 1024

	# And therefore this one should be fetched next
	rxreq
	expect req.url == /url2
	txresp -noserver -bodylen 1025
} -start

vinyl v1 -arg "-p nuke_limit=0 -p shortlived=0" \
	-arg "-sdefault,1m" -vcl+backend {
	sub vcl_backend_response {
		set beresp.do_stream = false;
		# Unset Date header to not change the object sizes
		unset beresp.http.Date;
	}
} -start

client c1 {
	txreq -url /url1
	rxresp
	expect resp.status == 200
	expect resp.bodylen == 1048400
} -run

delay .1

vinyl v1 -expect SM?.s0.g_space < 1000

client c1 {
	txreq -url /url2
	rxresp
	expect resp.status == 200
	expect resp.bodylen == 1024
} -run

delay .1

client c1 {
	txreq -url /url2
	rxresp
	expect resp.status == 200
	expect resp.bodylen == 1025
} -run
