varnishtest	"Object/LRU/Stevedores with storage set and body alloc failures"

server s1 {
	rxreq
	txresp -hdr "Connection: close" -bodylen 1000000
} -start

varnish v1 \
	-arg "-sdefault,1m" \
	-arg "-sdefault,1m" \
	-arg "-sdefault,1m" \
	-arg "-sTransient=default" \
	-syntax 4.0 \
	-vcl+backend {
	sub vcl_backend_response {
		set beresp.storage = storage.s0;
	}
} -start


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

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

server s1 -wait {
	rxreq
	non_fatal
	txresp -hdr "Connection: close" -bodylen 1000001
} -start

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

varnish v1 -expect n_lru_nuked == 1
varnish v1 -expect SM?.Transient.g_bytes == 0
varnish v1 -expect SM?.s0.g_bytes > 1000000
varnish v1 -expect SM?.s0.g_space < 100000
varnish v1 -expect SM?.s1.g_bytes == 0
varnish v1 -expect SM?.s1.g_space > 1000000
varnish v1 -expect SM?.s2.g_bytes == 0
varnish v1 -expect SM?.s2.g_space > 1000000

server s1 -wait {
	rxreq
	# non_fatal
	txresp -hdr "Connection: close" -bodylen 1000002
} -start

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

varnish v1 -expect n_lru_nuked == 2
varnish v1 -expect SM?.Transient.g_bytes == 0
varnish v1 -expect SM?.s0.g_bytes > 1000000
varnish v1 -expect SM?.s0.g_space < 100000
varnish v1 -expect SM?.s1.g_bytes == 0
varnish v1 -expect SM?.s1.g_space > 1000000
varnish v1 -expect SM?.s2.g_bytes == 0
varnish v1 -expect SM?.s2.g_space > 1000000
