aboutsummaryrefslogtreecommitdiff
path: root/core/setup/kubernetes_test.go
diff options
context:
space:
mode:
authorGravatar Michael Richmond <mrichmon@users.noreply.github.com> 2016-08-08 14:30:04 -0700
committerGravatar GitHub <noreply@github.com> 2016-08-08 14:30:04 -0700
commitc079de65b520bd7690c7ac057a38b404947f3909 (patch)
treef2c19117a64ca0e40ab187ae068d5819814492f5 /core/setup/kubernetes_test.go
parent51eaefc0377597691fec1829680b3c9612068d88 (diff)
downloadcoredns-c079de65b520bd7690c7ac057a38b404947f3909.tar.gz
coredns-c079de65b520bd7690c7ac057a38b404947f3909.tar.zst
coredns-c079de65b520bd7690c7ac057a38b404947f3909.zip
Adding `resyncperiod` to Corefile (#205)
* Removing old unused inline k8s API code and tests. * Adding parsing implementation for `resyncperiod` keyword from Corefile. * Adding tests for parsing `resyncperiod` keyword from Corefile. 8 Updating README.md and conf/k8sCorefile.
Diffstat (limited to 'core/setup/kubernetes_test.go')
-rw-r--r--core/setup/kubernetes_test.go99
1 files changed, 90 insertions, 9 deletions
diff --git a/core/setup/kubernetes_test.go b/core/setup/kubernetes_test.go
index af7f216d9..4674896b8 100644
--- a/core/setup/kubernetes_test.go
+++ b/core/setup/kubernetes_test.go
@@ -3,17 +3,19 @@ package setup
import (
"strings"
"testing"
+ "time"
)
func TestKubernetesParse(t *testing.T) {
tests := []struct {
- description string
- input string
- shouldErr bool
- expectedErrContent string // substring from the expected error. Empty for positive cases.
- expectedZoneCount int // expected count of defined zones.
- expectedNTValid bool // NameTemplate to be initialized and valid
- expectedNSCount int // expected count of namespaces.
+ description string // Human-facing description of test case
+ input string // Corefile data as string
+ shouldErr bool // true if test case is exected to produce an error.
+ expectedErrContent string // substring from the expected error. Empty for positive cases.
+ expectedZoneCount int // expected count of defined zones.
+ expectedNTValid bool // NameTemplate to be initialized and valid
+ expectedNSCount int // expected count of namespaces.
+ expectedResyncPeriod time.Duration // expected resync period value
}{
// positive
{
@@ -24,6 +26,7 @@ func TestKubernetesParse(t *testing.T) {
1,
true,
0,
+ defaultResyncPeriod,
},
{
"kubernetes keyword with multiple zones",
@@ -33,6 +36,7 @@ func TestKubernetesParse(t *testing.T) {
2,
true,
0,
+ defaultResyncPeriod,
},
{
"kubernetes keyword with zone and empty braces",
@@ -43,6 +47,7 @@ func TestKubernetesParse(t *testing.T) {
1,
true,
0,
+ defaultResyncPeriod,
},
{
"endpoint keyword with url",
@@ -54,6 +59,7 @@ func TestKubernetesParse(t *testing.T) {
1,
true,
0,
+ defaultResyncPeriod,
},
{
"template keyword with valid template",
@@ -65,6 +71,7 @@ func TestKubernetesParse(t *testing.T) {
1,
true,
0,
+ defaultResyncPeriod,
},
{
"namespaces keyword with one namespace",
@@ -76,6 +83,7 @@ func TestKubernetesParse(t *testing.T) {
1,
true,
1,
+ defaultResyncPeriod,
},
{
"namespaces keyword with multiple namespaces",
@@ -87,10 +95,36 @@ func TestKubernetesParse(t *testing.T) {
1,
true,
2,
+ defaultResyncPeriod,
+ },
+ {
+ "resync period in seconds",
+ `kubernetes coredns.local {
+ resyncperiod 30s
+}`,
+ false,
+ "",
+ 1,
+ true,
+ 0,
+ 30 * time.Second,
+ },
+ {
+ "resync period in minutes",
+ `kubernetes coredns.local {
+ resyncperiod 15m
+}`,
+ false,
+ "",
+ 1,
+ true,
+ 0,
+ 15 * time.Minute,
},
{
"fully specified valid config",
`kubernetes coredns.local test.local {
+ resyncperiod 15m
endpoint http://localhost:8080
template {service}.{namespace}.{zone}
namespaces demo test
@@ -100,6 +134,7 @@ func TestKubernetesParse(t *testing.T) {
2,
true,
2,
+ 15 * time.Minute,
},
// negative
{
@@ -110,6 +145,7 @@ func TestKubernetesParse(t *testing.T) {
-1,
false,
-1,
+ defaultResyncPeriod,
},
{
"kubernetes keyword without a zone",
@@ -119,6 +155,7 @@ func TestKubernetesParse(t *testing.T) {
-1,
true,
0,
+ defaultResyncPeriod,
},
{
"endpoint keyword without an endpoint value",
@@ -130,6 +167,7 @@ func TestKubernetesParse(t *testing.T) {
-1,
true,
-1,
+ defaultResyncPeriod,
},
{
"template keyword without a template value",
@@ -141,6 +179,7 @@ func TestKubernetesParse(t *testing.T) {
-1,
false,
0,
+ defaultResyncPeriod,
},
{
"template keyword with an invalid template value",
@@ -152,6 +191,7 @@ func TestKubernetesParse(t *testing.T) {
-1,
false,
0,
+ defaultResyncPeriod,
},
{
"namespace keyword without a namespace value",
@@ -163,6 +203,43 @@ func TestKubernetesParse(t *testing.T) {
-1,
true,
-1,
+ defaultResyncPeriod,
+ },
+ {
+ "resyncperiod keyword without a duration value",
+ `kubernetes coredns.local {
+ resyncperiod
+}`,
+ true,
+ "Wrong argument count or unexpected line ending after 'resyncperiod'",
+ -1,
+ true,
+ 0,
+ 0 * time.Minute,
+ },
+ {
+ "resync period no units",
+ `kubernetes coredns.local {
+ resyncperiod 15
+}`,
+ true,
+ "Unable to parse resync duration value. Value provided was ",
+ -1,
+ true,
+ 0,
+ 0 * time.Second,
+ },
+ {
+ "resync period invalid",
+ `kubernetes coredns.local {
+ resyncperiod abc
+}`,
+ true,
+ "Unable to parse resync duration value. Value provided was ",
+ -1,
+ true,
+ 0,
+ 0 * time.Second,
},
}
@@ -218,8 +295,12 @@ func TestKubernetesParse(t *testing.T) {
foundNSCount := len(k8sController.Namespaces)
if foundNSCount != test.expectedNSCount {
t.Errorf("Test %d: Expected kubernetes controller to be initialized with %d namespaces. Instead found %d namespaces: '%v' for input '%s'", i, test.expectedNSCount, foundNSCount, k8sController.Namespaces, test.input)
- t.Logf("k8sController is: %v", k8sController)
- t.Logf("k8sController.Namespaces is: %v", k8sController.Namespaces)
+ }
+
+ // ResyncPeriod
+ foundResyncPeriod := k8sController.ResyncPeriod
+ if foundResyncPeriod != test.expectedResyncPeriod {
+ t.Errorf("Test %d: Expected kubernetes controller to be initialized with resync period '%s'. Instead found period '%s' for input '%s'", test.expectedResyncPeriod, foundResyncPeriod, test.input)
}
}
}
='2023-10-17 16:46:31 -0700'>2023-10-17Update ZigGeneratedClasses.cppGravatar Dylan Conway 1-2/+0 2023-10-17use npm alias in dependencies (#6545)Gravatar Dylan Conway 7-29/+271 2023-10-17fix(node:http): fix `server.address()` (#6442)Gravatar Ai Hoshino 12-12/+453 2023-10-17docs: fix ws.publish (#6558)Gravatar Aral Roca Gomez 1-1/+1 2023-10-17perf(bun-types): remove needless some call (#6550)Gravatar Mikhail 1-1/+1 2023-10-16fix(runtime): make some things more stable (partial jsc debug build) (#5881)Gravatar dave caruso 116-1446/+1830 2023-10-16fix(runtime): improve IPC reliability + organization pass on that code (#6475)Gravatar dave caruso 15-98/+266 2023-10-16Simplify getting Set of extentions (#4975)Gravatar Mikhail 1-3/+3 2023-10-16Fix formattingGravatar Ashcon Partovi 1-3/+1 2023-10-16fix(test): when tests run with --only the nested describe blocks `.on… (#5616)Gravatar Igor Shapiro 2-13/+45 2023-10-16perf(node:events): optimize `emit(...)` function (#5485)Gravatar Yannik Schröder 3-11/+132 2023-10-16fix: don't remove content-encoding header from header table (#5743)Gravatar Liz 2-2/+25 2023-10-16fix(sqlite) Insert .all() does not return an array #5872 (#5946)Gravatar Hugo Galan 2-7/+11 2023-10-16Fix formattingGravatar Ashcon Partovi 2-5/+4 2023-10-16Fix `Response.statusText` (#6151)Gravatar Chris Toshok 10-238/+269 2023-10-16fix-subprocess-argument-missing (#6407)Gravatar Nicolae-Rares Ailincai 4-2/+40 2023-10-16Add type parameter to `expect` (#6128)Gravatar Voldemat 1-3/+3 2023-10-16fix(node:worker_threads): ensure threadId property is exposed on worker_threa...Gravatar Jérôme Benoit 6-15/+75 2023-10-16Fix use before define bug in sqliteGravatar Ashcon Partovi 2-5/+5 2023-10-16fix(jest): fix toStrictEqual on same URLs (#6528)Gravatar João Alisson 2-13/+16 2023-10-16Fix `toHaveBeenCalled` having wrong error signatureGravatar Ashcon Partovi 1-2/+2 2023-10-16Fix formattingGravatar Ashcon Partovi 1-2/+1 2023-10-16Add `reusePort` to `Bun.serve` typesGravatar Ashcon Partovi 1-0/+9 2023-10-16Fix `request.url` having incorrect portGravatar Ashcon Partovi 4-1/+92 2023-10-16Remove uWebSockets header from Bun.serve responsesGravatar Ashcon Partovi 1-6/+6 2023-10-16Rename some testsGravatar Ashcon Partovi 3-0/+0 2023-10-16Fix #6467Gravatar Ashcon Partovi 2-3/+10 2023-10-16Update InternalModuleRegistryConstants.hGravatar Dylan Conway 1-3/+3 2023-10-16Development -> Contributing (#6538)Gravatar Colin McDonnell 2-1/+1 2023-10-14fix(net/tls) fix pg hang on end + hanging on query (#6487)Gravatar Ciro Spaciari 3-8/+36 2023-10-13fix installing dependencies that match workspace versions (#6494)Gravatar Dylan Conway 4-2/+64 2023-10-13fix lockfile struct padding (#6495)Gravatar Dylan Conway 3-3/+18