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

@ -9,16 +9,10 @@ import (
"github.com/ooni/probe-cli/v3/internal/engine/model"
)
// TODO(bassosimone): we should remove the limit argument and
// we should also remove it from the config.
// TODO(bassosimone): we should propagate the kind of run
// to here such that we get the right runType.
// TODO(bassosimone): we are breaking the use case in which
// someone choose the number of URLs explicitly via the config.
func lookupURLs(ctl *Controller, limit int64, categories []string) ([]string, map[int64]int64, error) {
func lookupURLs(ctl *Controller, categories []string) ([]string, map[int64]int64, error) {
inputloader := &engine.InputLoader{
CheckInConfig: &model.CheckInConfig{
WebConnectivity: model.CheckInConfigWebConnectivity{
@ -53,13 +47,12 @@ func lookupURLs(ctl *Controller, limit int64, categories []string) ([]string, ma
}
// WebConnectivity test implementation
type WebConnectivity struct {
}
type WebConnectivity struct{}
// Run starts the test
func (n WebConnectivity) Run(ctl *Controller) error {
log.Debugf("Enabled category codes are the following %v", ctl.Probe.Config().Nettests.WebsitesEnabledCategoryCodes)
urls, urlIDMap, err := lookupURLs(ctl, ctl.Probe.Config().Nettests.WebsitesURLLimit, ctl.Probe.Config().Nettests.WebsitesEnabledCategoryCodes)
urls, urlIDMap, err := lookupURLs(ctl, ctl.Probe.Config().Nettests.WebsitesEnabledCategoryCodes)
if err != nil {
return err
}