Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
libvmod-weightadjust
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
uplex-varnish
libvmod-weightadjust
Commits
45641f77
Commit
45641f77
authored
Oct 04, 2017
by
Nils Goroll
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
specific tests
parent
437134b5
Pipeline
#307
skipped
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
130 additions
and
0 deletions
+130
-0
wadj_basic.vtc
src/tests/wadj_basic.vtc
+103
-0
wadj_duplic.vtc
src/tests/wadj_duplic.vtc
+27
-0
No files found.
src/tests/wadj_basic.vtc
0 → 100644
View file @
45641f77
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
src/tests/wadj_duplic.vtc
0 → 100644
View file @
45641f77
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
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment