refactor(netx): merge archival, trace, and the savers (#772)

This diff creates a new package under netx called tracex that
contains everything we need to perform measurements using events
tracing and postprocessing (which is the technique with which
we implement most network experiments).

The general idea here is to (1) create a unique package out of
all of these packages; (2) clean up the code a bit (improve tests,
docs, apply more recent code patterns); (3) move the resulting
code as a toplevel package inside of internal.

Once this is done, netx can be further refactored to avoid
subpackages and we can search for more code to salvage/refactor.

See https://github.com/ooni/probe/issues/2121
This commit is contained in:
Simone Basso
2022-05-31 21:53:01 +02:00
committed by GitHub
parent dd5655eaee
commit bbcd2e2280
53 changed files with 869 additions and 865 deletions
@@ -34,11 +34,11 @@ generic data model used by all experiments.
```
The `archival` package contains code used to format internal
The `tracex` package contains code used to format internal
measurements representations to the OONI data format.
```Go
"github.com/ooni/probe-cli/v3/internal/engine/netx/archival"
"github.com/ooni/probe-cli/v3/internal/engine/netx/tracex"
```
@@ -104,7 +104,7 @@ starting the experiment. Therefore, it's consistent with the
```Go
if err := ptl.Start(); err != nil {
testkeys.Failure = archival.NewFailure(err)
testkeys.Failure = tracex.NewFailure(err)
errch <- err
return
}
@@ -116,7 +116,7 @@ pass specific `TorArgs` that cause `tor` to know about the
pluggable transport created by `ptl` and `sfdialer`.
```Go
tun, err := tunnel.Start(ctx, &tunnel.Config{
tun, _, err := tunnel.Start(ctx, &tunnel.Config{
Name: "tor",
Session: sess,
TunnelDir: path.Join(sess.TempDir(), "torsf"),
@@ -130,7 +130,7 @@ pluggable transport created by `ptl` and `sfdialer`.
```
In case of error, we convert `err` to a OONI failure using
the `NewFailure` function of `archival`. This function reduces
the `NewFailure` function of `tracex`. This function reduces
Go error strings to the error strings used by OONI. You can
read the [errors spec](https://github.com/ooni/spec/blob/master/data-formats/df-007-errors.md)
at the [github.com/ooni/spec repo](https://github.com/ooni/spec).
@@ -141,7 +141,7 @@ experiment, but rather a possibly interesting anomaly.
```Go
if err != nil {
testkeys.Failure = archival.NewFailure(err)
testkeys.Failure = tracex.NewFailure(err)
errch <- nil
return
}
@@ -37,11 +37,11 @@ import (
// ```
//
// The `archival` package contains code used to format internal
// The `tracex` package contains code used to format internal
// measurements representations to the OONI data format.
//
// ```Go
"github.com/ooni/probe-cli/v3/internal/engine/netx/archival"
"github.com/ooni/probe-cli/v3/internal/engine/netx/tracex"
// ```
//
@@ -169,7 +169,7 @@ func (m *Measurer) run(ctx context.Context,
//
// ```Go
if err := ptl.Start(); err != nil {
testkeys.Failure = archival.NewFailure(err)
testkeys.Failure = tracex.NewFailure(err)
errch <- err
return
}
@@ -195,7 +195,7 @@ func (m *Measurer) run(ctx context.Context,
// ```
//
// In case of error, we convert `err` to a OONI failure using
// the `NewFailure` function of `archival`. This function reduces
// the `NewFailure` function of `tracex`. This function reduces
// Go error strings to the error strings used by OONI. You can
// read the [errors spec](https://github.com/ooni/spec/blob/master/data-formats/df-007-errors.md)
// at the [github.com/ooni/spec repo](https://github.com/ooni/spec).
@@ -206,7 +206,7 @@ func (m *Measurer) run(ctx context.Context,
//
// ```Go
if err != nil {
testkeys.Failure = archival.NewFailure(err)
testkeys.Failure = tracex.NewFailure(err)
errch <- nil
return
}