vtest	"Object/LRU/Stevedores"

server s1 {
	rxreq
	txresp -bodylen 1048290

	rxreq
	txresp -bodylen 1048291

	rxreq
	txresp -bodylen 1048292

	rxreq
	txresp -bodylen 1047293

	rxreq
	txresp -bodylen 1047294
} -start

vinyl v1 \
	-arg "-ss1=default,1m" \
	-arg "-ss2=default,1m" \
	-arg "-ss0=default,1m" \
	-arg "-sTransient=default" \
	-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 /foo
	rxresp
	expect resp.status == 200
	expect resp.bodylen == 1048290
} -run

vinyl v1 -expect SM?.Transient.g_bytes == 0
vinyl v1 -expect SM?.s0.g_bytes == 0
vinyl v1 -expect SM?.s0.g_space > 1000000
vinyl v1 -expect SM?.s1.g_bytes > 1000000
vinyl v1 -expect SM?.s1.g_space < 200
vinyl v1 -expect SM?.s2.g_bytes == 0
vinyl v1 -expect SM?.s2.g_space > 1000000

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

vinyl v1 -expect SM?.Transient.g_bytes == 0
vinyl v1 -expect SM?.s0.g_bytes == 0
vinyl v1 -expect SM?.s0.g_space > 1000000
vinyl v1 -expect SM?.s1.g_bytes > 1000000
vinyl v1 -expect SM?.s1.g_space < 200
vinyl v1 -expect SM?.s2.g_bytes > 1000000
vinyl v1 -expect SM?.s2.g_space < 200

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

vinyl v1 -expect SM?.Transient.g_bytes == 0
vinyl v1 -expect SM?.s0.g_bytes > 1000000
vinyl v1 -expect SM?.s0.g_space < 200
vinyl v1 -expect SM?.s1.g_bytes > 1000000
vinyl v1 -expect SM?.s1.g_space < 200
vinyl v1 -expect SM?.s2.g_bytes > 1000000
vinyl v1 -expect SM?.s2.g_space < 200

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

vinyl v1 -expect n_lru_nuked == 1

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

vinyl v1 -expect n_lru_nuked == 2
