diff --git a/deploy/tests/e2e/crd-tcp/suite_test.go b/deploy/tests/e2e/crd-tcp/suite_test.go index 0fc69018..ff08c0c5 100644 --- a/deploy/tests/e2e/crd-tcp/suite_test.go +++ b/deploy/tests/e2e/crd-tcp/suite_test.go @@ -21,6 +21,9 @@ import ( "io" "strings" + "github.com/google/go-cmp/cmp" + "github.com/google/go-cmp/cmp/cmpopts" + "github.com/stretchr/testify/suite" parser "github.com/haproxytech/client-native/v5/config-parser" @@ -81,7 +84,19 @@ func (suite *CRDTCPSuite) BeforeTest(suiteName, testName string) { func (suite *CRDTCPSuite) checkFrontend(p parser.Parser, frontendName, param string, value common.ParserData) { v, err := p.Get(parser.Frontends, frontendName, param) suite.Require().NoError(err, "Could not get Haproxy config parser Frontend %s param %s", frontendName, param) - suite.Equal(value, v, fmt.Sprintf("Frontend param %s should be equal to %v but is %v", param, value, v)) + + // Sort functions for map[string]XXX + sortBinds := cmpopts.SortSlices(func(a, b types.Bind) bool { + return a.Path < b.Path + }) + areEqual := cmp.Equal(v, value, sortBinds) + + if !areEqual { + diff := cmp.Diff(v, value, sortBinds) + suite.T().Log(diff) + } + + suite.Equal(areEqual, true, fmt.Sprintf("Frontend param %s should be equal to %v but is %v", param, value, v)) } func (suite *CRDTCPSuite) checkBackend(p parser.Parser, backendName, param string, value common.ParserData) { diff --git a/deploy/tests/integration/config-snippet/suite_test.go b/deploy/tests/integration/config-snippet/suite_test.go index 3d096006..578e7d41 100644 --- a/deploy/tests/integration/config-snippet/suite_test.go +++ b/deploy/tests/integration/config-snippet/suite_test.go @@ -15,6 +15,7 @@ package configsnippet_test import ( + "os" "testing" "github.com/haproxytech/kubernetes-ingress/deploy/tests/integration" @@ -44,6 +45,8 @@ func (suite *DisableConfigSnippetSuite) BeforeTest(suiteName, testName string) { suite.BaseSuite.BeforeTest(suiteName, testName) // Add any needed update to the controller setting // by updating suite.TestControllers[suite.T().Name()].XXXXX + os.Unsetenv("POD_NAME") + os.Unsetenv("POD_NAMESPACE") testController := suite.TestControllers[suite.T().Name()] testController.OSArgs.ConfigMap.Name = configMapName testController.OSArgs.ConfigMap.Namespace = configMapNamespace diff --git a/deploy/tests/integration/pod-maxconn/suite_test.go b/deploy/tests/integration/pod-maxconn/suite_test.go index e9b5af88..e2566726 100644 --- a/deploy/tests/integration/pod-maxconn/suite_test.go +++ b/deploy/tests/integration/pod-maxconn/suite_test.go @@ -15,6 +15,7 @@ package podmaxconn import ( + "os" "testing" "github.com/haproxytech/kubernetes-ingress/deploy/tests/integration" @@ -44,6 +45,8 @@ func (suite *PodMaxConnSuite) BeforeTest(suiteName, testName string) { suite.BaseSuite.BeforeTest(suiteName, testName) // Add any needed update to the controller setting // by updating suite.TestControllers[suite.T().Name()].XXXXX + os.Unsetenv("POD_NAME") + os.Unsetenv("POD_NAMESPACE") testController := suite.TestControllers[suite.T().Name()] testController.OSArgs.ConfigMap.Name = configMapName testController.OSArgs.ConfigMap.Namespace = configMapNamespace diff --git a/deploy/tests/integration/timeout-server/suite_test.go b/deploy/tests/integration/timeout-server/suite_test.go index 4a405755..0607300d 100644 --- a/deploy/tests/integration/timeout-server/suite_test.go +++ b/deploy/tests/integration/timeout-server/suite_test.go @@ -15,6 +15,7 @@ package timeoutserver import ( + "os" "testing" "github.com/haproxytech/kubernetes-ingress/deploy/tests/integration" @@ -44,6 +45,8 @@ func (suite *TimeoutServerSuite) BeforeTest(suiteName, testName string) { suite.BaseSuite.BeforeTest(suiteName, testName) // Add any needed update to the controller setting // by updating suite.TestControllers[suite.T().Name()].XXXXX + os.Unsetenv("POD_NAME") + os.Unsetenv("POD_NAMESPACE") testController := suite.TestControllers[suite.T().Name()] testController.OSArgs.ConfigMap.Name = configMapName testController.OSArgs.ConfigMap.Namespace = configMapNamespace diff --git a/deploy/tests/ut/acls/suite_test.go b/deploy/tests/ut/acls/suite_test.go index 9b13d4f1..5be4c03b 100644 --- a/deploy/tests/ut/acls/suite_test.go +++ b/deploy/tests/ut/acls/suite_test.go @@ -67,6 +67,10 @@ func (suite *ACLSuite) BeforeTest(suiteName, testName string) { suite.T().Logf("temporary configuration dir %s", suite.test.TempDir) } +func (suite *ACLSuite) TearDownSuite() { + os.Unsetenv("POD_NAME") +} + func (suite *ACLSuite) UseACLFixture() (eventChan chan k8ssync.SyncDataEvent) { var osArgs utils.OSArgs os.Args = []string{os.Args[0], "-e", "-t", "--config-dir=" + suite.test.TempDir} diff --git a/deploy/tests/ut/httprequests/suite_test.go b/deploy/tests/ut/httprequests/suite_test.go index 33ac41ac..51b53510 100644 --- a/deploy/tests/ut/httprequests/suite_test.go +++ b/deploy/tests/ut/httprequests/suite_test.go @@ -67,6 +67,10 @@ func (suite *HTTPRequestsSuite) BeforeTest(suiteName, testName string) { suite.T().Logf("temporary configuration dir %s", suite.test.TempDir) } +func (suite *HTTPRequestsSuite) TearDownSuite() { + os.Unsetenv("POD_NAME") +} + func (suite *HTTPRequestsSuite) UseHTTPRequestsFixture() (eventChan chan k8ssync.SyncDataEvent) { var osArgs utils.OSArgs os.Args = []string{os.Args[0], "-e", "-t", "--config-dir=" + suite.test.TempDir}