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:
parent
53e6b694cb
commit
0f61778e7a
6 changed files with 481 additions and 17 deletions
28
pkg/oonimkall/webconnectivity_integration_test.go
Normal file
28
pkg/oonimkall/webconnectivity_integration_test.go
Normal 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))
|
||||
}
|
||||
Loading…
Reference in a new issue