Skip to content

Commit

Permalink
fix: disable maxRuntime with --input or --input-file (#305)
Browse files Browse the repository at this point in the history
When this happens, the user is expressing the intention of
explicitly testing all the input they provided.

So, disable maxRuntime in these cases.

Part of ooni/probe#1436.
  • Loading branch information
bassosimone committed Apr 7, 2021
1 parent f48115a commit c5f52d5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
7 changes: 6 additions & 1 deletion cmd/ooniprobe/internal/nettests/nettests.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,10 @@ func (c *Controller) Run(builder *engine.ExperimentBuilder, inputs []string) err
log.Debug("disabling maxRuntime without Web Connectivity")
maxRuntime = 0
}
if len(c.Inputs) > 0 || len(c.InputFiles) > 0 {
log.Debug("disabling maxRuntime with user-provided input")
maxRuntime = 0
}
start := time.Now()
c.ntStartTime = start
for idx, input := range inputs {
Expand Down Expand Up @@ -220,7 +224,8 @@ func (c *Controller) OnProgress(perc float64, msg string) {
// when we have maxRuntime, honor it
maxRuntime := time.Duration(c.Probe.Config().Nettests.WebsitesMaxRuntime) * time.Second
_, isWebConnectivity := c.nt.(WebConnectivity)
if c.RunType == "manual" && maxRuntime > 0 && isWebConnectivity {
userProvidedInput := len(c.Inputs) > 0 || len(c.InputFiles) > 0
if c.RunType == "manual" && maxRuntime > 0 && isWebConnectivity && !userProvidedInput {
elapsed := time.Since(c.ntStartTime)
perc = float64(elapsed) / float64(maxRuntime)
eta := maxRuntime.Seconds() - elapsed.Seconds()
Expand Down
1 change: 0 additions & 1 deletion cmd/ooniprobe/internal/nettests/web_connectivity.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ func lookupURLs(ctl *Controller, categories []string) ([]string, map[int64]int64
SourceFiles: ctl.InputFiles,
StaticInputs: ctl.Inputs,
}
log.Infof("Calling CheckIn API with %s runType", ctl.RunType)
testlist, err := inputloader.Load(context.Background())
if err != nil {
return nil, nil, err
Expand Down

0 comments on commit c5f52d5

Please sign in to comment.