From a01f901e133b688fcab0be26adb7462e9becc68f Mon Sep 17 00:00:00 2001 From: Simone Basso Date: Fri, 21 Jan 2022 12:32:08 +0100 Subject: [PATCH] feat(ooniprobe): add torsf to experimental group (#670) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reference issue: https://github.com/ooni/probe/issues/1917. I needed to change the summary key type returned by `torsf` to be a value. It seems the DB layer assumes that. If we pass it a pointer, it panics because it's experiment a value rather than a pointer 🤷. --- cmd/ooniprobe/internal/nettests/groups.go | 1 + cmd/ooniprobe/internal/nettests/torsf.go | 14 ++++++++++++++ internal/engine/experiment/torsf/torsf.go | 2 +- internal/engine/experiment/torsf/torsf_test.go | 2 +- 4 files changed, 17 insertions(+), 2 deletions(-) create mode 100644 cmd/ooniprobe/internal/nettests/torsf.go diff --git a/cmd/ooniprobe/internal/nettests/groups.go b/cmd/ooniprobe/internal/nettests/groups.go index 2390432..7979714 100644 --- a/cmd/ooniprobe/internal/nettests/groups.go +++ b/cmd/ooniprobe/internal/nettests/groups.go @@ -55,6 +55,7 @@ var All = map[string]Group{ Nettests: []Nettest{ DNSCheck{}, STUNReachability{}, + TorSf{}, }, }, } diff --git a/cmd/ooniprobe/internal/nettests/torsf.go b/cmd/ooniprobe/internal/nettests/torsf.go new file mode 100644 index 0000000..d488188 --- /dev/null +++ b/cmd/ooniprobe/internal/nettests/torsf.go @@ -0,0 +1,14 @@ +package nettests + +// TorSf test implementation +type TorSf struct { +} + +// Run starts the test +func (h TorSf) Run(ctl *Controller) error { + builder, err := ctl.Session.NewExperimentBuilder("torsf") + if err != nil { + return err + } + return ctl.Run(builder, []string{""}) +} diff --git a/internal/engine/experiment/torsf/torsf.go b/internal/engine/experiment/torsf/torsf.go index cc8d2c5..e850953 100644 --- a/internal/engine/experiment/torsf/torsf.go +++ b/internal/engine/experiment/torsf/torsf.go @@ -173,5 +173,5 @@ type SummaryKeys struct { // GetSummaryKeys implements model.ExperimentMeasurer.GetSummaryKeys. func (m *Measurer) GetSummaryKeys(measurement *model.Measurement) (interface{}, error) { - return &SummaryKeys{IsAnomaly: false}, nil + return SummaryKeys{IsAnomaly: false}, nil } diff --git a/internal/engine/experiment/torsf/torsf_test.go b/internal/engine/experiment/torsf/torsf_test.go index 49e205a..f6d198b 100644 --- a/internal/engine/experiment/torsf/torsf_test.go +++ b/internal/engine/experiment/torsf/torsf_test.go @@ -160,7 +160,7 @@ func TestGetSummaryKeys(t *testing.T) { if err != nil { t.Fatal(err) } - rsk := sk.(*SummaryKeys) + rsk := sk.(SummaryKeys) if rsk.IsAnomaly { t.Fatal("expected no anomaly here") }