Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
K
k8s-vcl-reloader
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
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
uplex-varnish
k8s-vcl-reloader
Commits
70fcab50
Commit
70fcab50
authored
Dec 29, 2020
by
Geoff Simmons
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Test template generation when Services have no Endpoints.
parent
af3f7d8d
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
148 additions
and
0 deletions
+148
-0
backends.tmpl
pkg/varnish/vcl/testdata/backends.tmpl
+6
-0
backends_nobar.golden
pkg/varnish/vcl/testdata/backends_nobar.golden
+66
-0
backends_nosvc.golden
pkg/varnish/vcl/testdata/backends_nosvc.golden
+51
-0
vcl_test.go
pkg/varnish/vcl/vcl_test.go
+25
-0
No files found.
pkg/varnish/vcl/testdata/backends.tmpl
View file @
70fcab50
...
...
@@ -30,6 +30,7 @@ sub vcl_init {
# BAR & BAZ BACKENDS ######################
{{if or (index .Services "bar-service").Endpoints (index .Services "baz-service").Endpoints -}}
probe barbaz_probe {
.url = "/probe.html";
.interval = 5s;
...
...
@@ -37,6 +38,7 @@ probe barbaz_probe {
.window = 10;
.threshold = 1;
}
{{- end}}
{{range $name, $ep := (index .Services "bar-service").Endpoints -}}
backend {{$name}} {
...
...
@@ -57,11 +59,13 @@ backend {{$name}} {
sub vcl_init {
# shard/rr init
new shard_bar_backends = directors.shard();
{{- if (index .Services "bar-service").Endpoints}}
shard_bar_backends.set_rampup(60s);
{{- range $name, $ep := (index .Services "bar-service").Endpoints}}
shard_bar_backends.add_backend({{$name}});
{{- end}}
shard_bar_backends.reconfigure();
{{- end}}
new rr_bar_backends = directors.round_robin();
{{- range $name, $ep := (index .Services "bar-service").Endpoints}}
...
...
@@ -69,11 +73,13 @@ sub vcl_init {
{{- end}}
new shard_baz_backends = directors.shard();
{{- if (index .Services "baz-service").Endpoints}}
shard_baz_backends.set_rampup(60s);
{{- range $name, $ep := (index .Services "baz-service").Endpoints}}
shard_baz_backends.add_backend({{$name}});
{{- end}}
shard_baz_backends.reconfigure();
{{- end}}
new rr_baz_backends = directors.round_robin();
{{- range $name, $ep := (index .Services "baz-service").Endpoints}}
...
...
pkg/varnish/vcl/testdata/backends_nobar.golden
0 → 100644
View file @
70fcab50
# FOO SERVERS #############################
probe foo_probe {
.request = "HEAD /foo_health HTTP/1.1"
"Host: foo"
"Connection: close";
.interval = 3s;
.timeout = 0.3s;
.window = 5;
.threshold = 1;
}
backend foo-stateful-0 {
.host = "172.22.225.25";
.port = "6081";
.probe = foo_probe;
}
backend foo-stateful-1 {
.host = "172.22.225.39";
.port = "6081";
.probe = foo_probe;
}
sub vcl_init {
# foo sharding init
new foo = directors.shard();
foo.set_rampup(0s);
foo.add_backend(foo-stateful-0);
foo.add_backend(foo-stateful-1);
foo.reconfigure();
}
# BAR & BAZ BACKENDS ######################
probe barbaz_probe {
.url = "/probe.html";
.interval = 5s;
.timeout = 3s;
.window = 10;
.threshold = 1;
}
backend baz-5ff49fcd4-hx7lj {
.host = "172.22.225.8";
.port = "8080";
.probe = barbaz_probe;
}
sub vcl_init {
# shard/rr init
new shard_bar_backends = directors.shard();
new rr_bar_backends = directors.round_robin();
new shard_baz_backends = directors.shard();
shard_baz_backends.set_rampup(60s);
shard_baz_backends.add_backend(baz-5ff49fcd4-hx7lj);
shard_baz_backends.reconfigure();
new rr_baz_backends = directors.round_robin();
rr_baz_backends.add_backend(baz-5ff49fcd4-hx7lj);
}
pkg/varnish/vcl/testdata/backends_nosvc.golden
0 → 100644
View file @
70fcab50
# FOO SERVERS #############################
probe foo_probe {
.request = "HEAD /foo_health HTTP/1.1"
"Host: foo"
"Connection: close";
.interval = 3s;
.timeout = 0.3s;
.window = 5;
.threshold = 1;
}
backend foo-stateful-0 {
.host = "172.22.225.25";
.port = "6081";
.probe = foo_probe;
}
backend foo-stateful-1 {
.host = "172.22.225.39";
.port = "6081";
.probe = foo_probe;
}
sub vcl_init {
# foo sharding init
new foo = directors.shard();
foo.set_rampup(0s);
foo.add_backend(foo-stateful-0);
foo.add_backend(foo-stateful-1);
foo.reconfigure();
}
# BAR & BAZ BACKENDS ######################
sub vcl_init {
# shard/rr init
new shard_bar_backends = directors.shard();
new rr_bar_backends = directors.round_robin();
new shard_baz_backends = directors.shard();
new rr_baz_backends = directors.round_robin();
}
pkg/varnish/vcl/vcl_test.go
View file @
70fcab50
...
...
@@ -196,6 +196,31 @@ func TestTemplate(t *testing.T) {
t
.
Errorf
(
"Generated VCL at %s does not match gold file %s"
,
vclPath
,
filepath
.
Join
(
"testdata"
,
gold
))
}
gold
=
"backends_nobar.golden"
noEpsSpec
:=
testSpec
svc
,
_
:=
noEpsSpec
.
Services
[
"bar-service"
]
svc
.
Endpoints
=
map
[
string
]
Endpoint
{}
noEpsSpec
.
Services
[
"bar-service"
]
=
svc
if
err
=
noEpsSpec
.
WriteTemplate
(
tmpl
,
vclPath
);
err
!=
nil
{
t
.
Fatal
(
"WriteTemplate():"
,
err
)
}
if
!
cmpGold
(
t
,
vclPath
,
gold
)
{
t
.
Errorf
(
"Generated VCL at %s does not match gold file %s"
,
vclPath
,
filepath
.
Join
(
"testdata"
,
gold
))
}
gold
=
"backends_nosvc.golden"
svc
,
_
=
noEpsSpec
.
Services
[
"baz-service"
]
svc
.
Endpoints
=
map
[
string
]
Endpoint
{}
noEpsSpec
.
Services
[
"baz-service"
]
=
svc
if
err
=
noEpsSpec
.
WriteTemplate
(
tmpl
,
vclPath
);
err
!=
nil
{
t
.
Fatal
(
"WriteTemplate():"
,
err
)
}
if
!
cmpGold
(
t
,
vclPath
,
gold
)
{
t
.
Errorf
(
"Generated VCL at %s does not match gold file %s"
,
vclPath
,
filepath
.
Join
(
"testdata"
,
gold
))
}
}
func
TestFQVersion
(
t
*
testing
.
T
)
{
...
...
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