feat(ooniprobe): introduce websites_max_runtime (#273)

We cannot control anymore the maximum number of URLs using the API
because now we are using check-in, that has no such limit.

We could theoretically clamp the number of URLs to measure after
the call to check-in, and still honour the setting.

Yet, the right thing to do seems to introduce a max runtime variable
because that is what desktop and mobile do.

Thus, introduce code that warns the user about the change in the
settings, should they have set the URL limit to nonzero.

We are going to do a best effort conversion from the URL limit to
the maximum runtime for the rest of 2021.

Since then, we will silently ignore the URL limit.

This work is part of https://github.com/ooni/probe/issues/1299.
This commit is contained in:
Simone Basso 2021-03-30 11:16:12 +02:00 committed by GitHub
commit c264f61536
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 47 additions and 51 deletions

View file

@ -1,6 +1,8 @@
package nettests
import (
"time"
"github.com/apex/log"
"github.com/ooni/probe-cli/v3/cmd/ooniprobe/internal/database"
"github.com/ooni/probe-cli/v3/cmd/ooniprobe/internal/ooni"
@ -15,9 +17,36 @@ type RunGroupConfig struct {
Inputs []string
}
const websitesURLLimitRemoved = `WARNING: CONFIGURATION CHANGE REQUIRED:
* Since ooniprobe 3.9.0, websites_url_limit has been replaced
by websites_max_runtime in the configuration
* To silence this warning either set websites_url_limit to zero or
replace it with websites_max_runtime
* For the rest of 2021, we will automatically convert websites_url_limit
to websites_max_runtime (if the latter is not already set)
* We will consider that each URL in websites_url_limit takes five
seconds to run and thus calculate websites_max_runtime
* Since 2022, we will start silently ignoring websites_url_limit
`
// RunGroup runs a group of nettests according to the specified config.
func RunGroup(config RunGroupConfig) error {
if config.Probe.IsTerminated() == true {
if config.Probe.Config().Nettests.WebsitesURLLimit > 0 {
log.Warn(websitesURLLimitRemoved)
if config.Probe.Config().Nettests.WebsitesMaxRuntime <= 0 {
limit := config.Probe.Config().Nettests.WebsitesURLLimit
maxRuntime := 5 * limit
config.Probe.Config().Nettests.WebsitesMaxRuntime = maxRuntime
}
time.Sleep(30 * time.Second)
}
if config.Probe.IsTerminated() {
log.Debugf("context is terminated, stopping runNettestGroup early")
return nil
}