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:
@@ -22,7 +22,7 @@ import (
|
||||
|
||||
const (
|
||||
testName = "stunreachability"
|
||||
testVersion = "0.3.0"
|
||||
testVersion = "0.4.0"
|
||||
)
|
||||
|
||||
// Config contains the experiment config.
|
||||
@@ -100,7 +100,7 @@ func (m *Measurer) Run(
|
||||
if err := wrap(tk.run(ctx, m.config, sess, measurement, callbacks, URL.Host)); err != nil {
|
||||
s := err.Error()
|
||||
tk.Failure = &s
|
||||
return err
|
||||
return nil // we want to submit this measurement
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ func TestMeasurerExperimentNameVersion(t *testing.T) {
|
||||
if measurer.ExperimentName() != "stunreachability" {
|
||||
t.Fatal("unexpected ExperimentName")
|
||||
}
|
||||
if measurer.ExperimentVersion() != "0.3.0" {
|
||||
if measurer.ExperimentVersion() != "0.4.0" {
|
||||
t.Fatal("unexpected ExperimentVersion")
|
||||
}
|
||||
}
|
||||
@@ -128,7 +128,7 @@ func TestCancelledContext(t *testing.T) {
|
||||
measurement,
|
||||
model.NewPrinterCallbacks(log.Log),
|
||||
)
|
||||
if !errors.Is(err, context.Canceled) {
|
||||
if !errors.Is(err, nil) { // nil because we want to submit
|
||||
t.Fatal("not the error we expected", err)
|
||||
}
|
||||
tk := measurement.TestKeys.(*TestKeys)
|
||||
@@ -168,7 +168,7 @@ func TestNewClientFailure(t *testing.T) {
|
||||
measurement,
|
||||
model.NewPrinterCallbacks(log.Log),
|
||||
)
|
||||
if !errors.Is(err, expected) {
|
||||
if !errors.Is(err, nil) { // nil because we want to submit
|
||||
t.Fatal("not the error we expected")
|
||||
}
|
||||
tk := measurement.TestKeys.(*TestKeys)
|
||||
@@ -202,7 +202,7 @@ func TestStartFailure(t *testing.T) {
|
||||
measurement,
|
||||
model.NewPrinterCallbacks(log.Log),
|
||||
)
|
||||
if !errors.Is(err, expected) {
|
||||
if !errors.Is(err, nil) { // nil because we want to submit
|
||||
t.Fatal("not the error we expected")
|
||||
}
|
||||
tk := measurement.TestKeys.(*TestKeys)
|
||||
@@ -240,7 +240,7 @@ func TestReadFailure(t *testing.T) {
|
||||
measurement,
|
||||
model.NewPrinterCallbacks(log.Log),
|
||||
)
|
||||
if !errors.Is(err, stun.ErrTransactionTimeOut) {
|
||||
if !errors.Is(err, nil) { // nil because we want to submit
|
||||
t.Fatal("not the error we expected")
|
||||
}
|
||||
tk := measurement.TestKeys.(*TestKeys)
|
||||
|
||||
Reference in New Issue
Block a user