Skip to content

Commit 5d1a655

Browse files
authored
Fix graceful recovery tests (#2440)
Problem: Graceful recovery tests were failing in the pipeline Solutions: - Increase timeout when testing for passing/failing traffic after a container or pod restart. The timeout was set to 20 seconds, with a polling interval of 500ms, but the per-request timeout was 10 seconds. This means we were only retrying the request twice when a request timed out because it couldn't connect. Increasing the overall timeout to 60 seconds increased the number of retries and eliminated the errors. - Remove the kubectl drain flag --delete-local-data since it no longer exists and replace it with --delete-emptydir-data.
1 parent 0075167 commit 5d1a655

File tree

2 files changed

+15
-9
lines changed

2 files changed

+15
-9
lines changed

tests/framework/timeout.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ type TimeoutConfig struct {
3232

3333
// GetStatusTimeout represents the maximum time for NGF to update the status of a resource.
3434
GetStatusTimeout time.Duration
35+
36+
// TestForTrafficTimeout represents the maximum time for NGF to test for passing or failing traffic.
37+
TestForTrafficTimeout time.Duration
3538
}
3639

3740
// DefaultTimeoutConfig populates a TimeoutConfig with the default values.
@@ -47,5 +50,6 @@ func DefaultTimeoutConfig() TimeoutConfig {
4750
ContainerRestartTimeout: 10 * time.Second,
4851
GetLeaderLeaseTimeout: 60 * time.Second,
4952
GetStatusTimeout: 60 * time.Second,
53+
TestForTrafficTimeout: 60 * time.Second,
5054
}
5155
}

tests/suite/graceful_recovery_test.go

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ var _ = Describe("Graceful Recovery test", Ordered, Label("graceful-recovery"),
8282
func() error {
8383
return checkForWorkingTraffic(teaURL, coffeeURL)
8484
}).
85-
WithTimeout(timeoutConfig.RequestTimeout * 2).
85+
WithTimeout(timeoutConfig.TestForTrafficTimeout).
8686
WithPolling(500 * time.Millisecond).
8787
Should(Succeed())
8888
})
@@ -133,17 +133,18 @@ func runRestartNodeTest(teaURL, coffeeURL string, files []string, ns *core.Names
133133
}
134134

135135
if drain {
136-
_, err := exec.Command(
136+
output, err := exec.Command(
137137
"kubectl",
138138
"drain",
139139
kindNodeName,
140140
"--ignore-daemonsets",
141-
"--delete-local-data",
141+
"--delete-emptydir-data",
142142
).CombinedOutput()
143-
Expect(err).ToNot(HaveOccurred())
144143

145-
_, err = exec.Command("kubectl", "delete", "node", kindNodeName).CombinedOutput()
146-
Expect(err).ToNot(HaveOccurred())
144+
Expect(err).ToNot(HaveOccurred(), string(output))
145+
146+
output, err = exec.Command("kubectl", "delete", "node", kindNodeName).CombinedOutput()
147+
Expect(err).ToNot(HaveOccurred(), string(output))
147148
}
148149

149150
_, err = exec.Command("docker", "restart", containerName).CombinedOutput()
@@ -287,6 +288,7 @@ func checkForFailingTraffic(teaURL, coffeeURL string) error {
287288

288289
func expectRequestToSucceed(appURL, address string, responseBodyMessage string) error {
289290
status, body, err := framework.Get(appURL, address, timeoutConfig.RequestTimeout)
291+
290292
if status != http.StatusOK {
291293
return errors.New("http status was not 200")
292294
}
@@ -320,7 +322,7 @@ func checkNGFFunctionality(teaURL, coffeeURL, ngfPodName, containerName string,
320322
func() error {
321323
return checkForWorkingTraffic(teaURL, coffeeURL)
322324
}).
323-
WithTimeout(timeoutConfig.RequestTimeout * 2).
325+
WithTimeout(timeoutConfig.TestForTrafficTimeout).
324326
WithPolling(500 * time.Millisecond).
325327
Should(Succeed())
326328

@@ -330,7 +332,7 @@ func checkNGFFunctionality(teaURL, coffeeURL, ngfPodName, containerName string,
330332
func() error {
331333
return checkForFailingTraffic(teaURL, coffeeURL)
332334
}).
333-
WithTimeout(timeoutConfig.RequestTimeout).
335+
WithTimeout(timeoutConfig.TestForTrafficTimeout).
334336
WithPolling(500 * time.Millisecond).
335337
Should(Succeed())
336338

@@ -341,7 +343,7 @@ func checkNGFFunctionality(teaURL, coffeeURL, ngfPodName, containerName string,
341343
func() error {
342344
return checkForWorkingTraffic(teaURL, coffeeURL)
343345
}).
344-
WithTimeout(timeoutConfig.RequestTimeout * 2).
346+
WithTimeout(timeoutConfig.TestForTrafficTimeout).
345347
WithPolling(500 * time.Millisecond).
346348
Should(Succeed())
347349

0 commit comments

Comments
 (0)