diff --git a/integration/access_log_test.go b/integration/access_log_test.go index e79be8571..74d8200e1 100644 --- a/integration/access_log_test.go +++ b/integration/access_log_test.go @@ -65,7 +65,7 @@ func (s *AccessLogSuite) TestAccessLog(c *check.C) { err := cmd.Start() c.Assert(err, checker.IsNil) - defer cmd.Process.Kill() + defer s.killCmd(cmd) waitForTraefik(c, "server1") @@ -133,7 +133,7 @@ func (s *AccessLogSuite) TestAccessLogAuthFrontend(c *check.C) { err := cmd.Start() c.Assert(err, checker.IsNil) - defer cmd.Process.Kill() + defer s.killCmd(cmd) checkStatsForLogFile(c) @@ -204,7 +204,7 @@ func (s *AccessLogSuite) TestAccessLogDigestAuthMiddleware(c *check.C) { err := cmd.Start() c.Assert(err, checker.IsNil) - defer cmd.Process.Kill() + defer s.killCmd(cmd) checkStatsForLogFile(c) @@ -319,7 +319,7 @@ func (s *AccessLogSuite) TestAccessLogFrontendRedirect(c *check.C) { err := cmd.Start() c.Assert(err, checker.IsNil) - defer cmd.Process.Kill() + defer s.killCmd(cmd) checkStatsForLogFile(c) @@ -372,7 +372,7 @@ func (s *AccessLogSuite) TestAccessLogRateLimit(c *check.C) { err := cmd.Start() c.Assert(err, checker.IsNil) - defer cmd.Process.Kill() + defer s.killCmd(cmd) checkStatsForLogFile(c) @@ -423,7 +423,7 @@ func (s *AccessLogSuite) TestAccessLogBackendNotFound(c *check.C) { err := cmd.Start() c.Assert(err, checker.IsNil) - defer cmd.Process.Kill() + defer s.killCmd(cmd) waitForTraefik(c, "server1") @@ -468,7 +468,7 @@ func (s *AccessLogSuite) TestAccessLogFrontendWhitelist(c *check.C) { err := cmd.Start() c.Assert(err, checker.IsNil) - defer cmd.Process.Kill() + defer s.killCmd(cmd) checkStatsForLogFile(c) @@ -515,7 +515,7 @@ func (s *AccessLogSuite) TestAccessLogAuthFrontendSuccess(c *check.C) { err := cmd.Start() c.Assert(err, checker.IsNil) - defer cmd.Process.Kill() + defer s.killCmd(cmd) checkStatsForLogFile(c) diff --git a/integration/acme_test.go b/integration/acme_test.go index e91475bf6..a67eb96e2 100644 --- a/integration/acme_test.go +++ b/integration/acme_test.go @@ -410,7 +410,7 @@ func (s *AcmeSuite) TestNoValidLetsEncryptServer(c *check.C) { defer display(c) err := cmd.Start() c.Assert(err, checker.IsNil) - defer cmd.Process.Kill() + defer s.killCmd(cmd) // Expected traefik works err = try.GetRequest("http://127.0.0.1:8080/api/rawdata", 10*time.Second, try.StatusCodeIs(http.StatusOK)) @@ -440,7 +440,7 @@ func (s *AcmeSuite) retrieveAcmeCertificate(c *check.C, testCase acmeTestCase) { defer display(c) err := cmd.Start() c.Assert(err, checker.IsNil) - defer cmd.Process.Kill() + defer s.killCmd(cmd) // A real file is needed to have the right mode on acme.json file defer os.Remove("/tmp/acme.json") diff --git a/integration/consul_catalog_test.go b/integration/consul_catalog_test.go index c6e9f0775..3c065eb05 100644 --- a/integration/consul_catalog_test.go +++ b/integration/consul_catalog_test.go @@ -122,7 +122,7 @@ func (s *ConsulCatalogSuite) TestWithNotExposedByDefaultAndDefaultsSettings(c *c defer display(c) err = cmd.Start() c.Assert(err, checker.IsNil) - defer cmd.Process.Kill() + defer s.killCmd(cmd) req, err := http.NewRequest(http.MethodGet, "http://127.0.0.1:8000/", nil) c.Assert(err, checker.IsNil) @@ -181,7 +181,7 @@ func (s *ConsulCatalogSuite) TestByLabels(c *check.C) { defer display(c) err = cmd.Start() c.Assert(err, checker.IsNil) - defer cmd.Process.Kill() + defer s.killCmd(cmd) err = try.GetRequest("http://127.0.0.1:8000/whoami", 2*time.Second, try.StatusCodeIs(http.StatusOK), try.BodyContainsOr("Hostname: whoami1", "Hostname: whoami2", "Hostname: whoami3")) c.Assert(err, checker.IsNil) @@ -216,7 +216,7 @@ func (s *ConsulCatalogSuite) TestSimpleConfiguration(c *check.C) { defer display(c) err = cmd.Start() c.Assert(err, checker.IsNil) - defer cmd.Process.Kill() + defer s.killCmd(cmd) req, err := http.NewRequest(http.MethodGet, "http://127.0.0.1:8000/", nil) c.Assert(err, checker.IsNil) @@ -255,7 +255,7 @@ func (s *ConsulCatalogSuite) TestRegisterServiceWithoutIP(c *check.C) { defer display(c) err = cmd.Start() c.Assert(err, checker.IsNil) - defer cmd.Process.Kill() + defer s.killCmd(cmd) req, err := http.NewRequest(http.MethodGet, "http://127.0.0.1:8080/api/http/services", nil) c.Assert(err, checker.IsNil) @@ -294,7 +294,7 @@ func (s *ConsulCatalogSuite) TestDefaultConsulService(c *check.C) { defer display(c) err = cmd.Start() c.Assert(err, checker.IsNil) - defer cmd.Process.Kill() + defer s.killCmd(cmd) req, err := http.NewRequest(http.MethodGet, "http://127.0.0.1:8000/", nil) c.Assert(err, checker.IsNil) @@ -340,7 +340,7 @@ func (s *ConsulCatalogSuite) TestConsulServiceWithTCPLabels(c *check.C) { defer display(c) err = cmd.Start() c.Assert(err, checker.IsNil) - defer cmd.Process.Kill() + defer s.killCmd(cmd) err = try.GetRequest("http://127.0.0.1:8080/api/rawdata", 1500*time.Millisecond, try.StatusCodeIs(http.StatusOK), try.BodyContains("HostSNI(`my.super.host`)")) c.Assert(err, checker.IsNil) @@ -398,7 +398,7 @@ func (s *ConsulCatalogSuite) TestConsulServiceWithLabels(c *check.C) { defer display(c) err = cmd.Start() c.Assert(err, checker.IsNil) - defer cmd.Process.Kill() + defer s.killCmd(cmd) req, err := http.NewRequest(http.MethodGet, "http://127.0.0.1:8000/", nil) c.Assert(err, checker.IsNil) @@ -465,7 +465,7 @@ func (s *ConsulCatalogSuite) TestSameServiceIDOnDifferentConsulAgent(c *check.C) defer display(c) err = cmd.Start() c.Assert(err, checker.IsNil) - defer cmd.Process.Kill() + defer s.killCmd(cmd) req, err := http.NewRequest(http.MethodGet, "http://127.0.0.1:8000/", nil) c.Assert(err, checker.IsNil) @@ -520,7 +520,7 @@ func (s *ConsulCatalogSuite) TestConsulServiceWithOneMissingLabels(c *check.C) { defer display(c) err = cmd.Start() c.Assert(err, checker.IsNil) - defer cmd.Process.Kill() + defer s.killCmd(cmd) req, err := http.NewRequest(http.MethodGet, "http://127.0.0.1:8000/version", nil) c.Assert(err, checker.IsNil) @@ -572,7 +572,7 @@ func (s *ConsulCatalogSuite) TestConsulServiceWithHealthCheck(c *check.C) { defer display(c) err = cmd.Start() c.Assert(err, checker.IsNil) - defer cmd.Process.Kill() + defer s.killCmd(cmd) err = try.GetRequest("http://127.0.0.1:8000/whoami", 2*time.Second, try.StatusCodeIs(http.StatusNotFound)) c.Assert(err, checker.IsNil) diff --git a/integration/consul_test.go b/integration/consul_test.go index 388ff7944..07ade5d17 100644 --- a/integration/consul_test.go +++ b/integration/consul_test.go @@ -118,7 +118,7 @@ func (s *ConsulSuite) TestSimpleConfiguration(c *check.C) { defer display(c) err := cmd.Start() c.Assert(err, checker.IsNil) - defer cmd.Process.Kill() + defer s.killCmd(cmd) // wait for traefik err = try.GetRequest("http://127.0.0.1:8080/api/rawdata", 2*time.Second, diff --git a/integration/docker_compose_test.go b/integration/docker_compose_test.go index 4269c07e1..847ef3d8b 100644 --- a/integration/docker_compose_test.go +++ b/integration/docker_compose_test.go @@ -55,7 +55,7 @@ func (s *DockerComposeSuite) TestComposeScale(c *check.C) { defer display(c) err := cmd.Start() c.Assert(err, checker.IsNil) - defer cmd.Process.Kill() + defer s.killCmd(cmd) req := testhelpers.MustNewRequest(http.MethodGet, "http://127.0.0.1:8000/whoami", nil) req.Host = "my.super.host" diff --git a/integration/docker_test.go b/integration/docker_test.go index 02a91a676..e379d4f6b 100644 --- a/integration/docker_test.go +++ b/integration/docker_test.go @@ -98,7 +98,7 @@ func (s *DockerSuite) TestSimpleConfiguration(c *check.C) { defer display(c) err := cmd.Start() c.Assert(err, checker.IsNil) - defer cmd.Process.Kill() + defer s.killCmd(cmd) // TODO validate : run on 80 // Expected a 404 as we did not configure anything @@ -125,7 +125,7 @@ func (s *DockerSuite) TestDefaultDockerContainers(c *check.C) { defer display(c) err := cmd.Start() c.Assert(err, checker.IsNil) - defer cmd.Process.Kill() + defer s.killCmd(cmd) req, err := http.NewRequest(http.MethodGet, "http://127.0.0.1:8000/version", nil) c.Assert(err, checker.IsNil) @@ -170,7 +170,7 @@ func (s *DockerSuite) TestDockerContainersWithTCPLabels(c *check.C) { defer display(c) err := cmd.Start() c.Assert(err, checker.IsNil) - defer cmd.Process.Kill() + defer s.killCmd(cmd) err = try.GetRequest("http://127.0.0.1:8080/api/rawdata", 500*time.Millisecond, try.StatusCodeIs(http.StatusOK), try.BodyContains("HostSNI(`my.super.host`)")) c.Assert(err, checker.IsNil) @@ -210,7 +210,7 @@ func (s *DockerSuite) TestDockerContainersWithLabels(c *check.C) { defer display(c) err := cmd.Start() c.Assert(err, checker.IsNil) - defer cmd.Process.Kill() + defer s.killCmd(cmd) req, err := http.NewRequest(http.MethodGet, "http://127.0.0.1:8000/version", nil) c.Assert(err, checker.IsNil) @@ -260,7 +260,7 @@ func (s *DockerSuite) TestDockerContainersWithOneMissingLabels(c *check.C) { defer display(c) err := cmd.Start() c.Assert(err, checker.IsNil) - defer cmd.Process.Kill() + defer s.killCmd(cmd) req, err := http.NewRequest(http.MethodGet, "http://127.0.0.1:8000/version", nil) c.Assert(err, checker.IsNil) @@ -297,7 +297,7 @@ func (s *DockerSuite) TestRestartDockerContainers(c *check.C) { defer display(c) err := cmd.Start() c.Assert(err, checker.IsNil) - defer cmd.Process.Kill() + defer s.killCmd(cmd) req, err := http.NewRequest(http.MethodGet, "http://127.0.0.1:8000/version", nil) c.Assert(err, checker.IsNil) diff --git a/integration/error_pages_test.go b/integration/error_pages_test.go index 6ad6fc386..aae9d9b42 100644 --- a/integration/error_pages_test.go +++ b/integration/error_pages_test.go @@ -36,7 +36,7 @@ func (s *ErrorPagesSuite) TestSimpleConfiguration(c *check.C) { defer display(c) err := cmd.Start() c.Assert(err, checker.IsNil) - defer cmd.Process.Kill() + defer s.killCmd(cmd) frontendReq, err := http.NewRequest(http.MethodGet, "http://127.0.0.1:8080", nil) c.Assert(err, checker.IsNil) @@ -58,7 +58,7 @@ func (s *ErrorPagesSuite) TestErrorPage(c *check.C) { defer display(c) err := cmd.Start() c.Assert(err, checker.IsNil) - defer cmd.Process.Kill() + defer s.killCmd(cmd) frontendReq, err := http.NewRequest(http.MethodGet, "http://127.0.0.1:8080", nil) c.Assert(err, checker.IsNil) diff --git a/integration/etcd_test.go b/integration/etcd_test.go index 5f0502fa9..a4ca83262 100644 --- a/integration/etcd_test.go +++ b/integration/etcd_test.go @@ -118,7 +118,7 @@ func (s *EtcdSuite) TestSimpleConfiguration(c *check.C) { defer display(c) err := cmd.Start() c.Assert(err, checker.IsNil) - defer cmd.Process.Kill() + defer s.killCmd(cmd) // wait for traefik err = try.GetRequest("http://127.0.0.1:8080/api/rawdata", 2*time.Second, diff --git a/integration/file_test.go b/integration/file_test.go index 13fcbf2aa..cc4c8ea4f 100644 --- a/integration/file_test.go +++ b/integration/file_test.go @@ -25,7 +25,7 @@ func (s *FileSuite) TestSimpleConfiguration(c *check.C) { defer display(c) err := cmd.Start() c.Assert(err, checker.IsNil) - defer cmd.Process.Kill() + defer s.killCmd(cmd) // Expected a 404 as we did not configure anything err = try.GetRequest("http://127.0.0.1:8000/", 1000*time.Millisecond, try.StatusCodeIs(http.StatusNotFound)) @@ -38,7 +38,7 @@ func (s *FileSuite) TestSimpleConfigurationNoPanic(c *check.C) { defer display(c) err := cmd.Start() c.Assert(err, checker.IsNil) - defer cmd.Process.Kill() + defer s.killCmd(cmd) // Expected a 404 as we did not configure anything err = try.GetRequest("http://127.0.0.1:8000/", 1000*time.Millisecond, try.StatusCodeIs(http.StatusNotFound)) @@ -50,7 +50,7 @@ func (s *FileSuite) TestDirectoryConfiguration(c *check.C) { defer display(c) err := cmd.Start() c.Assert(err, checker.IsNil) - defer cmd.Process.Kill() + defer s.killCmd(cmd) // Expected a 404 as we did not configure anything at /test err = try.GetRequest("http://127.0.0.1:8000/test", 1000*time.Millisecond, try.StatusCodeIs(http.StatusNotFound)) diff --git a/integration/grpc_test.go b/integration/grpc_test.go index 9b0d17fcd..256b977a7 100644 --- a/integration/grpc_test.go +++ b/integration/grpc_test.go @@ -164,7 +164,7 @@ func (s *GRPCSuite) TestGRPC(c *check.C) { err = cmd.Start() c.Assert(err, check.IsNil) - defer cmd.Process.Kill() + defer s.killCmd(cmd) // wait for Traefik err = try.GetRequest("http://127.0.0.1:8080/api/rawdata", 1*time.Second, try.BodyContains("Host(`127.0.0.1`)")) @@ -202,7 +202,7 @@ func (s *GRPCSuite) TestGRPCh2c(c *check.C) { err = cmd.Start() c.Assert(err, check.IsNil) - defer cmd.Process.Kill() + defer s.killCmd(cmd) // wait for Traefik err = try.GetRequest("http://127.0.0.1:8080/api/rawdata", 1*time.Second, try.BodyContains("Host(`127.0.0.1`)")) @@ -244,7 +244,7 @@ func (s *GRPCSuite) TestGRPCh2cTermination(c *check.C) { err = cmd.Start() c.Assert(err, check.IsNil) - defer cmd.Process.Kill() + defer s.killCmd(cmd) // wait for Traefik err = try.GetRequest("http://127.0.0.1:8080/api/rawdata", 1*time.Second, try.BodyContains("Host(`127.0.0.1`)")) @@ -286,7 +286,7 @@ func (s *GRPCSuite) TestGRPCInsecure(c *check.C) { err = cmd.Start() c.Assert(err, check.IsNil) - defer cmd.Process.Kill() + defer s.killCmd(cmd) // wait for Traefik err = try.GetRequest("http://127.0.0.1:8080/api/rawdata", 1*time.Second, try.BodyContains("Host(`127.0.0.1`)")) @@ -333,7 +333,7 @@ func (s *GRPCSuite) TestGRPCBuffer(c *check.C) { err = cmd.Start() c.Assert(err, check.IsNil) - defer cmd.Process.Kill() + defer s.killCmd(cmd) // wait for Traefik err = try.GetRequest("http://127.0.0.1:8080/api/rawdata", 1*time.Second, try.BodyContains("Host(`127.0.0.1`)")) @@ -392,7 +392,7 @@ func (s *GRPCSuite) TestGRPCBufferWithFlushInterval(c *check.C) { defer display(c) err = cmd.Start() c.Assert(err, check.IsNil) - defer cmd.Process.Kill() + defer s.killCmd(cmd) // wait for Traefik err = try.GetRequest("http://127.0.0.1:8080/api/rawdata", 1*time.Second, try.BodyContains("Host(`127.0.0.1`)")) @@ -450,7 +450,7 @@ func (s *GRPCSuite) TestGRPCWithRetry(c *check.C) { err = cmd.Start() c.Assert(err, check.IsNil) - defer cmd.Process.Kill() + defer s.killCmd(cmd) // wait for Traefik err = try.GetRequest("http://127.0.0.1:8080/api/rawdata", 1*time.Second, try.BodyContains("Host(`127.0.0.1`)")) diff --git a/integration/headers_test.go b/integration/headers_test.go index fe80e576e..a5e9e7e67 100644 --- a/integration/headers_test.go +++ b/integration/headers_test.go @@ -18,7 +18,7 @@ func (s *HeadersSuite) TestSimpleConfiguration(c *check.C) { defer display(c) err := cmd.Start() c.Assert(err, checker.IsNil) - defer cmd.Process.Kill() + defer s.killCmd(cmd) // Expected a 404 as we did not configure anything err = try.GetRequest("http://127.0.0.1:8000/", 1000*time.Millisecond, try.StatusCodeIs(http.StatusNotFound)) @@ -33,7 +33,7 @@ func (s *HeadersSuite) TestCorsResponses(c *check.C) { err := cmd.Start() c.Assert(err, checker.IsNil) - defer cmd.Process.Kill() + defer s.killCmd(cmd) backend := startTestServer("9000", http.StatusOK, "") defer backend.Close() @@ -122,7 +122,7 @@ func (s *HeadersSuite) TestSecureHeadersResponses(c *check.C) { err := cmd.Start() c.Assert(err, checker.IsNil) - defer cmd.Process.Kill() + defer s.killCmd(cmd) backend := startTestServer("9000", http.StatusOK, "") defer backend.Close() @@ -171,7 +171,7 @@ func (s *HeadersSuite) TestMultipleSecureHeadersResponses(c *check.C) { err := cmd.Start() c.Assert(err, checker.IsNil) - defer cmd.Process.Kill() + defer s.killCmd(cmd) backend := startTestServer("9000", http.StatusOK, "") defer backend.Close() diff --git a/integration/healthcheck_test.go b/integration/healthcheck_test.go index 5d202a365..8d268ad85 100644 --- a/integration/healthcheck_test.go +++ b/integration/healthcheck_test.go @@ -37,7 +37,7 @@ func (s *HealthCheckSuite) TestSimpleConfiguration(c *check.C) { defer display(c) err := cmd.Start() c.Assert(err, checker.IsNil) - defer cmd.Process.Kill() + defer s.killCmd(cmd) // wait for traefik err = try.GetRequest("http://127.0.0.1:8080/api/rawdata", 60*time.Second, try.BodyContains("Host(`test.localhost`)")) @@ -105,7 +105,7 @@ func (s *HealthCheckSuite) TestMultipleEntrypoints(c *check.C) { defer display(c) err := cmd.Start() c.Assert(err, checker.IsNil) - defer cmd.Process.Kill() + defer s.killCmd(cmd) // Wait for traefik err = try.GetRequest("http://localhost:8080/api/rawdata", 60*time.Second, try.BodyContains("Host(`test.localhost`)")) @@ -181,7 +181,7 @@ func (s *HealthCheckSuite) TestPortOverload(c *check.C) { defer display(c) err = cmd.Start() c.Assert(err, checker.IsNil) - defer cmd.Process.Kill() + defer s.killCmd(cmd) // wait for traefik err = try.GetRequest("http://127.0.0.1:8080/api/rawdata", 10*time.Second, try.BodyContains("Host(`test.localhost`)")) @@ -217,7 +217,7 @@ func (s *HealthCheckSuite) TestMultipleRoutersOnSameService(c *check.C) { defer display(c) err := cmd.Start() c.Assert(err, checker.IsNil) - defer cmd.Process.Kill() + defer s.killCmd(cmd) // wait for traefik err = try.GetRequest("http://127.0.0.1:8080/api/rawdata", 60*time.Second, try.BodyContains("Host(`test.localhost`)")) diff --git a/integration/hostresolver_test.go b/integration/hostresolver_test.go index 8c864e6e3..936e60452 100644 --- a/integration/hostresolver_test.go +++ b/integration/hostresolver_test.go @@ -24,7 +24,7 @@ func (s *HostResolverSuite) TestSimpleConfig(c *check.C) { err := cmd.Start() c.Assert(err, checker.IsNil) - defer cmd.Process.Kill() + defer s.killCmd(cmd) testCase := []struct { desc string diff --git a/integration/http_test.go b/integration/http_test.go index 78ecf4c15..6e18fcb80 100644 --- a/integration/http_test.go +++ b/integration/http_test.go @@ -22,7 +22,7 @@ func (s *HTTPSuite) TestSimpleConfiguration(c *check.C) { err := cmd.Start() c.Assert(err, checker.IsNil) - defer cmd.Process.Kill() + defer s.killCmd(cmd) // Expect a 404 as we configured nothing. err = try.GetRequest("http://127.0.0.1:8000/", time.Second, try.StatusCodeIs(http.StatusNotFound)) diff --git a/integration/https_test.go b/integration/https_test.go index 71554b2c8..115eef899 100644 --- a/integration/https_test.go +++ b/integration/https_test.go @@ -31,7 +31,7 @@ func (s *HTTPSSuite) TestWithSNIConfigHandshake(c *check.C) { defer display(c) err := cmd.Start() c.Assert(err, checker.IsNil) - defer cmd.Process.Kill() + defer s.killCmd(cmd) // wait for Traefik err = try.GetRequest("http://127.0.0.1:8080/api/rawdata", 500*time.Millisecond, try.BodyContains("Host(`snitest.org`)")) @@ -67,7 +67,7 @@ func (s *HTTPSSuite) TestWithSNIConfigRoute(c *check.C) { defer display(c) err := cmd.Start() c.Assert(err, checker.IsNil) - defer cmd.Process.Kill() + defer s.killCmd(cmd) // wait for Traefik err = try.GetRequest("http://127.0.0.1:8080/api/rawdata", 1*time.Second, try.BodyContains("Host(`snitest.org`)")) @@ -123,7 +123,7 @@ func (s *HTTPSSuite) TestWithTLSOptions(c *check.C) { defer display(c) err := cmd.Start() c.Assert(err, checker.IsNil) - defer cmd.Process.Kill() + defer s.killCmd(cmd) // wait for Traefik err = try.GetRequest("http://127.0.0.1:8080/api/rawdata", 1*time.Second, try.BodyContains("Host(`snitest.org`)")) @@ -209,7 +209,7 @@ func (s *HTTPSSuite) TestWithConflictingTLSOptions(c *check.C) { defer display(c) err := cmd.Start() c.Assert(err, checker.IsNil) - defer cmd.Process.Kill() + defer s.killCmd(cmd) // wait for Traefik err = try.GetRequest("http://127.0.0.1:8080/api/rawdata", 1*time.Second, try.BodyContains("Host(`snitest.net`)")) @@ -279,7 +279,7 @@ func (s *HTTPSSuite) TestWithSNIStrictNotMatchedRequest(c *check.C) { defer display(c) err := cmd.Start() c.Assert(err, checker.IsNil) - defer cmd.Process.Kill() + defer s.killCmd(cmd) // wait for Traefik err = try.GetRequest("http://127.0.0.1:8080/api/rawdata", 500*time.Millisecond, try.BodyContains("Host(`snitest.com`)")) @@ -305,7 +305,7 @@ func (s *HTTPSSuite) TestWithDefaultCertificate(c *check.C) { defer display(c) err := cmd.Start() c.Assert(err, checker.IsNil) - defer cmd.Process.Kill() + defer s.killCmd(cmd) // wait for Traefik err = try.GetRequest("http://127.0.0.1:8080/api/rawdata", 500*time.Millisecond, try.BodyContains("Host(`snitest.com`)")) @@ -341,7 +341,7 @@ func (s *HTTPSSuite) TestWithDefaultCertificateNoSNI(c *check.C) { defer display(c) err := cmd.Start() c.Assert(err, checker.IsNil) - defer cmd.Process.Kill() + defer s.killCmd(cmd) // wait for Traefik err = try.GetRequest("http://127.0.0.1:8080/api/rawdata", 500*time.Millisecond, try.BodyContains("Host(`snitest.com`)")) @@ -377,7 +377,7 @@ func (s *HTTPSSuite) TestWithOverlappingStaticCertificate(c *check.C) { defer display(c) err := cmd.Start() c.Assert(err, checker.IsNil) - defer cmd.Process.Kill() + defer s.killCmd(cmd) // wait for Traefik err = try.GetRequest("http://127.0.0.1:8080/api/rawdata", 500*time.Millisecond, try.BodyContains("Host(`snitest.com`)")) @@ -414,7 +414,7 @@ func (s *HTTPSSuite) TestWithOverlappingDynamicCertificate(c *check.C) { defer display(c) err := cmd.Start() c.Assert(err, checker.IsNil) - defer cmd.Process.Kill() + defer s.killCmd(cmd) // wait for Traefik err = try.GetRequest("http://127.0.0.1:8080/api/rawdata", 500*time.Millisecond, try.BodyContains("Host(`snitest.com`)")) @@ -449,7 +449,7 @@ func (s *HTTPSSuite) TestWithClientCertificateAuthentication(c *check.C) { defer display(c) err := cmd.Start() c.Assert(err, checker.IsNil) - defer cmd.Process.Kill() + defer s.killCmd(cmd) // wait for Traefik err = try.GetRequest("http://127.0.0.1:8080/api/rawdata", 500*time.Millisecond, try.BodyContains("Host(`snitest.org`)")) @@ -521,7 +521,7 @@ func (s *HTTPSSuite) TestWithClientCertificateAuthenticationMultipleCAs(c *check defer display(c) err := cmd.Start() c.Assert(err, checker.IsNil) - defer cmd.Process.Kill() + defer s.killCmd(cmd) // wait for Traefik err = try.GetRequest("http://127.0.0.1:8080/api/rawdata", 1*time.Second, try.BodyContains("Host(`snitest.org`)")) @@ -617,7 +617,7 @@ func (s *HTTPSSuite) TestWithClientCertificateAuthenticationMultipleCAsMultipleF defer display(c) err := cmd.Start() c.Assert(err, checker.IsNil) - defer cmd.Process.Kill() + defer s.killCmd(cmd) // wait for Traefik err = try.GetRequest("http://127.0.0.1:8080/api/rawdata", 1*time.Second, try.BodyContains("Host(`snitest.org`)")) @@ -701,7 +701,7 @@ func (s *HTTPSSuite) TestWithRootCAsContentForHTTPSOnBackend(c *check.C) { defer display(c) err := cmd.Start() c.Assert(err, checker.IsNil) - defer cmd.Process.Kill() + defer s.killCmd(cmd) // wait for Traefik err = try.GetRequest("http://127.0.0.1:8080/api/rawdata", 1*time.Second, try.BodyContains(backend.URL)) @@ -723,7 +723,7 @@ func (s *HTTPSSuite) TestWithRootCAsFileForHTTPSOnBackend(c *check.C) { defer display(c) err := cmd.Start() c.Assert(err, checker.IsNil) - defer cmd.Process.Kill() + defer s.killCmd(cmd) // wait for Traefik err = try.GetRequest("http://127.0.0.1:8080/api/rawdata", 1*time.Second, try.BodyContains(backend.URL)) @@ -770,7 +770,7 @@ func (s *HTTPSSuite) TestWithSNIDynamicConfigRouteWithNoChange(c *check.C) { defer display(c) err := cmd.Start() c.Assert(err, checker.IsNil) - defer cmd.Process.Kill() + defer s.killCmd(cmd) tr1 := &http.Transport{ TLSClientConfig: &tls.Config{ @@ -839,7 +839,7 @@ func (s *HTTPSSuite) TestWithSNIDynamicConfigRouteWithChange(c *check.C) { defer display(c) err := cmd.Start() c.Assert(err, checker.IsNil) - defer cmd.Process.Kill() + defer s.killCmd(cmd) tr1 := &http.Transport{ TLSClientConfig: &tls.Config{ @@ -909,7 +909,7 @@ func (s *HTTPSSuite) TestWithSNIDynamicConfigRouteWithTlsConfigurationDeletion(c defer display(c) err := cmd.Start() c.Assert(err, checker.IsNil) - defer cmd.Process.Kill() + defer s.killCmd(cmd) tr2 := &http.Transport{ TLSClientConfig: &tls.Config{ @@ -986,7 +986,7 @@ func (s *HTTPSSuite) TestEntryPointHttpsRedirectAndPathModification(c *check.C) defer display(c) err := cmd.Start() c.Assert(err, checker.IsNil) - defer cmd.Process.Kill() + defer s.killCmd(cmd) // wait for Traefik err = try.GetRequest("http://127.0.0.1:8080/api/rawdata", 5*time.Second, try.BodyContains("Host(`example.com`)")) @@ -1089,7 +1089,7 @@ func (s *HTTPSSuite) TestWithSNIDynamicCaseInsensitive(c *check.C) { defer display(c) err := cmd.Start() c.Assert(err, checker.IsNil) - defer cmd.Process.Kill() + defer s.killCmd(cmd) // wait for Traefik err = try.GetRequest("http://127.0.0.1:8080/api/rawdata", 500*time.Millisecond, try.BodyContains("HostRegexp(`{subdomain:[a-z1-9-]+}.www.snitest.com`)")) @@ -1130,7 +1130,7 @@ func (s *HTTPSSuite) TestWithDomainFronting(c *check.C) { defer display(c) err := cmd.Start() c.Assert(err, checker.IsNil) - defer cmd.Process.Kill() + defer s.killCmd(cmd) // wait for Traefik err = try.GetRequest("http://127.0.0.1:8080/api/rawdata", 500*time.Millisecond, try.BodyContains("Host(`site1.www.snitest.com`)")) diff --git a/integration/integration_test.go b/integration/integration_test.go index b5eaf04f3..020ea3c53 100644 --- a/integration/integration_test.go +++ b/integration/integration_test.go @@ -13,6 +13,7 @@ import ( "strings" "testing" "text/template" + "time" "github.com/fatih/structs" "github.com/go-check/check" @@ -120,6 +121,15 @@ func (s *BaseSuite) cmdTraefik(args ...string) (*exec.Cmd, *bytes.Buffer) { return cmd, &out } +func (s *BaseSuite) killCmd(cmd *exec.Cmd) { + err := cmd.Process.Kill() + if err != nil { + log.WithoutContext().Errorf("Kill: %v", err) + } + + time.Sleep(100 * time.Millisecond) +} + func (s *BaseSuite) traefikCmd(args ...string) (*exec.Cmd, func(*check.C)) { cmd, out := s.cmdTraefik(args...) return cmd, func(c *check.C) { diff --git a/integration/k8s_test.go b/integration/k8s_test.go index d4ee8ea2a..c06d83a0f 100644 --- a/integration/k8s_test.go +++ b/integration/k8s_test.go @@ -69,7 +69,7 @@ func (s *K8sSuite) TestIngressConfiguration(c *check.C) { err := cmd.Start() c.Assert(err, checker.IsNil) - defer cmd.Process.Kill() + defer s.killCmd(cmd) testConfiguration(c, "testdata/rawdata-ingress.json", "8080") } @@ -80,7 +80,7 @@ func (s *K8sSuite) TestCRDConfiguration(c *check.C) { err := cmd.Start() c.Assert(err, checker.IsNil) - defer cmd.Process.Kill() + defer s.killCmd(cmd) testConfiguration(c, "testdata/rawdata-crd.json", "8000") } diff --git a/integration/keepalive_test.go b/integration/keepalive_test.go index 0972a42bd..499e693bd 100644 --- a/integration/keepalive_test.go +++ b/integration/keepalive_test.go @@ -95,7 +95,7 @@ func (s *KeepAliveSuite) TestShouldRespectConfiguredBackendHttpKeepAliveTime(c * err := cmd.Start() c.Check(err, checker.IsNil) - defer cmd.Process.Kill() + defer s.killCmd(cmd) err = try.GetRequest("http://127.0.0.1:8000/keepalive", time.Duration(1)*time.Second, try.StatusCodeIs(200)) c.Check(err, checker.IsNil) diff --git a/integration/log_rotation_test.go b/integration/log_rotation_test.go index bbe68070f..d91bf04b4 100644 --- a/integration/log_rotation_test.go +++ b/integration/log_rotation_test.go @@ -34,7 +34,7 @@ func (s *LogRotationSuite) TestAccessLogRotation(c *check.C) { err := cmd.Start() c.Assert(err, checker.IsNil) - defer cmd.Process.Kill() + defer s.killCmd(cmd) defer os.Remove(traefikTestAccessLogFile) @@ -93,7 +93,7 @@ func (s *LogRotationSuite) TestTraefikLogRotation(c *check.C) { err := cmd.Start() c.Assert(err, checker.IsNil) - defer cmd.Process.Kill() + defer s.killCmd(cmd) defer os.Remove(traefikTestAccessLogFile) diff --git a/integration/marathon15_test.go b/integration/marathon15_test.go index 4d0049643..eb253250e 100644 --- a/integration/marathon15_test.go +++ b/integration/marathon15_test.go @@ -79,7 +79,7 @@ func (s *MarathonSuite15) TestConfigurationUpdate(c *check.C) { defer display(c) err := cmd.Start() c.Assert(err, checker.IsNil) - defer cmd.Process.Kill() + defer s.killCmd(cmd) // Wait for Traefik to turn ready. err = try.GetRequest("http://127.0.0.1:8000/", 2*time.Second, try.StatusCodeIs(http.StatusNotFound)) diff --git a/integration/marathon_test.go b/integration/marathon_test.go index 5dfbc2db0..35fec0ad1 100644 --- a/integration/marathon_test.go +++ b/integration/marathon_test.go @@ -91,7 +91,7 @@ func (s *MarathonSuite) TestConfigurationUpdate(c *check.C) { defer display(c) err := cmd.Start() c.Assert(err, checker.IsNil) - defer cmd.Process.Kill() + defer s.killCmd(cmd) // Wait for Traefik to turn ready. err = try.GetRequest("http://127.0.0.1:8000/", 2*time.Second, try.StatusCodeIs(http.StatusNotFound)) diff --git a/integration/proxy_protocol_test.go b/integration/proxy_protocol_test.go index c528bec7e..15588d868 100644 --- a/integration/proxy_protocol_test.go +++ b/integration/proxy_protocol_test.go @@ -32,7 +32,7 @@ func (s *ProxyProtocolSuite) TestProxyProtocolTrusted(c *check.C) { defer display(c) err := cmd.Start() c.Assert(err, checker.IsNil) - defer cmd.Process.Kill() + defer s.killCmd(cmd) err = try.GetRequest("http://"+haproxyIP+"/whoami", 500*time.Millisecond, try.StatusCodeIs(http.StatusOK), @@ -55,7 +55,7 @@ func (s *ProxyProtocolSuite) TestProxyProtocolV2Trusted(c *check.C) { defer display(c) err := cmd.Start() c.Assert(err, checker.IsNil) - defer cmd.Process.Kill() + defer s.killCmd(cmd) err = try.GetRequest("http://"+haproxyIP+":81/whoami", 500*time.Millisecond, try.StatusCodeIs(http.StatusOK), @@ -77,7 +77,7 @@ func (s *ProxyProtocolSuite) TestProxyProtocolNotTrusted(c *check.C) { defer display(c) err := cmd.Start() c.Assert(err, checker.IsNil) - defer cmd.Process.Kill() + defer s.killCmd(cmd) err = try.GetRequest("http://"+haproxyIP+"/whoami", 500*time.Millisecond, try.StatusCodeIs(http.StatusOK), @@ -99,7 +99,7 @@ func (s *ProxyProtocolSuite) TestProxyProtocolV2NotTrusted(c *check.C) { defer display(c) err := cmd.Start() c.Assert(err, checker.IsNil) - defer cmd.Process.Kill() + defer s.killCmd(cmd) err = try.GetRequest("http://"+haproxyIP+":81/whoami", 500*time.Millisecond, try.StatusCodeIs(http.StatusOK), diff --git a/integration/ratelimit_test.go b/integration/ratelimit_test.go index 505e57b1b..72dcc289e 100644 --- a/integration/ratelimit_test.go +++ b/integration/ratelimit_test.go @@ -32,7 +32,7 @@ func (s *RateLimitSuite) TestSimpleConfiguration(c *check.C) { defer display(c) err := cmd.Start() c.Assert(err, checker.IsNil) - defer cmd.Process.Kill() + defer s.killCmd(cmd) err = try.GetRequest("http://127.0.0.1:8080/api/rawdata", 1*time.Second, try.BodyContains("ratelimit")) c.Assert(err, checker.IsNil) diff --git a/integration/redis_test.go b/integration/redis_test.go index 6084a9014..f601ca35a 100644 --- a/integration/redis_test.go +++ b/integration/redis_test.go @@ -118,7 +118,7 @@ func (s *RedisSuite) TestSimpleConfiguration(c *check.C) { defer display(c) err := cmd.Start() c.Assert(err, checker.IsNil) - defer cmd.Process.Kill() + defer s.killCmd(cmd) // wait for traefik err = try.GetRequest("http://127.0.0.1:8080/api/rawdata", 2*time.Second, diff --git a/integration/rest_test.go b/integration/rest_test.go index ae79eb8e2..55ce57af9 100644 --- a/integration/rest_test.go +++ b/integration/rest_test.go @@ -28,7 +28,7 @@ func (s *RestSuite) TestSimpleConfigurationInsecure(c *check.C) { defer display(c) err := cmd.Start() c.Assert(err, checker.IsNil) - defer cmd.Process.Kill() + defer s.killCmd(cmd) // wait for Traefik err = try.GetRequest("http://127.0.0.1:8080/api/rawdata", 1000*time.Millisecond, try.BodyContains("rest@internal")) @@ -126,7 +126,7 @@ func (s *RestSuite) TestSimpleConfiguration(c *check.C) { defer display(c) err := cmd.Start() c.Assert(err, checker.IsNil) - defer cmd.Process.Kill() + defer s.killCmd(cmd) // Expected a 404 as we did not configure anything. err = try.GetRequest("http://127.0.0.1:8000/", 1000*time.Millisecond, try.StatusCodeIs(http.StatusNotFound)) diff --git a/integration/retry_test.go b/integration/retry_test.go index 15a3dcaaa..c270bfa7e 100644 --- a/integration/retry_test.go +++ b/integration/retry_test.go @@ -29,7 +29,7 @@ func (s *RetrySuite) TestRetry(c *check.C) { defer display(c) err := cmd.Start() c.Assert(err, checker.IsNil) - defer cmd.Process.Kill() + defer s.killCmd(cmd) err = try.GetRequest("http://127.0.0.1:8080/api/rawdata", 60*time.Second, try.BodyContains("PathPrefix(`/`)")) c.Assert(err, checker.IsNil) @@ -51,7 +51,7 @@ func (s *RetrySuite) TestRetryWebsocket(c *check.C) { defer display(c) err := cmd.Start() c.Assert(err, checker.IsNil) - defer cmd.Process.Kill() + defer s.killCmd(cmd) err = try.GetRequest("http://127.0.0.1:8080/api/rawdata", 60*time.Second, try.BodyContains("PathPrefix(`/`)")) c.Assert(err, checker.IsNil) diff --git a/integration/simple_test.go b/integration/simple_test.go index b960846fc..d5cbc09a9 100644 --- a/integration/simple_test.go +++ b/integration/simple_test.go @@ -28,7 +28,7 @@ func (s *SimpleSuite) TestInvalidConfigShouldFail(c *check.C) { err := cmd.Start() c.Assert(err, checker.IsNil) - defer cmd.Process.Kill() + defer s.killCmd(cmd) err = try.Do(500*time.Millisecond, func() error { expected := "Near line 0 (last key parsed ''): bare keys cannot contain '{'" @@ -48,7 +48,7 @@ func (s *SimpleSuite) TestSimpleDefaultConfig(c *check.C) { err := cmd.Start() c.Assert(err, checker.IsNil) - defer cmd.Process.Kill() + defer s.killCmd(cmd) // TODO validate : run on 80 // Expected a 404 as we did not configure anything @@ -61,7 +61,7 @@ func (s *SimpleSuite) TestWithWebConfig(c *check.C) { err := cmd.Start() c.Assert(err, checker.IsNil) - defer cmd.Process.Kill() + defer s.killCmd(cmd) err = try.GetRequest("http://127.0.0.1:8080/api/rawdata", 1*time.Second, try.StatusCodeIs(http.StatusOK)) c.Assert(err, checker.IsNil) @@ -72,7 +72,7 @@ func (s *SimpleSuite) TestPrintHelp(c *check.C) { err := cmd.Start() c.Assert(err, checker.IsNil) - defer cmd.Process.Kill() + defer s.killCmd(cmd) err = try.Do(500*time.Millisecond, func() error { expected := "Usage:" @@ -106,7 +106,7 @@ func (s *SimpleSuite) TestRequestAcceptGraceTimeout(c *check.C) { defer display(c) err := cmd.Start() c.Assert(err, checker.IsNil) - defer cmd.Process.Kill() + defer s.killCmd(cmd) // Wait for Traefik to turn ready. err = try.GetRequest("http://127.0.0.1:8000/", 2*time.Second, try.StatusCodeIs(http.StatusNotFound)) @@ -169,7 +169,7 @@ func (s *SimpleSuite) TestCustomPingTerminationStatusCode(c *check.C) { err := cmd.Start() c.Assert(err, checker.IsNil) - defer cmd.Process.Kill() + defer s.killCmd(cmd) // Wait for Traefik to turn ready. err = try.GetRequest("http://127.0.0.1:8001/", 2*time.Second, try.StatusCodeIs(http.StatusNotFound)) @@ -207,7 +207,7 @@ func (s *SimpleSuite) TestStatsWithMultipleEntryPoint(c *check.C) { err := cmd.Start() c.Assert(err, checker.IsNil) - defer cmd.Process.Kill() + defer s.killCmd(cmd) err = try.GetRequest("http://127.0.0.1:8080/api", 1*time.Second, try.StatusCodeIs(http.StatusOK)) c.Assert(err, checker.IsNil) @@ -238,7 +238,7 @@ func (s *SimpleSuite) TestNoAuthOnPing(c *check.C) { err := cmd.Start() c.Assert(err, checker.IsNil) - defer cmd.Process.Kill() + defer s.killCmd(cmd) err = try.GetRequest("http://127.0.0.1:8001/api/rawdata", 2*time.Second, try.StatusCodeIs(http.StatusUnauthorized)) c.Assert(err, checker.IsNil) @@ -256,7 +256,7 @@ func (s *SimpleSuite) TestDefaultEntryPointHTTP(c *check.C) { err := cmd.Start() c.Assert(err, checker.IsNil) - defer cmd.Process.Kill() + defer s.killCmd(cmd) err = try.GetRequest("http://127.0.0.1:8080/api/rawdata", 1*time.Second, try.BodyContains("PathPrefix")) c.Assert(err, checker.IsNil) @@ -274,7 +274,7 @@ func (s *SimpleSuite) TestWithNonExistingEntryPoint(c *check.C) { err := cmd.Start() c.Assert(err, checker.IsNil) - defer cmd.Process.Kill() + defer s.killCmd(cmd) err = try.GetRequest("http://127.0.0.1:8080/api/rawdata", 1*time.Second, try.BodyContains("PathPrefix")) c.Assert(err, checker.IsNil) @@ -292,7 +292,7 @@ func (s *SimpleSuite) TestMetricsPrometheusDefaultEntryPoint(c *check.C) { err := cmd.Start() c.Assert(err, checker.IsNil) - defer cmd.Process.Kill() + defer s.killCmd(cmd) err = try.GetRequest("http://127.0.0.1:8080/api/rawdata", 1*time.Second, try.BodyContains("PathPrefix")) c.Assert(err, checker.IsNil) @@ -320,7 +320,7 @@ func (s *SimpleSuite) TestMultipleProviderSameBackendName(c *check.C) { err := cmd.Start() c.Assert(err, checker.IsNil) - defer cmd.Process.Kill() + defer s.killCmd(cmd) err = try.GetRequest("http://127.0.0.1:8080/api/rawdata", 1*time.Second, try.BodyContains("PathPrefix")) c.Assert(err, checker.IsNil) @@ -341,7 +341,7 @@ func (s *SimpleSuite) TestIPStrategyWhitelist(c *check.C) { err := cmd.Start() c.Assert(err, checker.IsNil) - defer cmd.Process.Kill() + defer s.killCmd(cmd) err = try.GetRequest("http://127.0.0.1:8080/api/rawdata", 2*time.Second, try.BodyContains("override")) c.Assert(err, checker.IsNil) @@ -409,7 +409,7 @@ func (s *SimpleSuite) TestXForwardedHeaders(c *check.C) { err := cmd.Start() c.Assert(err, checker.IsNil) - defer cmd.Process.Kill() + defer s.killCmd(cmd) err = try.GetRequest("http://127.0.0.1:8080/api/rawdata", 2*time.Second, try.BodyContains("override.remoteaddr.whitelist.docker.local")) @@ -444,7 +444,7 @@ func (s *SimpleSuite) TestMultiProvider(c *check.C) { err := cmd.Start() c.Assert(err, checker.IsNil) - defer cmd.Process.Kill() + defer s.killCmd(cmd) err = try.GetRequest("http://127.0.0.1:8080/api/rawdata", 1000*time.Millisecond, try.BodyContains("service")) c.Assert(err, checker.IsNil) @@ -495,7 +495,7 @@ func (s *SimpleSuite) TestSimpleConfigurationHostRequestTrailingPeriod(c *check. err := cmd.Start() c.Assert(err, checker.IsNil) - defer cmd.Process.Kill() + defer s.killCmd(cmd) testCases := []struct { desc string @@ -539,7 +539,7 @@ func (s *SimpleSuite) TestRouterConfigErrors(c *check.C) { err := cmd.Start() c.Assert(err, checker.IsNil) - defer cmd.Process.Kill() + defer s.killCmd(cmd) // All errors err = try.GetRequest("http://127.0.0.1:8080/api/http/routers", 1000*time.Millisecond, try.BodyContains(`["middleware \"unknown@file\" does not exist","found different TLS options for routers on the same host snitest.net, so using the default TLS options instead"]`)) @@ -567,7 +567,7 @@ func (s *SimpleSuite) TestServiceConfigErrors(c *check.C) { err := cmd.Start() c.Assert(err, checker.IsNil) - defer cmd.Process.Kill() + defer s.killCmd(cmd) err = try.GetRequest("http://127.0.0.1:8080/api/http/services", 1000*time.Millisecond, try.BodyContains(`["the service \"service1@file\" does not have any type defined"]`)) c.Assert(err, checker.IsNil) @@ -588,7 +588,7 @@ func (s *SimpleSuite) TestTCPRouterConfigErrors(c *check.C) { err := cmd.Start() c.Assert(err, checker.IsNil) - defer cmd.Process.Kill() + defer s.killCmd(cmd) // router3 has an error because it uses an unknown entrypoint err = try.GetRequest("http://127.0.0.1:8080/api/tcp/routers/router3@file", 1000*time.Millisecond, try.BodyContains(`entryPoint \"unknown-entrypoint\" doesn't exist`, "no valid entryPoint for this router")) @@ -608,7 +608,7 @@ func (s *SimpleSuite) TestTCPServiceConfigErrors(c *check.C) { err := cmd.Start() c.Assert(err, checker.IsNil) - defer cmd.Process.Kill() + defer s.killCmd(cmd) err = try.GetRequest("http://127.0.0.1:8080/api/tcp/services", 1000*time.Millisecond, try.BodyContains(`["the service \"service1@file\" does not have any type defined"]`)) c.Assert(err, checker.IsNil) @@ -629,7 +629,7 @@ func (s *SimpleSuite) TestUDPRouterConfigErrors(c *check.C) { err := cmd.Start() c.Assert(err, checker.IsNil) - defer cmd.Process.Kill() + defer s.killCmd(cmd) err = try.GetRequest("http://127.0.0.1:8080/api/udp/routers/router3@file", 1000*time.Millisecond, try.BodyContains(`entryPoint \"unknown-entrypoint\" doesn't exist`, "no valid entryPoint for this router")) c.Assert(err, checker.IsNil) @@ -644,7 +644,7 @@ func (s *SimpleSuite) TestUDPServiceConfigErrors(c *check.C) { err := cmd.Start() c.Assert(err, checker.IsNil) - defer cmd.Process.Kill() + defer s.killCmd(cmd) err = try.GetRequest("http://127.0.0.1:8080/api/udp/services", 1000*time.Millisecond, try.BodyContains(`["the udp service \"service1@file\" does not have any type defined"]`)) c.Assert(err, checker.IsNil) @@ -674,7 +674,7 @@ func (s *SimpleSuite) TestWRR(c *check.C) { err := cmd.Start() c.Assert(err, checker.IsNil) - defer cmd.Process.Kill() + defer s.killCmd(cmd) err = try.GetRequest("http://127.0.0.1:8080/api/http/services", 1000*time.Millisecond, try.BodyContains("service1", "service2")) c.Assert(err, checker.IsNil) @@ -721,7 +721,7 @@ func (s *SimpleSuite) TestWRRSticky(c *check.C) { err := cmd.Start() c.Assert(err, checker.IsNil) - defer cmd.Process.Kill() + defer s.killCmd(cmd) err = try.GetRequest("http://127.0.0.1:8080/api/http/services", 1000*time.Millisecond, try.BodyContains("service1", "service2")) c.Assert(err, checker.IsNil) @@ -785,7 +785,7 @@ func (s *SimpleSuite) TestMirror(c *check.C) { err := cmd.Start() c.Assert(err, checker.IsNil) - defer cmd.Process.Kill() + defer s.killCmd(cmd) err = try.GetRequest("http://127.0.0.1:8080/api/http/services", 1000*time.Millisecond, try.BodyContains("mirror1", "mirror2", "service1")) c.Assert(err, checker.IsNil) @@ -865,7 +865,7 @@ func (s *SimpleSuite) TestMirrorWithBody(c *check.C) { err = cmd.Start() c.Assert(err, checker.IsNil) - defer cmd.Process.Kill() + defer s.killCmd(cmd) err = try.GetRequest("http://127.0.0.1:8080/api/http/services", 1000*time.Millisecond, try.BodyContains("mirror1", "mirror2", "service1")) c.Assert(err, checker.IsNil) @@ -892,8 +892,8 @@ func (s *SimpleSuite) TestMirrorWithBody(c *check.C) { atomic.StoreInt32(&countMirror2, 0) req, err = http.NewRequest(http.MethodGet, "http://127.0.0.1:8000/whoamiWithMaxBody", bytes.NewBuffer(body5)) - req.Header.Set("Size", "5") c.Assert(err, checker.IsNil) + req.Header.Set("Size", "5") for i := 0; i < 10; i++ { response, err := http.DefaultClient.Do(req) c.Assert(err, checker.IsNil) @@ -913,8 +913,8 @@ func (s *SimpleSuite) TestMirrorWithBody(c *check.C) { atomic.StoreInt32(&countMirror2, 0) req, err = http.NewRequest(http.MethodGet, "http://127.0.0.1:8000/whoamiWithMaxBody", bytes.NewBuffer(body20)) - req.Header.Set("Size", "20") c.Assert(err, checker.IsNil) + req.Header.Set("Size", "20") for i := 0; i < 10; i++ { response, err := http.DefaultClient.Do(req) c.Assert(err, checker.IsNil) @@ -962,7 +962,7 @@ func (s *SimpleSuite) TestMirrorCanceled(c *check.C) { err := cmd.Start() c.Assert(err, checker.IsNil) - defer cmd.Process.Kill() + defer s.killCmd(cmd) err = try.GetRequest("http://127.0.0.1:8080/api/http/services", 1000*time.Millisecond, try.BodyContains("mirror1", "mirror2", "service1")) c.Assert(err, checker.IsNil) @@ -998,7 +998,7 @@ func (s *SimpleSuite) TestSecureAPI(c *check.C) { err := cmd.Start() c.Assert(err, checker.IsNil) - defer cmd.Process.Kill() + defer s.killCmd(cmd) err = try.GetRequest("http://127.0.0.1:8000/secure/api/rawdata", 1*time.Second, try.StatusCodeIs(http.StatusOK)) c.Assert(err, checker.IsNil) @@ -1030,10 +1030,10 @@ func (s *SimpleSuite) TestContentTypeDisableAutoDetect(c *check.C) { rw.WriteHeader(http.StatusOK) - bytes, err := ioutil.ReadFile("fixtures/test.pdf") + data, err := ioutil.ReadFile("fixtures/test.pdf") c.Assert(err, checker.IsNil) - _, err = rw.Write(bytes) + _, err = rw.Write(data) c.Assert(err, checker.IsNil) } })) @@ -1052,7 +1052,7 @@ func (s *SimpleSuite) TestContentTypeDisableAutoDetect(c *check.C) { err := cmd.Start() c.Assert(err, check.IsNil) - defer cmd.Process.Kill() + defer s.killCmd(cmd) // wait for traefik err = try.GetRequest("http://127.0.0.1:8080/api/rawdata", 10*time.Second, try.BodyContains("127.0.0.1")) diff --git a/integration/tcp_test.go b/integration/tcp_test.go index 0f87d2103..16b1c8e41 100644 --- a/integration/tcp_test.go +++ b/integration/tcp_test.go @@ -30,7 +30,7 @@ func (s *TCPSuite) TestMixed(c *check.C) { err := cmd.Start() c.Assert(err, checker.IsNil) - defer cmd.Process.Kill() + defer s.killCmd(cmd) 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) @@ -80,7 +80,7 @@ func (s *TCPSuite) TestTLSOptions(c *check.C) { err := cmd.Start() c.Assert(err, checker.IsNil) - defer cmd.Process.Kill() + defer s.killCmd(cmd) 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) @@ -110,7 +110,7 @@ func (s *TCPSuite) TestNonTLSFallback(c *check.C) { err := cmd.Start() c.Assert(err, checker.IsNil) - defer cmd.Process.Kill() + defer s.killCmd(cmd) 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) @@ -144,7 +144,7 @@ func (s *TCPSuite) TestNonTlsTcp(c *check.C) { err := cmd.Start() c.Assert(err, checker.IsNil) - defer cmd.Process.Kill() + defer s.killCmd(cmd) 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) @@ -164,7 +164,7 @@ func (s *TCPSuite) TestCatchAllNoTLS(c *check.C) { err := cmd.Start() c.Assert(err, checker.IsNil) - defer cmd.Process.Kill() + defer s.killCmd(cmd) 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) @@ -184,7 +184,7 @@ func (s *TCPSuite) TestCatchAllNoTLSWithHTTPS(c *check.C) { err := cmd.Start() c.Assert(err, checker.IsNil) - defer cmd.Process.Kill() + defer s.killCmd(cmd) 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) @@ -276,7 +276,7 @@ func (s *TCPSuite) TestWRR(c *check.C) { err := cmd.Start() c.Assert(err, checker.IsNil) - defer cmd.Process.Kill() + defer s.killCmd(cmd) 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) diff --git a/integration/timeout_test.go b/integration/timeout_test.go index edca51dc8..4dce1df6e 100644 --- a/integration/timeout_test.go +++ b/integration/timeout_test.go @@ -29,7 +29,7 @@ func (s *TimeoutSuite) TestForwardingTimeouts(c *check.C) { defer display(c) err := cmd.Start() c.Assert(err, checker.IsNil) - defer cmd.Process.Kill() + defer s.killCmd(cmd) err = try.GetRequest("http://127.0.0.1:8080/api/rawdata", 60*time.Second, try.BodyContains("Path(`/dialTimeout`)")) c.Assert(err, checker.IsNil) diff --git a/integration/tls_client_headers_test.go b/integration/tls_client_headers_test.go index f58417c98..490568749 100644 --- a/integration/tls_client_headers_test.go +++ b/integration/tls_client_headers_test.go @@ -48,7 +48,7 @@ func (s *TLSClientHeadersSuite) TestTLSClientHeaders(c *check.C) { defer display(c) err = cmd.Start() c.Assert(err, checker.IsNil) - defer cmd.Process.Kill() + defer s.killCmd(cmd) err = try.GetRequest("http://127.0.0.1:8080/api/rawdata", 2*time.Second, try.BodyContains("PathPrefix(`/`)")) c.Assert(err, checker.IsNil) diff --git a/integration/tracing_test.go b/integration/tracing_test.go index f6cecb8a7..d15bf45bd 100644 --- a/integration/tracing_test.go +++ b/integration/tracing_test.go @@ -55,7 +55,7 @@ func (s *TracingSuite) TestZipkinRateLimit(c *check.C) { defer display(c) err := cmd.Start() c.Assert(err, checker.IsNil) - defer cmd.Process.Kill() + defer s.killCmd(cmd) // wait for traefik err = try.GetRequest("http://127.0.0.1:8080/api/rawdata", time.Second, try.BodyContains("basic-auth")) @@ -105,7 +105,7 @@ func (s *TracingSuite) TestZipkinRetry(c *check.C) { defer display(c) err := cmd.Start() c.Assert(err, checker.IsNil) - defer cmd.Process.Kill() + defer s.killCmd(cmd) // wait for traefik err = try.GetRequest("http://127.0.0.1:8080/api/rawdata", time.Second, try.BodyContains("basic-auth")) @@ -132,7 +132,7 @@ func (s *TracingSuite) TestZipkinAuth(c *check.C) { defer display(c) err := cmd.Start() c.Assert(err, checker.IsNil) - defer cmd.Process.Kill() + defer s.killCmd(cmd) // wait for traefik err = try.GetRequest("http://127.0.0.1:8080/api/rawdata", time.Second, try.BodyContains("basic-auth")) @@ -169,7 +169,7 @@ func (s *TracingSuite) TestJaegerRateLimit(c *check.C) { defer display(c) err := cmd.Start() c.Assert(err, checker.IsNil) - defer cmd.Process.Kill() + defer s.killCmd(cmd) // wait for traefik err = try.GetRequest("http://127.0.0.1:8080/api/rawdata", time.Second, try.BodyContains("basic-auth")) @@ -219,7 +219,7 @@ func (s *TracingSuite) TestJaegerRetry(c *check.C) { defer display(c) err := cmd.Start() c.Assert(err, checker.IsNil) - defer cmd.Process.Kill() + defer s.killCmd(cmd) // wait for traefik err = try.GetRequest("http://127.0.0.1:8080/api/rawdata", time.Second, try.BodyContains("basic-auth")) @@ -247,7 +247,7 @@ func (s *TracingSuite) TestJaegerAuth(c *check.C) { defer display(c) err := cmd.Start() c.Assert(err, checker.IsNil) - defer cmd.Process.Kill() + defer s.killCmd(cmd) // wait for traefik err = try.GetRequest("http://127.0.0.1:8080/api/rawdata", time.Second, try.BodyContains("basic-auth")) @@ -275,7 +275,7 @@ func (s *TracingSuite) TestJaegerCustomHeader(c *check.C) { defer display(c) err := cmd.Start() c.Assert(err, checker.IsNil) - defer cmd.Process.Kill() + defer s.killCmd(cmd) // wait for traefik err = try.GetRequest("http://127.0.0.1:8080/api/rawdata", time.Second, try.BodyContains("basic-auth")) @@ -302,7 +302,7 @@ func (s *TracingSuite) TestJaegerAuthCollector(c *check.C) { defer display(c) err := cmd.Start() c.Assert(err, checker.IsNil) - defer cmd.Process.Kill() + defer s.killCmd(cmd) // wait for traefik err = try.GetRequest("http://127.0.0.1:8080/api/rawdata", time.Second, try.BodyContains("basic-auth")) diff --git a/integration/udp_test.go b/integration/udp_test.go index 459c96483..837e0c238 100644 --- a/integration/udp_test.go +++ b/integration/udp_test.go @@ -70,7 +70,7 @@ func (s *UDPSuite) TestWRR(c *check.C) { err := cmd.Start() c.Assert(err, checker.IsNil) - defer cmd.Process.Kill() + defer s.killCmd(cmd) err = try.GetRequest("http://127.0.0.1:8080/api/rawdata", 5*time.Second, try.StatusCodeIs(http.StatusOK), try.BodyContains("whoami-a")) c.Assert(err, checker.IsNil) diff --git a/integration/websocket_test.go b/integration/websocket_test.go index 65ce663cb..9fec4a209 100644 --- a/integration/websocket_test.go +++ b/integration/websocket_test.go @@ -54,7 +54,7 @@ func (s *WebsocketSuite) TestBase(c *check.C) { err := cmd.Start() c.Assert(err, check.IsNil) - defer cmd.Process.Kill() + defer s.killCmd(cmd) // wait for traefik err = try.GetRequest("http://127.0.0.1:8080/api/rawdata", 10*time.Second, try.BodyContains("127.0.0.1")) @@ -104,7 +104,7 @@ func (s *WebsocketSuite) TestWrongOrigin(c *check.C) { err := cmd.Start() c.Assert(err, check.IsNil) - defer cmd.Process.Kill() + defer s.killCmd(cmd) // wait for traefik err = try.GetRequest("http://127.0.0.1:8080/api/rawdata", 10*time.Second, try.BodyContains("127.0.0.1")) @@ -154,7 +154,7 @@ func (s *WebsocketSuite) TestOrigin(c *check.C) { err := cmd.Start() c.Assert(err, check.IsNil) - defer cmd.Process.Kill() + defer s.killCmd(cmd) // wait for traefik err = try.GetRequest("http://127.0.0.1:8080/api/rawdata", 10*time.Second, try.BodyContains("127.0.0.1")) @@ -214,7 +214,7 @@ func (s *WebsocketSuite) TestWrongOriginIgnoredByServer(c *check.C) { err := cmd.Start() c.Assert(err, check.IsNil) - defer cmd.Process.Kill() + defer s.killCmd(cmd) // wait for traefik err = try.GetRequest("http://127.0.0.1:8080/api/rawdata", 10*time.Second, try.BodyContains("127.0.0.1")) @@ -271,7 +271,7 @@ func (s *WebsocketSuite) TestSSLTermination(c *check.C) { err := cmd.Start() c.Assert(err, check.IsNil) - defer cmd.Process.Kill() + defer s.killCmd(cmd) // wait for traefik err = try.GetRequest("http://127.0.0.1:8080/api/rawdata", 10*time.Second, try.BodyContains("127.0.0.1")) @@ -333,7 +333,7 @@ func (s *WebsocketSuite) TestBasicAuth(c *check.C) { err := cmd.Start() c.Assert(err, check.IsNil) - defer cmd.Process.Kill() + defer s.killCmd(cmd) // wait for traefik err = try.GetRequest("http://127.0.0.1:8080/api/rawdata", 10*time.Second, try.BodyContains("127.0.0.1")) @@ -377,7 +377,7 @@ func (s *WebsocketSuite) TestSpecificResponseFromBackend(c *check.C) { err := cmd.Start() c.Assert(err, check.IsNil) - defer cmd.Process.Kill() + defer s.killCmd(cmd) // wait for traefik err = try.GetRequest("http://127.0.0.1:8080/api/rawdata", 10*time.Second, try.BodyContains("127.0.0.1")) @@ -422,7 +422,7 @@ func (s *WebsocketSuite) TestURLWithURLEncodedChar(c *check.C) { err := cmd.Start() c.Assert(err, check.IsNil) - defer cmd.Process.Kill() + defer s.killCmd(cmd) // wait for traefik err = try.GetRequest("http://127.0.0.1:8080/api/rawdata", 10*time.Second, try.BodyContains("127.0.0.1")) @@ -477,7 +477,7 @@ func (s *WebsocketSuite) TestSSLhttp2(c *check.C) { err := cmd.Start() c.Assert(err, check.IsNil) - defer cmd.Process.Kill() + defer s.killCmd(cmd) // wait for traefik err = try.GetRequest("http://127.0.0.1:8080/api/rawdata", 10*time.Second, try.BodyContains("127.0.0.1")) @@ -536,7 +536,7 @@ func (s *WebsocketSuite) TestHeaderAreForwared(c *check.C) { err := cmd.Start() c.Assert(err, check.IsNil) - defer cmd.Process.Kill() + defer s.killCmd(cmd) // wait for traefik err = try.GetRequest("http://127.0.0.1:8080/api/rawdata", 10*time.Second, try.BodyContains("127.0.0.1")) diff --git a/integration/zk_test.go b/integration/zk_test.go index 6d718ac2e..5ab71151f 100644 --- a/integration/zk_test.go +++ b/integration/zk_test.go @@ -118,7 +118,7 @@ func (s *ZookeeperSuite) TestSimpleConfiguration(c *check.C) { defer display(c) err := cmd.Start() c.Assert(err, checker.IsNil) - defer cmd.Process.Kill() + defer s.killCmd(cmd) // wait for traefik err = try.GetRequest("http://127.0.0.1:8080/api/rawdata", 2*time.Second,