diff --git a/pkg/environment/flags.go b/pkg/environment/flags.go index 59efc52e9..80fda9862 100644 --- a/pkg/environment/flags.go +++ b/pkg/environment/flags.go @@ -21,8 +21,10 @@ import ( "fmt" "strconv" "strings" + "time" "knative.dev/reconciler-test/pkg/feature" + "knative.dev/reconciler-test/pkg/state" ) var ( @@ -34,6 +36,9 @@ var ( ipFilePath = new(string) teardownOnFail = new(bool) + + pollTimeout = new(time.Duration) + pollInterval = new(time.Duration) ) // InitFlags registers the requirement and state filter flags supported by the @@ -62,7 +67,8 @@ func InitFlags(fs *flag.FlagSet) { fs.StringVar(ipFilePath, "images.producer.file", "", "file path for file-based image producer") fs.StringVar(testNamespace, "environment.namespace", "", "Test namespace") - + fs.DurationVar(pollTimeout, "poll.timeout", state.DefaultPollTimeout, "Poll timeout") + fs.DurationVar(pollInterval, "poll.interval", state.DefaultPollInterval, "Poll interval") fs.BoolVar(teardownOnFail, "teardown.on.fail", false, "Set this flag to do teardown even if test fails.") } diff --git a/pkg/environment/magic.go b/pkg/environment/magic.go index a1808d856..a0400bcb2 100644 --- a/pkg/environment/magic.go +++ b/pkg/environment/magic.go @@ -198,6 +198,7 @@ func (mr *MagicGlobalEnvironment) Environment(opts ...EnvOpts) (context.Context, } ctx := ContextWith(mr.c, env) + ctx = ContextWithPollTimings(ctx, *pollInterval, *pollTimeout) for _, opt := range opts { if nctx, err := opt(ctx, env); err != nil { diff --git a/pkg/state/timings.go b/pkg/state/timings.go index 88a3dc1e6..5a79de9e1 100644 --- a/pkg/state/timings.go +++ b/pkg/state/timings.go @@ -48,5 +48,5 @@ func PollTimingsFromContext(ctx context.Context) (time.Duration, time.Duration) if t, ok := ctx.Value(timingsKey{}).(timingsType); ok { return t.interval, t.timeout } - return DefaultPollInterval, DefaultPollTimeout + panic("no poll timings found in context") }