oonimkall: mobile api for running WebConnectivity (#223)

* poc: mobile api for running WebConnectivity

Yesterday we had a team meeting where we discussed the importance
of stopping using MK wrappers for running experiments.

Here's a PoC showing how we can do that for WebConnectivity. It
seems to me we probably want to add more tests and merge this code
such that we can experiment with it quite soon.

There seems to be opportunities for auto-generating code, BTW.

While working on this PoC, I've also took a chance to revamp the
external documentation of pkg/oonimkall.

* feat: start making the code more abstract

* chore: write unit tests for new code

* fix(oonimkall): improve naming

* refactor: cosmetic changes

* fix: explain
This commit is contained in:
Simone Basso 2021-03-18 08:44:58 +01:00 committed by GitHub
commit 0f61778e7a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 481 additions and 17 deletions

View file

@ -0,0 +1,28 @@
package oonimkall_test
import (
"testing"
"github.com/ooni/probe-cli/v3/pkg/oonimkall"
)
func TestSessionWebConnectivity(t *testing.T) {
if testing.Short() {
t.Skip("skip test in short mode")
}
sess, err := NewSessionForTesting()
if err != nil {
t.Fatal(err)
}
ctx := sess.NewContext()
config := &oonimkall.WebConnectivityConfig{
Input: "https://www.google.com",
}
results, err := sess.WebConnectivity(ctx, config)
if err != nil {
t.Fatal(err)
}
t.Logf("bytes received: %f", results.KibiBytesReceived)
t.Logf("bytes sent: %f", results.KibiBytesSent)
t.Logf("measurement: %d bytes", len(results.Measurement))
}