vtest "Check expiry of non-instantiated object"

feature persistent_storage

shell "rm -f ${tmpdir}/_.per"

server s1 {
	rxreq
	txresp -hdr "Foo: foo1"
} -start

vinyl v1 \
	-arg "-sdeprecated_persistent,${tmpdir}/_.per,5m" \
	-arg "-pban_lurker_sleep=0" \
	-arg "-pshortlived=0" \
	-vcl+backend {
		sub vcl_backend_response {
			set beresp.ttl = 3s;
			set beresp.keep = 0s;
			set beresp.grace = 0s;
		}
	} -start

vinyl v1 -cliok "param.set debug +syncvsl"
vinyl v1 -cliok "param.set feature +wait_silo"

logexpect l1 -v v1 -g vxid -q "Begin ~ bereq" {
    expect * 1002 Storage         "persistent s0"
} -start

client c1 {
	txreq -url "/foo"
	rxresp
	expect resp.status == 200
	expect resp.http.X-Vinyl == "1001"
	expect resp.http.foo == "foo1"
} -run

logexpect l1 -wait
vinyl v1 -expect n_object == 1

vinyl v1 -stop

server s1 -wait {
	rxreq
	txresp -hdr "Foo: foo2"
} -start

vinyl v1 -vcl+backend {
		sub vcl_backend_response {
			set beresp.ttl = 3s;
		}
	} -start

delay 5

vinyl v1 -expect n_object == 0

logexpect l1 -v v1 -g vxid -q "Begin ~ bereq" {
    expect * 1002 Storage         "persistent s0"
} -start

client c1 {
	txreq -url "/foo"
	rxresp
	expect resp.status == 200
	expect resp.http.X-Vinyl == "1001"
	expect resp.http.foo == "foo2"
} -run

logexpect l1 -wait
vinyl v1 -expect n_object == 1
