Skip to content

Commit b2290f9

Browse files
committed
TEST: e2e: merge DeployYamlTemplate and DeployYalm methods into
Apply
1 parent 6dd53df commit b2290f9

31 files changed

+91
-85
lines changed

deploy/tests/e2e/basic-auth/basic_auth_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import (
2424

2525
func (suite *HTTPBasicAuthSuite) Test_BasicAuth() {
2626
suite.Run("Denied", func() {
27-
suite.NoError(suite.test.DeployYamlTemplate("config/deploy.yaml.tmpl", suite.test.GetNS(), suite.tmplData))
27+
suite.NoError(suite.test.Apply("config/deploy.yaml.tmpl", suite.test.GetNS(), suite.tmplData))
2828
suite.Require().Eventually(func() bool {
2929
res, cls, err := suite.client.Do()
3030
if res == nil {

deploy/tests/e2e/canary-deployment/percentage_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ func (suite *CanaryDeploymentSuite) Test_Response_Percentage() {
2828
for _, percentage := range []int{0, 25, 100} {
2929
suite.Run(fmt.Sprintf("%d", percentage), func() {
3030
suite.tmplData.StagingRouteACL = fmt.Sprintf("rand(100) lt %d", percentage)
31-
suite.NoError(suite.test.DeployYamlTemplate("config/deploy.yaml.tmpl", suite.test.GetNS(), suite.tmplData))
31+
suite.NoError(suite.test.Apply("config/deploy.yaml.tmpl", suite.test.GetNS(), suite.tmplData))
3232
suite.Eventually(func() bool {
3333
counter := 0
3434
for i := 0; i < 10; i++ {

deploy/tests/e2e/canary-deployment/suite_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ func (suite *CanaryDeploymentSuite) SetupSuite() {
4848
}
4949
suite.client, err = e2e.NewHTTPClient(suite.tmplData.Host)
5050
suite.NoError(err)
51-
suite.Require().NoError(suite.test.DeployYamlTemplate("config/deploy.yaml.tmpl", suite.test.GetNS(), suite.tmplData))
51+
suite.Require().NoError(suite.test.Apply("config/deploy.yaml.tmpl", suite.test.GetNS(), suite.tmplData))
5252
suite.Require().Eventually(func() bool {
5353
res, cls, err := suite.client.Do()
5454
if res == nil {

deploy/tests/e2e/config-snippet/backend_cfg_snippet.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import (
2424
)
2525

2626
func (suite *ConfigSnippetSuite) TestBackendCfgSnippet() {
27-
suite.NoError(suite.test.DeployYaml("config/backend-cfg-snippet.yaml", suite.test.GetNS()))
27+
suite.NoError(suite.test.Apply("config/backend-cfg-snippet.yaml", suite.test.GetNS(), nil))
2828
suite.Eventually(func() bool {
2929
res, cls, err := suite.client.Do()
3030
if err != nil {

deploy/tests/e2e/config-snippet/frontend_cfg_snippet.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import (
2424
)
2525

2626
func (suite *ConfigSnippetSuite) TestFrontendCfgSnippet() {
27-
suite.NoError(suite.test.DeployYaml("config/configmap.yaml", "haproxy-controller"))
27+
suite.NoError(suite.test.Apply("config/configmap.yaml", "", nil))
2828
suite.Eventually(func() bool {
2929
res, cls, err := suite.client.Do()
3030
if err != nil {

deploy/tests/e2e/config-snippet/suite_test.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
package configsnippet
1818

1919
import (
20-
"os/exec"
2120
"testing"
2221

2322
"github.com/stretchr/testify/suite"
@@ -43,7 +42,7 @@ func (suite *ConfigSnippetSuite) SetupSuite() {
4342
suite.tmplData = tmplData{Host: suite.test.GetNS() + ".test"}
4443
suite.client, err = e2e.NewHTTPClient(suite.tmplData.Host)
4544
suite.NoError(err)
46-
suite.NoError(suite.test.DeployYamlTemplate("config/deploy.yaml.tmpl", suite.test.GetNS(), suite.tmplData))
45+
suite.NoError(suite.test.Apply("config/deploy.yaml.tmpl", suite.test.GetNS(), suite.tmplData))
4746
suite.Require().Eventually(func() bool {
4847
res, cls, err := suite.client.Do()
4948
if res == nil {
@@ -54,8 +53,7 @@ func (suite *ConfigSnippetSuite) SetupSuite() {
5453
return res.StatusCode == 200
5554
}, e2e.WaitDuration, e2e.TickDuration)
5655
suite.test.AddTearDown(func() error {
57-
cmd := exec.Command("kubectl", "apply", "-f", "../../config/3.configmap.yaml")
58-
return cmd.Run()
56+
return suite.test.Apply("../../config/3.configmap.yaml", "", nil)
5957
})
6058
}
6159

deploy/tests/e2e/endpoints/http_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ func (suite *EndpointsSuite) Test_HTTP_Reach() {
3131
for _, replicas := range []int{4, 8, 2, 0, 3} {
3232
suite.Run(fmt.Sprintf("%d-replicas", replicas), func() {
3333
suite.tmplData.Replicas = replicas
34-
suite.NoError(suite.test.DeployYamlTemplate("config/endpoints.yaml.tmpl", suite.test.GetNS(), suite.tmplData))
34+
suite.NoError(suite.test.Apply("config/endpoints.yaml.tmpl", suite.test.GetNS(), suite.tmplData))
3535
suite.Eventually(func() bool {
3636
counter := map[string]int{}
3737
for i := 0; i < replicas*2; i++ {

deploy/tests/e2e/endpoints/suite_test.go

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ package endpoints
1818

1919
import (
2020
"net/http"
21-
"os/exec"
2221
"testing"
2322

2423
"github.com/stretchr/testify/suite"
@@ -66,7 +65,7 @@ func (suite *EndpointsSuite) BeforeTest(suiteName, testName string) {
6665
case "Test_HTTP_Reach":
6766
suite.client, err = e2e.NewHTTPClient(suite.tmplData.Host)
6867
suite.NoError(err)
69-
suite.NoError(test.DeployYamlTemplate("config/endpoints.yaml.tmpl", test.GetNS(), suite.tmplData))
68+
suite.NoError(test.Apply("config/endpoints.yaml.tmpl", test.GetNS(), suite.tmplData))
7069
suite.Require().Eventually(func() bool {
7170
res, cls, err := suite.client.Do()
7271
if res == nil {
@@ -80,11 +79,10 @@ func (suite *EndpointsSuite) BeforeTest(suiteName, testName string) {
8079
suite.client, err = e2e.NewHTTPSClient("tcp-service.test", 32766)
8180
suite.NoError(err)
8281
suite.tmplData.Replicas = 4
83-
suite.NoError(test.DeployYamlTemplate("config/endpoints.yaml.tmpl", test.GetNS(), suite.tmplData))
84-
suite.NoError(test.DeployYaml("config/tcp.yaml", "haproxy-controller"))
82+
suite.NoError(test.Apply("config/endpoints.yaml.tmpl", test.GetNS(), suite.tmplData))
83+
suite.NoError(test.Apply("config/tcp.yaml", "", nil))
8584
test.AddTearDown(func() error {
86-
cmd := exec.Command("kubectl", "-n", "haproxy-controller", "delete", "cm", "haproxy-configmap-tcp")
87-
return cmd.Run()
85+
return suite.test.Delete("config/tcp.yaml")
8886
})
8987
suite.Require().Eventually(func() bool {
9088
res, cls, err := suite.client.Do()

deploy/tests/e2e/global-config/maxconn_test.go

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,21 +17,15 @@
1717
package globalconfig
1818

1919
import (
20-
"os/exec"
21-
2220
"github.com/haproxytech/kubernetes-ingress/deploy/tests/e2e"
2321
)
2422

2523
func (suite *GlobalConfigSuite) TestMaxconn() {
26-
cmd := exec.Command("kubectl", "apply", "-f", "config/configmap.yaml")
27-
_, err := cmd.CombinedOutput()
28-
suite.Require().NoError(err)
24+
suite.NoError(suite.test.Apply("config/configmap.yaml", "", nil))
2925
suite.maxconn = "1111"
3026
suite.Eventually(suite.checkMaxconn, e2e.WaitDuration, e2e.TickDuration)
3127

32-
cmd = exec.Command("kubectl", "apply", "-f", "../../config/3.configmap.yaml")
33-
_, err = cmd.CombinedOutput()
34-
suite.Require().NoError(err)
28+
suite.NoError(suite.test.Apply("../../config/3.configmap.yaml", "", nil))
3529
suite.maxconn = "1000"
3630
suite.Eventually(suite.checkMaxconn, e2e.WaitDuration, e2e.TickDuration)
3731
}

deploy/tests/e2e/global-config/suite_test.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,22 @@ import (
2020
"testing"
2121

2222
"github.com/stretchr/testify/suite"
23+
24+
"github.com/haproxytech/kubernetes-ingress/deploy/tests/e2e"
2325
)
2426

2527
type GlobalConfigSuite struct {
2628
suite.Suite
29+
test e2e.Test
2730
maxconn string
2831
}
2932

33+
func (suite *GlobalConfigSuite) SetupSuite() {
34+
var err error
35+
suite.test, err = e2e.NewTest()
36+
suite.NoError(err)
37+
}
38+
3039
func TestGlobalConfigSuite(t *testing.T) {
3140
suite.Run(t, new(GlobalConfigSuite))
3241
}

0 commit comments

Comments
 (0)