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:
@@ -14,7 +14,7 @@ import (
|
||||
|
||||
const (
|
||||
testName = "urlgetter"
|
||||
testVersion = "0.1.0"
|
||||
testVersion = "0.2.0"
|
||||
)
|
||||
|
||||
// Config contains the experiment's configuration.
|
||||
@@ -109,9 +109,9 @@ func (m Measurer) Run(
|
||||
Session: sess,
|
||||
Target: string(measurement.Input),
|
||||
}
|
||||
tk, err := g.Get(ctx)
|
||||
tk, _ := g.Get(ctx) // ignore error since we have the testkeys and we wanna submit them
|
||||
measurement.TestKeys = &tk
|
||||
return err
|
||||
return nil
|
||||
}
|
||||
|
||||
// NewExperimentMeasurer creates a new ExperimentMeasurer.
|
||||
|
||||
@@ -18,7 +18,7 @@ func TestMeasurer(t *testing.T) {
|
||||
if m.ExperimentName() != "urlgetter" {
|
||||
t.Fatal("invalid experiment name")
|
||||
}
|
||||
if m.ExperimentVersion() != "0.1.0" {
|
||||
if m.ExperimentVersion() != "0.2.0" {
|
||||
t.Fatal("invalid experiment version")
|
||||
}
|
||||
measurement := new(model.Measurement)
|
||||
@@ -27,7 +27,7 @@ func TestMeasurer(t *testing.T) {
|
||||
ctx, &mockable.Session{},
|
||||
measurement, model.NewPrinterCallbacks(log.Log),
|
||||
)
|
||||
if !errors.Is(err, context.Canceled) {
|
||||
if !errors.Is(err, nil) { // nil because we want to submit the measurement
|
||||
t.Fatal("not the error we expected")
|
||||
}
|
||||
if len(measurement.Extensions) != 6 {
|
||||
@@ -55,7 +55,7 @@ func TestMeasurerDNSCache(t *testing.T) {
|
||||
if m.ExperimentName() != "urlgetter" {
|
||||
t.Fatal("invalid experiment name")
|
||||
}
|
||||
if m.ExperimentVersion() != "0.1.0" {
|
||||
if m.ExperimentVersion() != "0.2.0" {
|
||||
t.Fatal("invalid experiment version")
|
||||
}
|
||||
measurement := new(model.Measurement)
|
||||
@@ -64,7 +64,7 @@ func TestMeasurerDNSCache(t *testing.T) {
|
||||
ctx, &mockable.Session{},
|
||||
measurement, model.NewPrinterCallbacks(log.Log),
|
||||
)
|
||||
if !errors.Is(err, context.Canceled) {
|
||||
if !errors.Is(err, nil) { // nil because we want to submit the measurement
|
||||
t.Fatal("not the error we expected")
|
||||
}
|
||||
if len(measurement.Extensions) != 6 {
|
||||
|
||||
Reference in New Issue
Block a user