Skip to content

Fix graceful recovery tests #2440

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Aug 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions tests/framework/timeout.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ type TimeoutConfig struct {

// GetStatusTimeout represents the maximum time for NGF to update the status of a resource.
GetStatusTimeout time.Duration

// TestForTrafficTimeout represents the maximum time for NGF to test for passing or failing traffic.
TestForTrafficTimeout time.Duration
}

// DefaultTimeoutConfig populates a TimeoutConfig with the default values.
Expand All @@ -47,5 +50,6 @@ func DefaultTimeoutConfig() TimeoutConfig {
ContainerRestartTimeout: 10 * time.Second,
GetLeaderLeaseTimeout: 60 * time.Second,
GetStatusTimeout: 60 * time.Second,
TestForTrafficTimeout: 60 * time.Second,
}
}
20 changes: 11 additions & 9 deletions tests/suite/graceful_recovery_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ var _ = Describe("Graceful Recovery test", Ordered, Label("graceful-recovery"),
func() error {
return checkForWorkingTraffic(teaURL, coffeeURL)
}).
WithTimeout(timeoutConfig.RequestTimeout * 2).
WithTimeout(timeoutConfig.TestForTrafficTimeout).
WithPolling(500 * time.Millisecond).
Should(Succeed())
})
Expand Down Expand Up @@ -133,17 +133,18 @@ func runRestartNodeTest(teaURL, coffeeURL string, files []string, ns *core.Names
}

if drain {
_, err := exec.Command(
output, err := exec.Command(
"kubectl",
"drain",
kindNodeName,
"--ignore-daemonsets",
"--delete-local-data",
"--delete-emptydir-data",
).CombinedOutput()
Expect(err).ToNot(HaveOccurred())

_, err = exec.Command("kubectl", "delete", "node", kindNodeName).CombinedOutput()
Expect(err).ToNot(HaveOccurred())
Expect(err).ToNot(HaveOccurred(), string(output))

output, err = exec.Command("kubectl", "delete", "node", kindNodeName).CombinedOutput()
Expect(err).ToNot(HaveOccurred(), string(output))
}

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

func expectRequestToSucceed(appURL, address string, responseBodyMessage string) error {
status, body, err := framework.Get(appURL, address, timeoutConfig.RequestTimeout)

if status != http.StatusOK {
return errors.New("http status was not 200")
}
Expand Down Expand Up @@ -320,7 +322,7 @@ func checkNGFFunctionality(teaURL, coffeeURL, ngfPodName, containerName string,
func() error {
return checkForWorkingTraffic(teaURL, coffeeURL)
}).
WithTimeout(timeoutConfig.RequestTimeout * 2).
WithTimeout(timeoutConfig.TestForTrafficTimeout).
WithPolling(500 * time.Millisecond).
Should(Succeed())

Expand All @@ -330,7 +332,7 @@ func checkNGFFunctionality(teaURL, coffeeURL, ngfPodName, containerName string,
func() error {
return checkForFailingTraffic(teaURL, coffeeURL)
}).
WithTimeout(timeoutConfig.RequestTimeout).
WithTimeout(timeoutConfig.TestForTrafficTimeout).
WithPolling(500 * time.Millisecond).
Should(Succeed())

Expand All @@ -341,7 +343,7 @@ func checkNGFFunctionality(teaURL, coffeeURL, ngfPodName, containerName string,
func() error {
return checkForWorkingTraffic(teaURL, coffeeURL)
}).
WithTimeout(timeoutConfig.RequestTimeout * 2).
WithTimeout(timeoutConfig.TestForTrafficTimeout).
WithPolling(500 * time.Millisecond).
Should(Succeed())

Expand Down
Loading