Skip to content

Commit

Permalink
e2e/regression: move timeout closer to context usage
Browse files Browse the repository at this point in the history
Signed-off-by: Paul Meyer <[email protected]>
  • Loading branch information
katexochen committed Aug 30, 2024
1 parent 2374c09 commit 91fd671
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions e2e/regression/regression_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,6 @@ func TestRegression(t *testing.T) {
require := require.New(t)

c := kubeclient.NewForTest(t)
ctx, cancel := context.WithTimeout(context.Background(), 3*time.Minute) // Already long timeout, not using ct.FactorPlatformTimeout.
defer cancel()

yaml, err := os.ReadFile(yamlDir + file.Name())
require.NoError(err)
Expand All @@ -82,8 +80,7 @@ func TestRegression(t *testing.T) {

t.Cleanup(func() {
// delete the deployment
ctx = context.Background()
require.NoError(ct.Kubeclient.Client.AppsV1().Deployments(ct.Namespace).Delete(ctx, deploymentName, metav1.DeleteOptions{}))
require.NoError(ct.Kubeclient.Client.AppsV1().Deployments(ct.Namespace).Delete(context.Background(), deploymentName, metav1.DeleteOptions{}))
})

// generate, set, deploy and verify the new policy
Expand All @@ -92,6 +89,8 @@ func TestRegression(t *testing.T) {
require.True(t.Run("set", ct.Set), "contrast set needs to succeed for subsequent tests")
require.True(t.Run("verify", ct.Verify), "contrast verify needs to succeed for subsequent tests")

ctx, cancel := context.WithTimeout(context.Background(), 3*time.Minute) // Already long timeout, not using ct.FactorPlatformTimeout.
defer cancel()
require.NoError(c.WaitFor(ctx, kubeclient.Deployment{}, ct.Namespace, deploymentName))
})
}
Expand Down

0 comments on commit 91fd671

Please sign in to comment.