tests: improve timeout.
- upgrade k3s to v0.8.0
This commit is contained in:
parent
5d01452648
commit
0f32de4aa2
9 changed files with 54 additions and 33 deletions
|
@ -18,7 +18,7 @@ In the following, the Kubernetes resources defined in YAML configuration files c
|
|||
|
||||
!!! 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
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
server:
|
||||
image: rancher/k3s:v0.5.0
|
||||
image: rancher/k3s:v0.8.0
|
||||
command: server --disable-agent --no-deploy traefik
|
||||
environment:
|
||||
- K3S_CLUSTER_SECRET=somethingtotallyrandom
|
||||
|
@ -17,7 +17,7 @@ server:
|
|||
- 6443:6443
|
||||
|
||||
node:
|
||||
image: rancher/k3s:v0.5.0
|
||||
image: rancher/k3s:v0.8.0
|
||||
privileged: true
|
||||
links:
|
||||
- server
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
apiVersion: traefik.containo.us/v1alpha1
|
||||
kind: IngressRouteTCP
|
||||
metadata:
|
||||
name: test3.crd
|
||||
name: test3.route
|
||||
namespace: default
|
||||
|
||||
spec:
|
||||
|
|
0
integration/fixtures/k8s/config.skip/.gitkeep
Normal file
0
integration/fixtures/k8s/config.skip/.gitkeep
Normal file
|
@ -119,17 +119,32 @@ func (s *BaseSuite) traefikCmd(args ...string) (*exec.Cmd, func(*check.C)) {
|
|||
cmd, out := s.cmdTraefik(args...)
|
||||
return cmd, func(c *check.C) {
|
||||
if c.Failed() || *showLog {
|
||||
s.displayLogK3S(c)
|
||||
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) {
|
||||
if output == nil || output.Len() == 0 {
|
||||
log.Infof("%s: No Traefik logs.", c.TestName())
|
||||
log.WithoutContext().Infof("%s: No Traefik logs.", c.TestName())
|
||||
} else {
|
||||
log.Infof("%s: Traefik logs: ", c.TestName())
|
||||
log.Infof(output.String())
|
||||
log.WithoutContext().Infof("%s: Traefik logs: ", c.TestName())
|
||||
log.WithoutContext().Infof(output.String())
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -16,6 +16,7 @@ import (
|
|||
|
||||
"github.com/containous/traefik/v2/integration/try"
|
||||
"github.com/containous/traefik/v2/pkg/api"
|
||||
"github.com/containous/traefik/v2/pkg/log"
|
||||
"github.com/go-check/check"
|
||||
"github.com/pmezard/go-difflib/difflib"
|
||||
checker "github.com/vdemeester/shakers"
|
||||
|
@ -30,7 +31,7 @@ func (s *K8sSuite) SetUpSuite(c *check.C) {
|
|||
s.createComposeProject(c, "k8s")
|
||||
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)
|
||||
|
||||
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) {
|
||||
s.composeProject.Stop(c)
|
||||
|
||||
err := os.Remove("./fixtures/k8s/kubeconfig.yaml")
|
||||
if err != nil {
|
||||
c.Log(err)
|
||||
generatedFiles := []string{
|
||||
"./fixtures/k8s/config.skip/kubeconfig.yaml",
|
||||
"./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 {
|
||||
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) {
|
||||
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)
|
||||
|
||||
if *updateExpected {
|
||||
|
@ -93,7 +99,7 @@ func testConfiguration(c *check.C, path string) {
|
|||
}
|
||||
|
||||
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 err != nil {
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
server:
|
||||
image: rancher/k3s:v0.5.0
|
||||
command: server --disable-agent --no-deploy traefik
|
||||
image: rancher/k3s:v0.8.0
|
||||
command: server --disable-agent --no-deploy traefik --log /output/k3s.log
|
||||
environment:
|
||||
- K3S_CLUSTER_SECRET=somethingtotallyrandom
|
||||
- K3S_KUBECONFIG_OUTPUT=/output/kubeconfig.yaml
|
||||
- K3S_KUBECONFIG_MODE=666
|
||||
volumes:
|
||||
- ../../fixtures/k8s:/output
|
||||
- ../../fixtures/k8s/config.skip:/output
|
||||
- ../../fixtures/k8s:/var/lib/rancher/k3s/server/manifests
|
||||
ports:
|
||||
- 6443:6443
|
||||
|
||||
node:
|
||||
image: rancher/k3s:v0.5.0
|
||||
image: rancher/k3s:v0.8.0
|
||||
privileged: true
|
||||
links:
|
||||
- server
|
||||
|
|
|
@ -31,7 +31,7 @@ func (s *TCPSuite) TestMixed(c *check.C) {
|
|||
c.Assert(err, checker.IsNil)
|
||||
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)
|
||||
|
||||
// Traefik passes through, termination handled by whoami-a
|
||||
|
@ -81,7 +81,7 @@ func (s *TCPSuite) TestTLSOptions(c *check.C) {
|
|||
c.Assert(err, checker.IsNil)
|
||||
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)
|
||||
|
||||
// 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)
|
||||
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)
|
||||
|
||||
// Traefik passes through, termination handled by whoami-a
|
||||
|
@ -145,7 +145,7 @@ func (s *TCPSuite) TestNonTlsTcp(c *check.C) {
|
|||
c.Assert(err, checker.IsNil)
|
||||
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)
|
||||
|
||||
// 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)
|
||||
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)
|
||||
|
||||
// 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)
|
||||
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)
|
||||
|
||||
req := httptest.NewRequest(http.MethodGet, "https://127.0.0.1:8093/test", nil)
|
||||
|
|
8
integration/testdata/rawdata-crd.json
vendored
8
integration/testdata/rawdata-crd.json
vendored
|
@ -82,11 +82,11 @@
|
|||
}
|
||||
},
|
||||
"tcpRouters": {
|
||||
"default/test3.crd-673acf455cb2dab0b43a@kubernetescrd": {
|
||||
"default/test3.route-673acf455cb2dab0b43a@kubernetescrd": {
|
||||
"entryPoints": [
|
||||
"footcp"
|
||||
],
|
||||
"service": "default/test3.crd-673acf455cb2dab0b43a",
|
||||
"service": "default/test3.route-673acf455cb2dab0b43a",
|
||||
"rule": "HostSNI(`*`)",
|
||||
"tls": {
|
||||
"passthrough": false,
|
||||
|
@ -96,7 +96,7 @@
|
|||
}
|
||||
},
|
||||
"tcpServices": {
|
||||
"default/test3.crd-673acf455cb2dab0b43a@kubernetescrd": {
|
||||
"default/test3.route-673acf455cb2dab0b43a@kubernetescrd": {
|
||||
"loadBalancer": {
|
||||
"servers": [
|
||||
{
|
||||
|
@ -109,7 +109,7 @@
|
|||
},
|
||||
"status": "enabled",
|
||||
"usedBy": [
|
||||
"default/test3.crd-673acf455cb2dab0b43a@kubernetescrd"
|
||||
"default/test3.route-673acf455cb2dab0b43a@kubernetescrd"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue