summaryrefslogtreecommitdiffhomepage
path: root/pkg
diff options
context:
space:
mode:
authorgVisor bot <gvisor-bot@google.com>2020-08-14 11:24:56 -0700
committergVisor bot <gvisor-bot@google.com>2020-08-14 11:24:56 -0700
commit3be8b49c703e5b9b692fbce74946bc3e84f8dbbb (patch)
tree44f1098144133983f2032a3a52153ea5d8cc26c5 /pkg
parente6ea59203ba6e9c0431999463795a2c14036053f (diff)
parent805a96d7ba78762a3bb96bb1cc9e32ccc569437a (diff)
Merge pull request #3375 from kevinGC:ipt-test-early-return
PiperOrigin-RevId: 326693922
Diffstat (limited to 'pkg')
-rw-r--r--pkg/test/testutil/testutil.go5
1 files changed, 5 insertions, 0 deletions
diff --git a/pkg/test/testutil/testutil.go b/pkg/test/testutil/testutil.go
index 64c292698..1580527b5 100644
--- a/pkg/test/testutil/testutil.go
+++ b/pkg/test/testutil/testutil.go
@@ -316,6 +316,11 @@ func Copy(src, dst string) error {
func Poll(cb func() error, timeout time.Duration) error {
ctx, cancel := context.WithTimeout(context.Background(), timeout)
defer cancel()
+ return PollContext(ctx, cb)
+}
+
+// PollContext is like Poll, but takes a context instead of a timeout.
+func PollContext(ctx context.Context, cb func() error) error {
b := backoff.WithContext(backoff.NewConstantBackOff(100*time.Millisecond), ctx)
return backoff.Retry(cb, b)
}