Commit 45641f77 authored by Nils Goroll's avatar Nils Goroll

specific tests

parent 437134b5
Pipeline #307 skipped
varnishtest "weightadjust basic"
server s1 {
rxreq
expect req.url == "/"
expect req.http.Connection == "close"
txresp -hdr "X-Weight: 11.345whatever"
accept
rxreq
expect req.url == "/"
expect req.http.Host == "Host"
expect req.http.Connection == "close"
txresp -hdr "X-Weight: 12.345whatever"
} -start
server s2 {
rxreq
expect req.url == "/otherurl"
expect req.http.Connection == "close"
txresp -body "127ewsdfinthebodyljgof5te3.789sdh723"
} -start
server s3 {
rxreq
expect req.url == "/weight"
expect req.http.Host == "weighthost"
expect req.http.Connection == "close"
txresp -hdr "X-Weight: 42something"
} -start
varnish v1 -arg "-p vcc_allow_inline_c=true" -vcl+backend {
import ${vmod_weightadjust};
C{#include <unistd.h>}C
backend s1_hosthdr {
.host = "${s1_addr}";
.port = "${s1_port}";
.host_header = "Host";
}
sub vcl_init {
new foo = weightadjust.random();
foo.add_backend(backend=s1, weight=1,
weight_update = "^X-Weight: ([\d.]+)",
interval = 1h);
}
sub vcl_recv {
if (req.url == "/1") {
C{sleep(1);}C
foo.add_backend(backend=s1_hosthdr, weight=1,
weight_update = "^X-Weight: (\d+\.\d+)",
interval = 1h);
C{sleep(1);}C
foo.remove_backend(backend=s1);
return (synth(200));
}
if (req.url == "/2") {
foo.add_backend(backend=s2, weight=1,
url = "/otherurl",
weight_update = "inthebody.*(\d+\.\d+)",
interval = 1h);
C{sleep(1);}C
return (synth(200));
}
if (req.url == "/3") {
foo.add_backend(backend=s3, weight=1,
request={"
GET /weight HTTP/1.1
Host: weighthost
"},
weight_update = "^X-Weight: ([\d.]+)",
interval = 1h);
C{sleep(1);}C
return (synth(200));
}
return (synth(400));
}
} -start
logexpect l1 -v v1 -g raw -d 1 {
expect * * Debug {^vmod weightadjust: poke foo.vcl1.s1 starting}
expect * * Debug {^vmod weightadjust: poke foo.vcl1.s1 set to 11.345000 total 11.345000}
expect * * Debug {^vmod weightadjust: poke foo.vcl1.s1_hosthdr starting}
expect * * Debug {^vmod weightadjust: poke foo.vcl1.s1_hosthdr set to 12.345000 total 23.690000}
expect * * Debug {^vmod weightadjust: poke foo.vcl1.s1 stopping}
expect * * Debug {^vmod weightadjust: poke foo.vcl1.s2 starting}
expect * * Debug {^vmod weightadjust: poke foo.vcl1.s2 set to 3.789000 total 16.134000}
expect * * Debug {^vmod weightadjust: poke foo.vcl1.s3 starting}
expect * * Debug {^vmod weightadjust: poke foo.vcl1.s3 set to 42.000000 total 58.134000}
} -start
client c1 {
txreq -url "/1"
rxresp
txreq -url "/2"
rxresp
txreq -url "/3"
rxresp
} -run
logexpect l1 -wait
varnishtest "weightadjust duplicate add"
server s1 {
rxreq
txresp
} -start
varnish v1 -vcl+backend {} -start
client c1 {
txreq
rxresp
} -run
varnish v1 -errvcl {already exists} {
import ${vmod_weightadjust};
backend s1 { .host = "${bad_ip}"; }
sub vcl_init {
new foo = weightadjust.random();
foo.add_backend(s1, 1, weight_update="dontcare(\d+)");
foo.add_backend(s1, 1, weight_update="dontcare(\d+)");
}
}
varnish v1 -cliok vcl.list
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