Skip to content

Commit 8404224

Browse files
hdurand0710Gopher Bot
authored andcommitted
CLEANUP/MINOR: Use the base function to check the map content
1 parent fec5e1c commit 8404224

5 files changed

Lines changed: 21 additions & 55 deletions

File tree

test/integration/base/base.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -650,23 +650,23 @@ var StandardMaps = []string{
650650

651651
func (b *BaseSuite) ExpectMapContents(mapFilePath, expectedMapPath string) {
652652
b.Require().Eventually(func() bool {
653-
check := b.CheckMapContents(mapFilePath, expectedMapPath)
653+
check := b.checkMapContents(mapFilePath, expectedMapPath)
654654
return check
655655
}, timeout, interval, fmt.Sprintf("maps in %s did not match expected contents", mapFilePath))
656656
}
657657

658-
func (b *BaseSuite) CheckMapContents(mapFileRelativePath, expectedMapPath string) bool {
659-
checkFile := b.CheckMapFileContents(mapFileRelativePath, expectedMapPath)
658+
func (b *BaseSuite) checkMapContents(mapFileRelativePath, expectedMapPath string) bool {
659+
checkFile := b.checkMapFileContents(mapFileRelativePath, expectedMapPath)
660660
if !checkFile {
661661
return false
662662
}
663663
if TestMapThroughRuntime {
664-
return b.CheckRuntimeMapContents(mapFileRelativePath, expectedMapPath)
664+
return b.checkRuntimeMapContents(mapFileRelativePath, expectedMapPath)
665665
}
666666
return true
667667
}
668668

669-
func (b *BaseSuite) CheckMapFileContents(mapFileRelativePath, expectedMapPath string) bool {
669+
func (b *BaseSuite) checkMapFileContents(mapFileRelativePath, expectedMapPath string) bool {
670670
b.T().Logf("Checking map [file] in %s with expected map path %s", mapFileRelativePath, expectedMapPath)
671671
for _, mapName := range StandardMaps {
672672
expectedFilePath := path.Join(expectedMapPath, mapName)
@@ -876,7 +876,7 @@ func (b *BaseSuite) ConsistentlyNoReload(oldPid string, duration time.Duration)
876876
}
877877
}
878878

879-
func (b *BaseSuite) CheckRuntimeMapContents(mapFileRelativePath, expectedMapPath string) bool {
879+
func (b *BaseSuite) checkRuntimeMapContents(mapFileRelativePath, expectedMapPath string) bool {
880880
b.T().Logf("Checking map [runtime] for %s with expected map path %s", mapFileRelativePath, expectedMapPath)
881881
socketPath := filepath.Join(b.test.HaproxyCfgDir, "haproxy-runtime-api.sock")
882882

test/integration/gateway-tls-multiple/gateway_tls_multiple_test.go

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
package gatewaytlsmultiple
1717

1818
import (
19-
"fmt"
2019
"path"
2120
"testing"
2221

@@ -81,12 +80,8 @@ func (s *GatewayTLSMultipleSuite) Test_Gateway_TLS_multiple_same_namespace_ok()
8180
// Check Maps
8281
mapFileRelativePath := "hug_http_8080"
8382
expectedMapsPath := path.Join(expectationsPath, "maps")
84-
s.Eventually(func() bool {
85-
return s.CheckMapContents(mapFileRelativePath, expectedMapsPath)
86-
}, timeout, interval, fmt.Sprintf("maps in %s did not match expected contents", mapFileRelativePath))
83+
s.ExpectMapContents(mapFileRelativePath, expectedMapsPath)
8784

8885
mapFileRelativePath = "hug_https_8443"
89-
s.Eventually(func() bool {
90-
return s.CheckMapContents(mapFileRelativePath, expectedMapsPath)
91-
}, timeout, interval, fmt.Sprintf("maps in %s did not match expected contents", mapFileRelativePath))
86+
s.ExpectMapContents(mapFileRelativePath, expectedMapsPath)
9287
}

test/integration/gateway-tls/gateway_tls_basic_test.go

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
package gatewaytls
1717

1818
import (
19-
"fmt"
2019
"path"
2120
"testing"
2221

@@ -57,14 +56,10 @@ func (s *GatewayTLSTestSuite) Test_Gateway_TLS_missingSecret() {
5756
// Check Maps
5857
mapFileRelativePath := "hug_" + s.Test().Namespace + "_gateway_http"
5958
expectedMapsPath := path.Join(expectationsPath, "maps")
60-
s.Eventually(func() bool {
61-
return s.CheckMapContents(mapFileRelativePath, expectedMapsPath)
62-
}, timeout, interval, fmt.Sprintf("maps in %s did not match expected contents", mapFileRelativePath))
59+
s.ExpectMapContents(mapFileRelativePath, expectedMapsPath)
6360

6461
mapFileRelativePath = "hug_" + s.Test().Namespace + "_gateway_https"
65-
s.Eventually(func() bool {
66-
return s.CheckMapContents(mapFileRelativePath, expectedMapsPath)
67-
}, timeout, interval, fmt.Sprintf("maps in %s did not match expected contents", mapFileRelativePath))
62+
s.ExpectMapContents(mapFileRelativePath, expectedMapsPath)
6863
}
6964

7065
func (s *GatewayTLSTestSuite) Test_Gateway_TLS_okSecret() {
@@ -88,14 +83,10 @@ func (s *GatewayTLSTestSuite) Test_Gateway_TLS_okSecret() {
8883
// Check Maps
8984
mapFileRelativePath := "hug_" + s.Test().Namespace + "_gateway_http"
9085
expectedMapsPath := path.Join(expectationsPath, "maps")
91-
s.Eventually(func() bool {
92-
return s.CheckMapContents(mapFileRelativePath, expectedMapsPath)
93-
}, timeout, interval, fmt.Sprintf("maps in %s did not match expected contents", mapFileRelativePath))
86+
s.ExpectMapContents(mapFileRelativePath, expectedMapsPath)
9487

9588
mapFileRelativePath = "hug_" + s.Test().Namespace + "_gateway_https"
96-
s.Eventually(func() bool {
97-
return s.CheckMapContents(mapFileRelativePath, expectedMapsPath)
98-
}, timeout, interval, fmt.Sprintf("maps in %s did not match expected contents", mapFileRelativePath))
89+
s.ExpectMapContents(mapFileRelativePath, expectedMapsPath)
9990
}
10091

10192
func (s *GatewayTLSTestSuite) Test_Gateway_TLS_Dynamic_ok_missing_ok_Secret() {
@@ -132,14 +123,10 @@ func (s *GatewayTLSTestSuite) Test_Gateway_TLS_Dynamic_ok_missing_ok_Secret() {
132123
// Check Maps
133124
mapFileRelativePath := "hug_" + s.Test().Namespace + "_gateway_http"
134125
expectedMapsPath := path.Join(expectationsPath, "maps")
135-
s.Eventually(func() bool {
136-
return s.CheckMapContents(mapFileRelativePath, expectedMapsPath)
137-
}, timeout, interval, fmt.Sprintf("maps in %s did not match expected contents", mapFileRelativePath))
126+
s.ExpectMapContents(mapFileRelativePath, expectedMapsPath)
138127

139128
mapFileRelativePath = "hug_" + s.Test().Namespace + "_gateway_https"
140-
s.Eventually(func() bool {
141-
return s.CheckMapContents(mapFileRelativePath, expectedMapsPath)
142-
}, timeout, interval, fmt.Sprintf("maps in %s did not match expected contents", mapFileRelativePath))
129+
s.ExpectMapContents(mapFileRelativePath, expectedMapsPath)
143130
}
144131

145132
func (s *GatewayTLSTestSuite) deleteSecret(name string) *v1.Secret {

test/integration/gateway/gateway_test.go

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
package gateway
1717

1818
import (
19-
"fmt"
2019
"path"
2120
"testing"
2221
"time"
@@ -60,9 +59,7 @@ func (s *GatewayTestSuite) Test_Gateway_InvalidRef() {
6059
// Check Maps
6160
mapFileRelativePath := "hug_" + s.Test().Namespace + "_gateway_http"
6261
expectedMapsPath := path.Join(expectationsPath, "maps")
63-
s.Eventually(func() bool {
64-
return s.CheckMapContents(mapFileRelativePath, expectedMapsPath)
65-
}, timeout, interval, fmt.Sprintf("maps in %s did not match expected contents", mapFileRelativePath))
62+
s.ExpectMapContents(mapFileRelativePath, expectedMapsPath)
6663
}
6764

6865
func (s *GatewayTestSuite) Test_Gateway_InvalidHTTPS() {
@@ -86,9 +83,7 @@ func (s *GatewayTestSuite) Test_Gateway_InvalidHTTPS() {
8683
// Check Maps
8784
mapFileRelativePath := "hug_" + s.Test().Namespace + "_gateway_http"
8885
expectedMapsPath := path.Join(expectationsPath, "maps")
89-
s.Eventually(func() bool {
90-
return s.CheckMapContents(mapFileRelativePath, expectedMapsPath)
91-
}, timeout, interval, fmt.Sprintf("maps in %s did not match expected contents", mapFileRelativePath))
86+
s.ExpectMapContents(mapFileRelativePath, expectedMapsPath)
9287
}
9388

9489
func (s *GatewayTestSuite) Test_Gateway_validRef() {
@@ -112,9 +107,7 @@ func (s *GatewayTestSuite) Test_Gateway_validRef() {
112107
// Check Maps
113108
mapFileRelativePath := "hug_" + s.Test().Namespace + "_gateway_http"
114109
expectedMapsPath := path.Join(expectationsPath, "maps")
115-
s.Eventually(func() bool {
116-
return s.CheckMapContents(mapFileRelativePath, expectedMapsPath)
117-
}, timeout, interval, fmt.Sprintf("maps in %s did not match expected contents", mapFileRelativePath))
110+
s.ExpectMapContents(mapFileRelativePath, expectedMapsPath)
118111
}
119112

120113
func (s *GatewayTestSuite) Test_Gateway_conflict_at_least_1_listener_ok() {
@@ -153,19 +146,13 @@ func (s *GatewayTestSuite) Test_Gateway_conflict_at_least_1_listener_ok() {
153146
// Check Maps
154147
mapFileRelativePath := "hug_http_8080"
155148
expectedMapsPath := path.Join(expectationsPath, "maps")
156-
s.Eventually(func() bool {
157-
return s.CheckMapContents(mapFileRelativePath, expectedMapsPath)
158-
}, timeout, interval, fmt.Sprintf("maps in %s did not match expected contents", mapFileRelativePath))
149+
s.ExpectMapContents(mapFileRelativePath, expectedMapsPath)
159150

160151
mapFileRelativePath = "hug_http_8081"
161-
s.Eventually(func() bool {
162-
return s.CheckMapContents(mapFileRelativePath, expectedMapsPath)
163-
}, timeout, interval, fmt.Sprintf("maps in %s did not match expected contents", mapFileRelativePath))
152+
s.ExpectMapContents(mapFileRelativePath, expectedMapsPath)
164153

165154
mapFileRelativePath = "hug_http_9090"
166-
s.Eventually(func() bool {
167-
return s.CheckMapContents(mapFileRelativePath, expectedMapsPath)
168-
}, timeout, interval, fmt.Sprintf("maps in %s did not match expected contents", mapFileRelativePath))
155+
s.ExpectMapContents(mapFileRelativePath, expectedMapsPath)
169156
}
170157

171158
func (s *GatewayTestSuite) Test_Gateway_conflict_empty_hostname_no_conflict() {

test/integration/tlsroute/tlsroute_test.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package tlsroute
22

33
import (
4-
"fmt"
54
"path"
65

76
"github.com/haproxytech/haproxy-unified-gateway/test/integration/utils"
@@ -30,7 +29,5 @@ func (s *TLSRouteSuite) Test_TLSRoute_SSL_Passthrough() {
3029
mapFilePath := "hug_tls_31445"
3130

3231
expectedMapsPath := path.Join(expectationsPath, "maps")
33-
s.Eventually(func() bool {
34-
return s.CheckMapContents(mapFilePath, expectedMapsPath)
35-
}, timeout, interval, fmt.Sprintf("maps in %s did not match expected contents", mapFilePath))
32+
s.ExpectMapContents(mapFilePath, expectedMapsPath)
3633
}

0 commit comments

Comments
 (0)