varnishtest "ESI memory should only be fully allocated"

# In this test case, the cache is almost filled. Then we force the
# allocation of ESI memory that does not fit in the cache, is bigger
# than fetch_chunksize, but where half the amount can be allocated by
# the stevedore.

server s1 {
	rxreq
	expect req.url == /big
	txresp -bodylen 1037480
	rxreq
	txresp -nolen -hdr "Content-Length: 6545" -body "<html>"
	loop 92 {
		send {<esi:include }
		send {src="/long1234567890123456789012345678901234567890.txt"}
		send { />}
	}
	send "</html>"
	rxreq
	expect req.url == /long1234567890123456789012345678901234567890.txt
	txresp -body {fo}
} -start

varnish v1 -arg "-pfetch_chunksize=4k" \
	-arg "-p feature=+esi_disable_xml_check" \
	-arg "-sdefault,1m" -vcl+backend {
	sub vcl_backend_response {
		set beresp.do_esi = true;
	}
} -start

client c1 {
	txreq -url /big
	rxresp
	expect resp.bodylen == 1037480
	txreq -url /
	rxresp
} -run
