tests: improve timeout.

- upgrade k3s to v0.8.0
This commit is contained in:
Fernandez Ludovic 2019-08-11 12:22:14 +02:00 committed by Traefiker Bot
parent 5d01452648
commit 0f32de4aa2
9 changed files with 54 additions and 33 deletions

View file

@ -18,7 +18,7 @@ In the following, the Kubernetes resources defined in YAML configuration files c
!!! important "Kubectl Version" !!! important "Kubectl Version"
With the `rancher/k3s` version used in this guide (`0.5.0`), the kubectl version needs to be >= `0.11`. With the `rancher/k3s` version used in this guide (`0.8.0`), the kubectl version needs to be >= `0.11`.
## k3s Docker-compose Configuration ## k3s Docker-compose Configuration

View file

@ -1,5 +1,5 @@
server: server:
image: rancher/k3s:v0.5.0 image: rancher/k3s:v0.8.0
command: server --disable-agent --no-deploy traefik command: server --disable-agent --no-deploy traefik
environment: environment:
- K3S_CLUSTER_SECRET=somethingtotallyrandom - K3S_CLUSTER_SECRET=somethingtotallyrandom
@ -17,7 +17,7 @@ server:
- 6443:6443 - 6443:6443
node: node:
image: rancher/k3s:v0.5.0 image: rancher/k3s:v0.8.0
privileged: true privileged: true
links: links:
- server - server

View file

@ -1,7 +1,7 @@
apiVersion: traefik.containo.us/v1alpha1 apiVersion: traefik.containo.us/v1alpha1
kind: IngressRouteTCP kind: IngressRouteTCP
metadata: metadata:
name: test3.crd name: test3.route
namespace: default namespace: default
spec: spec:

View file

@ -119,17 +119,32 @@ func (s *BaseSuite) traefikCmd(args ...string) (*exec.Cmd, func(*check.C)) {
cmd, out := s.cmdTraefik(args...) cmd, out := s.cmdTraefik(args...)
return cmd, func(c *check.C) { return cmd, func(c *check.C) {
if c.Failed() || *showLog { if c.Failed() || *showLog {
s.displayLogK3S(c)
s.displayTraefikLog(c, out) s.displayTraefikLog(c, out)
} }
} }
} }
func (s *BaseSuite) displayLogK3S(c *check.C) {
filePath := "./fixtures/k8s/config.skip/k3s.log"
if _, err := os.Stat(filePath); err == nil {
content, errR := ioutil.ReadFile(filePath)
if errR != nil {
log.WithoutContext().Error(errR)
}
log.WithoutContext().Println(string(content))
}
log.WithoutContext().Println()
log.WithoutContext().Println("################################")
log.WithoutContext().Println()
}
func (s *BaseSuite) displayTraefikLog(c *check.C, output *bytes.Buffer) { func (s *BaseSuite) displayTraefikLog(c *check.C, output *bytes.Buffer) {
if output == nil || output.Len() == 0 { if output == nil || output.Len() == 0 {
log.Infof("%s: No Traefik logs.", c.TestName()) log.WithoutContext().Infof("%s: No Traefik logs.", c.TestName())
} else { } else {
log.Infof("%s: Traefik logs: ", c.TestName()) log.WithoutContext().Infof("%s: Traefik logs: ", c.TestName())
log.Infof(output.String()) log.WithoutContext().Infof(output.String())
} }
} }

View file

@ -16,6 +16,7 @@ import (
"github.com/containous/traefik/v2/integration/try" "github.com/containous/traefik/v2/integration/try"
"github.com/containous/traefik/v2/pkg/api" "github.com/containous/traefik/v2/pkg/api"
"github.com/containous/traefik/v2/pkg/log"
"github.com/go-check/check" "github.com/go-check/check"
"github.com/pmezard/go-difflib/difflib" "github.com/pmezard/go-difflib/difflib"
checker "github.com/vdemeester/shakers" checker "github.com/vdemeester/shakers"
@ -30,7 +31,7 @@ func (s *K8sSuite) SetUpSuite(c *check.C) {
s.createComposeProject(c, "k8s") s.createComposeProject(c, "k8s")
s.composeProject.Start(c) s.composeProject.Start(c)
abs, err := filepath.Abs("./fixtures/k8s/kubeconfig.yaml") abs, err := filepath.Abs("./fixtures/k8s/config.skip/kubeconfig.yaml")
c.Assert(err, checker.IsNil) c.Assert(err, checker.IsNil)
err = try.Do(60*time.Second, try.DoCondition(func() error { err = try.Do(60*time.Second, try.DoCondition(func() error {
@ -46,17 +47,19 @@ func (s *K8sSuite) SetUpSuite(c *check.C) {
func (s *K8sSuite) TearDownSuite(c *check.C) { func (s *K8sSuite) TearDownSuite(c *check.C) {
s.composeProject.Stop(c) s.composeProject.Stop(c)
err := os.Remove("./fixtures/k8s/kubeconfig.yaml") generatedFiles := []string{
if err != nil { "./fixtures/k8s/config.skip/kubeconfig.yaml",
c.Log(err) "./fixtures/k8s/config.skip/k3s.log",
"./fixtures/k8s/coredns.yaml",
"./fixtures/k8s/rolebindings.yaml",
"./fixtures/k8s/traefik.yaml",
} }
err = os.Remove("./fixtures/k8s/coredns.yaml")
for _, filename := range generatedFiles {
err := os.Remove(filename)
if err != nil { if err != nil {
c.Log(err) log.WithoutContext().Warning(err)
} }
err = os.Remove("./fixtures/k8s/traefik.yaml")
if err != nil {
c.Log(err)
} }
} }
@ -83,6 +86,9 @@ func (s *K8sSuite) TestCRDConfiguration(c *check.C) {
} }
func testConfiguration(c *check.C, path string) { func testConfiguration(c *check.C, path string) {
err := try.GetRequest("http://127.0.0.1:8080/api/entrypoints", 20*time.Second, try.BodyContains(`"name":"web"`))
c.Assert(err, checker.IsNil)
expectedJSON := filepath.FromSlash(path) expectedJSON := filepath.FromSlash(path)
if *updateExpected { if *updateExpected {
@ -93,7 +99,7 @@ func testConfiguration(c *check.C, path string) {
} }
var buf bytes.Buffer var buf bytes.Buffer
err := try.GetRequest("http://127.0.0.1:8080/api/rawdata", 20*time.Second, try.StatusCodeIs(http.StatusOK), matchesConfig(expectedJSON, &buf)) err = try.GetRequest("http://127.0.0.1:8080/api/rawdata", 40*time.Second, try.StatusCodeIs(http.StatusOK), matchesConfig(expectedJSON, &buf))
if !*updateExpected { if !*updateExpected {
if err != nil { if err != nil {

View file

@ -1,18 +1,18 @@
server: server:
image: rancher/k3s:v0.5.0 image: rancher/k3s:v0.8.0
command: server --disable-agent --no-deploy traefik command: server --disable-agent --no-deploy traefik --log /output/k3s.log
environment: environment:
- K3S_CLUSTER_SECRET=somethingtotallyrandom - K3S_CLUSTER_SECRET=somethingtotallyrandom
- K3S_KUBECONFIG_OUTPUT=/output/kubeconfig.yaml - K3S_KUBECONFIG_OUTPUT=/output/kubeconfig.yaml
- K3S_KUBECONFIG_MODE=666 - K3S_KUBECONFIG_MODE=666
volumes: volumes:
- ../../fixtures/k8s:/output - ../../fixtures/k8s/config.skip:/output
- ../../fixtures/k8s:/var/lib/rancher/k3s/server/manifests - ../../fixtures/k8s:/var/lib/rancher/k3s/server/manifests
ports: ports:
- 6443:6443 - 6443:6443
node: node:
image: rancher/k3s:v0.5.0 image: rancher/k3s:v0.8.0
privileged: true privileged: true
links: links:
- server - server

View file

@ -31,7 +31,7 @@ func (s *TCPSuite) TestMixed(c *check.C) {
c.Assert(err, checker.IsNil) c.Assert(err, checker.IsNil)
defer cmd.Process.Kill() defer cmd.Process.Kill()
err = try.GetRequest("http://127.0.0.1:8080/api/rawdata", 500*time.Millisecond, try.StatusCodeIs(http.StatusOK), try.BodyContains("Path(`/test`)")) err = try.GetRequest("http://127.0.0.1:8080/api/rawdata", 5*time.Second, try.StatusCodeIs(http.StatusOK), try.BodyContains("Path(`/test`)"))
c.Assert(err, checker.IsNil) c.Assert(err, checker.IsNil)
// Traefik passes through, termination handled by whoami-a // Traefik passes through, termination handled by whoami-a
@ -81,7 +81,7 @@ func (s *TCPSuite) TestTLSOptions(c *check.C) {
c.Assert(err, checker.IsNil) c.Assert(err, checker.IsNil)
defer cmd.Process.Kill() defer cmd.Process.Kill()
err = try.GetRequest("http://127.0.0.1:8080/api/rawdata", 500*time.Millisecond, try.StatusCodeIs(http.StatusOK), try.BodyContains("HostSNI(`whoami-c.test`)")) err = try.GetRequest("http://127.0.0.1:8080/api/rawdata", 5*time.Second, try.StatusCodeIs(http.StatusOK), try.BodyContains("HostSNI(`whoami-c.test`)"))
c.Assert(err, checker.IsNil) c.Assert(err, checker.IsNil)
// Check that we can use a client tls version <= 1.1 with hostSNI 'whoami-c.test' // Check that we can use a client tls version <= 1.1 with hostSNI 'whoami-c.test'
@ -111,7 +111,7 @@ func (s *TCPSuite) TestNonTLSFallback(c *check.C) {
c.Assert(err, checker.IsNil) c.Assert(err, checker.IsNil)
defer cmd.Process.Kill() defer cmd.Process.Kill()
err = try.GetRequest("http://127.0.0.1:8080/api/rawdata", 500*time.Millisecond, try.StatusCodeIs(http.StatusOK), try.BodyContains("HostSNI(`*`)")) err = try.GetRequest("http://127.0.0.1:8080/api/rawdata", 5*time.Second, try.StatusCodeIs(http.StatusOK), try.BodyContains("HostSNI(`*`)"))
c.Assert(err, checker.IsNil) c.Assert(err, checker.IsNil)
// Traefik passes through, termination handled by whoami-a // Traefik passes through, termination handled by whoami-a
@ -145,7 +145,7 @@ func (s *TCPSuite) TestNonTlsTcp(c *check.C) {
c.Assert(err, checker.IsNil) c.Assert(err, checker.IsNil)
defer cmd.Process.Kill() defer cmd.Process.Kill()
err = try.GetRequest("http://127.0.0.1:8080/api/rawdata", 500*time.Millisecond, try.StatusCodeIs(http.StatusOK), try.BodyContains("HostSNI(`*`)")) err = try.GetRequest("http://127.0.0.1:8080/api/rawdata", 5*time.Second, try.StatusCodeIs(http.StatusOK), try.BodyContains("HostSNI(`*`)"))
c.Assert(err, checker.IsNil) c.Assert(err, checker.IsNil)
// Traefik will forward every requests on the given port to whoami-no-tls // Traefik will forward every requests on the given port to whoami-no-tls
@ -165,7 +165,7 @@ func (s *TCPSuite) TestCatchAllNoTLS(c *check.C) {
c.Assert(err, checker.IsNil) c.Assert(err, checker.IsNil)
defer cmd.Process.Kill() defer cmd.Process.Kill()
err = try.GetRequest("http://127.0.0.1:8080/api/rawdata", 500*time.Millisecond, try.StatusCodeIs(http.StatusOK), try.BodyContains("HostSNI(`*`)")) err = try.GetRequest("http://127.0.0.1:8080/api/rawdata", 5*time.Second, try.StatusCodeIs(http.StatusOK), try.BodyContains("HostSNI(`*`)"))
c.Assert(err, checker.IsNil) c.Assert(err, checker.IsNil)
// Traefik will forward every requests on the given port to whoami-no-tls // Traefik will forward every requests on the given port to whoami-no-tls
@ -185,7 +185,7 @@ func (s *TCPSuite) TestCatchAllNoTLSWithHTTPS(c *check.C) {
c.Assert(err, checker.IsNil) c.Assert(err, checker.IsNil)
defer cmd.Process.Kill() defer cmd.Process.Kill()
err = try.GetRequest("http://127.0.0.1:8080/api/rawdata", 500*time.Millisecond, try.StatusCodeIs(http.StatusOK), try.BodyContains("HostSNI(`*`)")) err = try.GetRequest("http://127.0.0.1:8080/api/rawdata", 5*time.Second, try.StatusCodeIs(http.StatusOK), try.BodyContains("HostSNI(`*`)"))
c.Assert(err, checker.IsNil) c.Assert(err, checker.IsNil)
req := httptest.NewRequest(http.MethodGet, "https://127.0.0.1:8093/test", nil) req := httptest.NewRequest(http.MethodGet, "https://127.0.0.1:8093/test", nil)

View file

@ -82,11 +82,11 @@
} }
}, },
"tcpRouters": { "tcpRouters": {
"default/test3.crd-673acf455cb2dab0b43a@kubernetescrd": { "default/test3.route-673acf455cb2dab0b43a@kubernetescrd": {
"entryPoints": [ "entryPoints": [
"footcp" "footcp"
], ],
"service": "default/test3.crd-673acf455cb2dab0b43a", "service": "default/test3.route-673acf455cb2dab0b43a",
"rule": "HostSNI(`*`)", "rule": "HostSNI(`*`)",
"tls": { "tls": {
"passthrough": false, "passthrough": false,
@ -96,7 +96,7 @@
} }
}, },
"tcpServices": { "tcpServices": {
"default/test3.crd-673acf455cb2dab0b43a@kubernetescrd": { "default/test3.route-673acf455cb2dab0b43a@kubernetescrd": {
"loadBalancer": { "loadBalancer": {
"servers": [ "servers": [
{ {
@ -109,7 +109,7 @@
}, },
"status": "enabled", "status": "enabled",
"usedBy": [ "usedBy": [
"default/test3.crd-673acf455cb2dab0b43a@kubernetescrd" "default/test3.route-673acf455cb2dab0b43a@kubernetescrd"
] ]
} }
} }