fix: ensure experiments return nil when we want to submit (#654)

Since https://github.com/ooni/probe-cli/pull/527, if an experiment
returns an error, the corresponding measurement is not submitted since
the semantics of returning an error is that something fundamental
went wrong (e.g., we could not parse the input URL).

This diff ensures that all experiments only return and error when
something fundamental was wrong and return nil otherwise.

Reference issue: https://github.com/ooni/probe/issues/1808.
This commit is contained in:
Simone Basso
2022-01-07 13:17:20 +01:00
committed by GitHub
parent 60a3c372f5
commit 99ec7ffca9
27 changed files with 132 additions and 66 deletions
@@ -2,7 +2,6 @@ package run
import (
"context"
"sync"
"github.com/ooni/probe-cli/v3/internal/engine/experiment/dnscheck"
"github.com/ooni/probe-cli/v3/internal/model"
@@ -10,7 +9,6 @@ import (
type dnsCheckMain struct {
Endpoints *dnscheck.Endpoints
mu sync.Mutex
}
func (m *dnsCheckMain) do(ctx context.Context, input StructuredInput,
+4
View File
@@ -0,0 +1,4 @@
// Package run contains code to run other experiments.
//
// This code is currently alpha.
package run
-3
View File
@@ -1,6 +1,3 @@
// Package run contains code to run other experiments.
//
// This code is currently alpha.
package run
import (
+1 -1
View File
@@ -63,7 +63,7 @@ func TestRunURLGetterWithCancelledContext(t *testing.T) {
sess := &mockable.Session{MockableLogger: log.Log}
callbacks := model.NewPrinterCallbacks(log.Log)
err := measurer.Run(ctx, sess, measurement, callbacks)
if err == nil {
if err != nil { // here we expected nil b/c we want to submit the measurement
t.Fatal(err)
}
if len(measurement.Extensions) != 6 {