Skip to content

Commit 8fb7b55

Browse files
authored
Fix TestVerifyClient performance (#443)
1 parent de0458d commit 8fb7b55

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

internal/nginx/verify/client.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ import (
1414

1515
// Client is a client for verifying the config version.
1616
type Client struct {
17-
client *http.Client
17+
client *http.Client
18+
maxRetries int
1819
}
1920

2021
// NewClient returns a new client pointed at the config version socket.
@@ -27,6 +28,7 @@ func NewClient() *Client {
2728
},
2829
},
2930
},
31+
maxRetries: 160,
3032
}
3133
}
3234

@@ -57,10 +59,8 @@ func (c *Client) GetConfigVersion() (int, error) {
5759
// WaitForCorrectVersion calls the config version endpoint until it gets the expectedVersion,
5860
// which ensures that a new worker process has been started for that config version.
5961
func (c *Client) WaitForCorrectVersion(expectedVersion int) error {
60-
// This value needs tuning.
61-
maxRetries := 160
6262
sleep := 25 * time.Millisecond
63-
for i := 1; i <= maxRetries; i++ {
63+
for i := 1; i <= c.maxRetries; i++ {
6464
time.Sleep(sleep)
6565

6666
version, err := c.GetConfigVersion()

internal/nginx/verify/client_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ func getTestHTTPClient() *http.Client {
2727
}
2828

2929
func TestVerifyClient(t *testing.T) {
30-
3130
c := Client{
32-
client: getTestHTTPClient(),
31+
client: getTestHTTPClient(),
32+
maxRetries: 1,
3333
}
3434

3535
configVersion, err := c.GetConfigVersion()

0 commit comments

Comments
 (0)