Commit dad12301 authored by Geoff Simmons's avatar Geoff Simmons

add tests for max_mem with the set object interface, and emit a better

diagnostic when .compile() fails
parent 88339bce
......@@ -2,6 +2,8 @@
varnishtest "max_mem option"
# regex object
varnish v1 -vcl {
import re2 from "${vmod_topbuild}/src/.libs/libvmod_re2.so";
backend b { .host = "${bad_ip}"; }
......@@ -67,3 +69,44 @@ logexpect l1 -v v1 -d 1 -g vxid -q "VCL_Error" {
expect * = VCL_Error "^vmod re2 error: re2.match.pattern=...1000.x., text=.c+"
expect * = End
} -run
# set object
varnish v1 -vcl {
import re2 from "${vmod_topbuild}/src/.libs/libvmod_re2.so";
backend b { .host = "${bad_ip}"; }
sub vcl_init {
new rep = re2.set();
rep.add(".{1000}x");
rep.compile();
}
sub vcl_recv {
return(synth(200));
}
sub vcl_synth {
if (rep.match("ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccx")) {
set resp.http.rep = "match";
}
}
}
client c1 {
txreq
rxresp
expect resp.http.rep == "match"
} -run
varnish v1 -errvcl {vmod re2 error: rep.compile(): failed, possibly insufficient memory} {
import re2 from "${vmod_topbuild}/src/.libs/libvmod_re2.so";
backend b { .host = "${bad_ip}"; }
sub vcl_init {
new rep = re2.set(max_mem=1024);
rep.add(".{1000}x");
rep.compile();
}
}
......@@ -489,7 +489,8 @@ vmod_set_compile(VRT_CTX, struct vmod_re2_set *set)
return;
}
if ((err = vre2set_compile(set->set)) != NULL) {
VERR(ctx, ERR_PREFIX "%s", set->vcl_name, err);
VERR(ctx, ERR_PREFIX "failed, possibly insufficient memory",
set->vcl_name);
return;
}
set->compiled = 1;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment