Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integrate further with ooni/probe-engine: episode two #46

Merged
merged 38 commits into from
Aug 15, 2019

Conversation

bassosimone
Copy link
Member

  1. use ooni/probe-engine for contacting the bouncer, using the collector

  2. use ooni/probe-engine for running the IM tests

  3. DO NOT use it for other tests for now (to keep the diff small and ease comparison between tests using the ooni/probe-engine and tests using measurement-kit/go-measurement-kit)

I'd like @hellais to review. If this is fine, we can either continue the work in this branch and making all tests use ooni/probe-engine or merge and open a new PR for other tests.

Related issue #44

Let's start using the engine by rewriting utils/geoip.go to
be just a thin wrapper around the engine functionality.
Still have some doubts with respect to the variables that
are passed to MK via probe-engine. Will double check.
Conflicts:
	go.mod
	go.sum
	nettests/nettests.go
	ooni.go
@bassosimone bassosimone added enhancement New feature or request OTFy2 OTF contract - second year labels May 24, 2019
@bassosimone bassosimone requested a review from hellais May 24, 2019 13:25
@bassosimone bassosimone self-assigned this May 24, 2019
@bassosimone bassosimone added this to Icebox in DO NOT USE (was: OONI Probe Desktop) via automation May 24, 2019
@bassosimone bassosimone moved this from Icebox to Review in DO NOT USE (was: OONI Probe Desktop) May 24, 2019
internal/cli/run/run.go Outdated Show resolved Hide resolved
nettests/im/whatsapp.go Outdated Show resolved Hide resolved
nettests/nettests.go Outdated Show resolved Hide resolved
nettests/nettests.go Outdated Show resolved Hide resolved
nettests/im/whatsapp.go Outdated Show resolved Hide resolved
Copy link
Member Author

@bassosimone bassosimone left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did read the diff once more and added an useful note for the future

@bassosimone bassosimone moved this from Review to In Progress in DO NOT USE (was: OONI Probe Desktop) Jun 3, 2019
Making the concept of measurement more abstract in the engine is
not feasible because, when submitting a measurement, we need to
modify it to update the report ID and the measurement ID. Therefore,
returning a serialized measurement is not a good idea. We will
keep using a model.Measurement in the engine.

Changing model.Measurement.TestKeys's type from a `interface{}`
pointing to a well defined data structure to `map[string]interface{}`
is a regression because means that we are moving from code that
has a clear and defined structure to code that is more complicated
to parse and validate. Since we're already suffering havily from
the lack of a good schema, I'm not going to make the situation
worst by worsening the engine. At least for ndt7 and psiphon, we
now have a good schema and I don't want to lose that.

However, the current code in this repository is expecting the
test keys to be a `map[string]interface{}`. This choice was
dictated by the fact that we receive a JSON from Measurement Kit
and by the fact that there's not a clear schema.

To solve this tension, in this commit I am going to write glue
adapter code that makes sure that the TestKeys of a Measurement
are converted to `map[string]interface{}`. This will be done
using a type cast where possible and JSON serialization and parsing
otherwise. In a perfect world, glue is not a good idea, but in a
real world it may actually be useful.

When all tests in the engine will have a clear Go data structure,
we'll then remove the glue and just cast to the proper data
structure from `interface{}` where required.
@bassosimone
Copy link
Member Author

(It seems I broke Travis in my attempts to fix it for probe-engine.)

For reference, to unbreak it and get back the webook, go to travis-ci.org/organizations/ooni/repositories, disable and re-enable the affected repo.

@bassosimone
Copy link
Member Author

It also seems I did broke the Linux build. Let me check this.

@bassosimone
Copy link
Member Author

Bug filed: measurement-kit/script-build-linux#6

@bassosimone
Copy link
Member Author

Fixed in these PRs, which require some light review:

When those are merged, we can resume the work here.

@bassosimone
Copy link
Member Author

bassosimone commented Jun 17, 2019

TODO list of actions to be performed before merging

@hellais here's the initial list I identified based on our exchanges above. Please add to this list if you think there's something we should address here or by opening new issues.

@bassosimone
Copy link
Member Author

With the merging of ooni/probe-engine#37 we have enough pieces in place to move forward this PR. While the resolver_ip is not properly handled by the probe engine, it will be handled at a later stage. Also, because we're still on MK v0.10.4 with the engine, that does not matter, because MK writes the resolver_ip anyway. The main issue is that it performs a resolver lookup for each input, and that will be solved with MK v0.10.5 and a subsequent engine.

@hellais can you please take a final look to this branch?

```
go get -u github.com/ooni/probe-engine
go mod tidy
```
@hellais
Copy link
Member

hellais commented Aug 15, 2019

This branch looks good to me, however I think that the resolver_ip is still a bit of a blocker on cutting a new release on probe-cli.

For me it's good to go ahead with merging this PR, but it would be good to prioritise the resolver_ip lookup and writing functionality as it's pretty crucial.

@hellais
Copy link
Member

hellais commented Aug 15, 2019

Adding some notes from the discussion we had privately with @bassosimone.

It appears that adding the client_resolver key into the test_keys is not so seamless to do in the client. This friction highlights how this is most likely an issue in the specification and the most logical place to put it would in theory be in the top level keys.

However doing that introduces problems in data processing and normalisation which we aren't really sure how to handle.

In the best interest of moving forward I suggest that for the time being we add the client_resolver to the top level keys so that at least it's there and then we figure out what is the best strategy going forward for this prior to a stable launch/release.

@hellais hellais merged commit b9b555b into master Aug 15, 2019
DO NOT USE (was: OONI Probe Desktop) automation moved this from Review to Done Aug 15, 2019
@hellais hellais deleted the feature/episode-two branch August 15, 2019 16:08
ainghazal pushed a commit to ainghazal/probe-cli that referenced this pull request Mar 8, 2022
* utils/geoip.go: use github.com/ooni/probe-engine

Let's start using the engine by rewriting utils/geoip.go to
be just a thin wrapper around the engine functionality.

* Ready for review

* Checkpoint: the im tests are converted

Still have some doubts with respect to the variables that
are passed to MK via probe-engine. Will double check.

* fix(i/c/r/run.go): write the correct logic

* nettests: one more comment and also fix a format string

* Tweak previous

* progress

* Fix doofus

* better comment

* XXX => actionable comment

* Add glue to simplify test keys management

Making the concept of measurement more abstract in the engine is
not feasible because, when submitting a measurement, we need to
modify it to update the report ID and the measurement ID. Therefore,
returning a serialized measurement is not a good idea. We will
keep using a model.Measurement in the engine.

Changing model.Measurement.TestKeys's type from a `interface{}`
pointing to a well defined data structure to `map[string]interface{}`
is a regression because means that we are moving from code that
has a clear and defined structure to code that is more complicated
to parse and validate. Since we're already suffering havily from
the lack of a good schema, I'm not going to make the situation
worst by worsening the engine. At least for ndt7 and psiphon, we
now have a good schema and I don't want to lose that.

However, the current code in this repository is expecting the
test keys to be a `map[string]interface{}`. This choice was
dictated by the fact that we receive a JSON from Measurement Kit
and by the fact that there's not a clear schema.

To solve this tension, in this commit I am going to write glue
adapter code that makes sure that the TestKeys of a Measurement
are converted to `map[string]interface{}`. This will be done
using a type cast where possible and JSON serialization and parsing
otherwise. In a perfect world, glue is not a good idea, but in a
real world it may actually be useful.

When all tests in the engine will have a clear Go data structure,
we'll then remove the glue and just cast to the proper data
structure from `interface{}` where required.

* nettests/performance: use probe-engine

* go.{mod,sum}: upgrade to latest probe-engine

* nettests/middlebox: use ooni/probe-engine

* Update to the latest probe-engine

* web_connectivity: rewrite to use probe-engine

* Cosmetic change suggested by @hellais

* nettests/nettests.go: remove unused code

* nettests/nettests.go: fix progress

* nettests/nettests.go: remove go-measurement-kit code

* We don't depend on go-measurement-kit anymore

* Improve non-verbose output where possible

See also: measurement-kit/measurement-kit#1856

* Make web_connectivity output pleasant

* Update to the latest probe-engine

* nettests/nettests.go: honour sharing settings

* Update to the latest probe-engine

* Use log.WithFields for probe-engine

* Update go.mod go.sum

* Revert "Update go.mod go.sum"

This reverts commit 5ecd38d.

* Revert "Revert "Update go.mod go.sum""

This reverts commit 6114b31.

* Upgrade ooni/probe-engine

* Unset GOPATH before running go build commands

* Dockefile: fix linux build by using latest

* Update to the latest ooni/probe-engine

```
go get -u github.com/ooni/probe-engine
go mod tidy
```

* Repair build
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request OTFy2 OTF contract - second year
Projects
No open projects
2 participants