fix(ooniprobe): use ooniprobe-cli-unattended for unattended runs (#714)
This diff changes the software name used by unattended runs for which we did not override the default software name (`ooniprobe-cli`). It will become `ooniprobe-cli-unattended`. This software name is in line with the one we use for Android, iOS, and desktop unattended runs. While working in this diff, I introduced string constants for the run types and a string constant for the default software name. See https://github.com/ooni/probe/issues/2081.
This commit is contained in:
@@ -55,8 +55,8 @@ type Controller struct {
|
||||
Inputs []string
|
||||
|
||||
// RunType contains the run_type hint for the CheckIn API. If
|
||||
// not set, the underlying code defaults to "timed".
|
||||
RunType string
|
||||
// not set, the underlying code defaults to model.RunTypeTimed.
|
||||
RunType model.RunType
|
||||
|
||||
// numInputs is the total number of inputs
|
||||
numInputs int
|
||||
@@ -154,7 +154,7 @@ func (c *Controller) Run(builder *engine.ExperimentBuilder, inputs []string) err
|
||||
}
|
||||
|
||||
maxRuntime := time.Duration(c.Probe.Config().Nettests.WebsitesMaxRuntime) * time.Second
|
||||
if c.RunType == "timed" && maxRuntime > 0 {
|
||||
if c.RunType == model.RunTypeTimed && maxRuntime > 0 {
|
||||
log.Debug("disabling maxRuntime when running in the background")
|
||||
maxRuntime = 0
|
||||
}
|
||||
@@ -267,7 +267,7 @@ func (c *Controller) OnProgress(perc float64, msg string) {
|
||||
maxRuntime := time.Duration(c.Probe.Config().Nettests.WebsitesMaxRuntime) * time.Second
|
||||
_, isWebConnectivity := c.nt.(WebConnectivity)
|
||||
userProvidedInput := len(c.Inputs) > 0 || len(c.InputFiles) > 0
|
||||
if c.RunType == "manual" && maxRuntime > 0 && isWebConnectivity && !userProvidedInput {
|
||||
if c.RunType == model.RunTypeManual && maxRuntime > 0 && isWebConnectivity && !userProvidedInput {
|
||||
elapsed := time.Since(c.ntStartTime)
|
||||
perc = float64(elapsed) / float64(maxRuntime)
|
||||
eta := maxRuntime.Seconds() - elapsed.Seconds()
|
||||
|
||||
@@ -9,6 +9,7 @@ import (
|
||||
|
||||
"github.com/ooni/probe-cli/v3/cmd/ooniprobe/internal/database"
|
||||
"github.com/ooni/probe-cli/v3/cmd/ooniprobe/internal/ooni"
|
||||
"github.com/ooni/probe-cli/v3/internal/model"
|
||||
)
|
||||
|
||||
func copyfile(source, dest string) error {
|
||||
@@ -45,7 +46,7 @@ func TestCreateContext(t *testing.T) {
|
||||
|
||||
func TestRun(t *testing.T) {
|
||||
probe := newOONIProbe(t)
|
||||
sess, err := probe.NewSession(context.Background())
|
||||
sess, err := probe.NewSession(context.Background(), model.RunTypeManual)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ import (
|
||||
"github.com/apex/log"
|
||||
"github.com/ooni/probe-cli/v3/cmd/ooniprobe/internal/database"
|
||||
"github.com/ooni/probe-cli/v3/cmd/ooniprobe/internal/ooni"
|
||||
"github.com/ooni/probe-cli/v3/internal/model"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
@@ -17,7 +18,7 @@ type RunGroupConfig struct {
|
||||
InputFiles []string
|
||||
Inputs []string
|
||||
Probe *ooni.Probe
|
||||
RunType string // hint for check-in API
|
||||
RunType model.RunType // hint for check-in API
|
||||
}
|
||||
|
||||
const websitesURLLimitRemoved = `WARNING: CONFIGURATION CHANGE REQUIRED:
|
||||
@@ -58,7 +59,7 @@ func RunGroup(config RunGroupConfig) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
sess, err := config.Probe.NewSession(context.Background())
|
||||
sess, err := config.Probe.NewSession(context.Background(), config.RunType)
|
||||
if err != nil {
|
||||
log.WithError(err).Error("Failed to create a measurement session")
|
||||
return err
|
||||
|
||||
Reference in New Issue
Block a user