feat(ooniprobe): propagate the RunType CheckIn hint (#274)

This diff propagates the RunType CheckIn hint such that we run
using less URLs when running in the background.

Part of https://github.com/ooni/probe/issues/1299.
This commit is contained in:
Simone Basso
2021-03-30 11:59:29 +02:00
committed by GitHub
parent c264f61536
commit dae02ce5b6
4 changed files with 40 additions and 17 deletions
+12 -8
View File
@@ -26,19 +26,23 @@ func init() {
log.WithError(err).Error("failed to perform onboarding")
return err
}
if *noCollector == true {
if *noCollector {
probe.Config().Sharing.UploadResults = false
}
return nil
})
functionalRun := func(pred func(name string, gr nettests.Group) bool) error {
functionalRun := func(runType string, pred func(name string, gr nettests.Group) bool) error {
for name, group := range nettests.All {
if pred(name, group) != true {
if !pred(name, group) {
continue
}
log.Infof("Running %s tests", color.BlueString(name))
conf := nettests.RunGroupConfig{GroupName: name, Probe: probe}
conf := nettests.RunGroupConfig{
GroupName: name,
Probe: probe,
RunType: runType,
}
if err := nettests.RunGroup(conf); err != nil {
log.WithError(err).Errorf("failed to run %s", name)
}
@@ -48,7 +52,7 @@ func init() {
genRunWithGroupName := func(targetName string) func(*kingpin.ParseContext) error {
return func(*kingpin.ParseContext) error {
return functionalRun(func(groupName string, gr nettests.Group) bool {
return functionalRun("manual", func(groupName string, gr nettests.Group) bool {
return groupName == targetName
})
}
@@ -75,14 +79,14 @@ func init() {
unattendedCmd := cmd.Command("unattended", "")
unattendedCmd.Action(func(_ *kingpin.ParseContext) error {
return functionalRun(func(name string, gr nettests.Group) bool {
return gr.UnattendedOK == true
return functionalRun("timed", func(name string, gr nettests.Group) bool {
return gr.UnattendedOK
})
})
allCmd := cmd.Command("all", "").Default()
allCmd.Action(func(_ *kingpin.ParseContext) error {
return functionalRun(func(name string, gr nettests.Group) bool {
return functionalRun("manual", func(name string, gr nettests.Group) bool {
return true
})
})