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

fix: provide good default input for dnscheck and stunreachability #539

Closed
wants to merge 17 commits into from

Conversation

hellais
Copy link
Member

@hellais hellais commented Oct 12, 2021

Checklist

Description

This diff aims to solve the problem that dnscheck and stunreachability are not easily runnable from ooniprobe. We started with a small diff, and then we needed to hammer other pieces of the codebase to make it WAI.

This diff will need to be backported to the release/3.11 branch. (Also, this diff will work better when using the release/3.11 branch because ooni/probe#1816 and ooni/probe#1808 make the master branch not always ideal, but we started on master and I'd say we merge on master and then backport.)

@hellais hellais requested a review from bassosimone as a code owner October 12, 2021 15:55
@hellais
Copy link
Member Author

hellais commented Oct 12, 2021

This doesn't actually work as it crashes with the following stacktrace:

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0xf0 pc=0x4a69991]

@bassosimone
Copy link
Contributor

@hellais ouch, so I guess we gotta figure out why :-(

Copy link
Contributor

@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.

We need to figure out why it's crashing, so I'm using the "request changes" feature to signal that we're not quite done here yet.

@bassosimone bassosimone changed the title Fix issue with the test_name of dnscheck being run fix: provide good default input for dnscheck and stunreachability Oct 13, 2021
@bassosimone
Copy link
Contributor

@hellais I have fixed the way in which the code works and it should be okay now. Could you please test it? I am going to figure out why it was crashing after your initial diff and apply fixes/write tests as a follow up step.

@bassosimone bassosimone dismissed their stale review October 13, 2021 08:51

Dismissing my review since I introduced significant changes on the same branch :^)

@hellais
Copy link
Member Author

hellais commented Oct 13, 2021

I tested this branch and I can confirm that it's not crashing on the running of the test anymore.

However the show command for both the stunreachability and the dnscheck tests is not working as expected.

This is the output of a show command:

./ooniprobe -v show 30528
   • ooni version 3.11.0-alpha
   • Reading default config file
   • Connecting to database sqlite3:///Users/art/.ooniprobe/db/main.sqlite3
   • running migrations
   • performed 0 migrations
   • using https://api.ooni.io/api/v1/raw_measurement?report_id=20211013T143221Z_stunreachability_IT_30722_n1_C21JUQ865m4eaZbb
{
  "error": ""
}%

I believe the reason for it failing to do the lookup is that it's not passing the input value to the raw_measurement lookup query. I suspect this is due to the fact that we aren't telling probe-cli that this test is a multi-input test and it doesn't record the input value inside of the table for it.

We're about to make the stun experiment a first class citizen of
ooniprobe as part of the `ooniprobe run experimental` command.

All ooniprobe tests require a URL as their input. So, make stun no
exception and add require the `stun://` scheme now.
bassosimone added a commit to ooni/spec that referenced this pull request Nov 26, 2021
1. the input MUST now be an URL

2. there is no default input anymore

See ooni/probe-cli#539
bassosimone added a commit to ooni/spec that referenced this pull request Nov 26, 2021
1. the input MUST now be an URL

2. there is no default input anymore

See ooni/probe-cli#539
Copy link
Contributor

@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 a round of self code review

if err != nil {
return nil, err
}
return ctl.BuildAndSetInputIdxMap(ctl.Probe.DB(), testlist)
Copy link
Contributor

Choose a reason for hiding this comment

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

Explanation of the changes in this file: DNSCheck now has a lookupURLs method that uses the engine's InputLoader with the InputOrStaticDefault policy. The end result is that we use --input or --input-files if they are provided. Otherwise, we fallback to a static input list defined in the engine.

}

// Run starts the nettest.
func (n DNSCheck) Run(ctl *Controller) error {
builder, err := ctl.Session.NewExperimentBuilder("run")
builder, err := ctl.Session.NewExperimentBuilder("dnscheck")
Copy link
Contributor

Choose a reason for hiding this comment

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

This two-lines change above is what we started from. Originally dnscheck here used the engine's run functionality to run tests with many options. Yet, we cannot do that easily. So, we fallback to running dnscheck directly with the afore-mentioned "static input" mechanism.

urls = append(urls, url.URL)
}
c.inputIdxMap = urlIDMap
return urls, nil
Copy link
Contributor

Choose a reason for hiding this comment

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

This function factors code that previously was Web-Connectivity specific. We now have a mechanism that all tests can use to configure their input so that it's stored into the inputs URL. Because the data model assumes an URL, this means we also changed stunreachability to require URLs as input for consistency (you'll see this later).

cmd/ooniprobe/internal/nettests/dnscheck.go Outdated Show resolved Hide resolved
}
return ctl.BuildAndSetInputIdxMap(ctl.Probe.DB(), testlist)
}

Copy link
Contributor

Choose a reason for hiding this comment

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

This diff is simular to the dnscheck one. Also here we use the default static input if no input is provided.

// StaticBareInputForExperiment returns the list of strings an
// experiment should use as static input. In case there is no
// static input for this experiment, we return an error.
func StaticBareInputForExperiment(name string) ([]string, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

This function is public because pkg/oonimkall does not use InputLoader directly for loading inputs. There is need to refactor how we run experiments on mobile. (やれやれ)

internal/engine/inputloader_test.go Outdated Show resolved Hide resolved
"stun:stun.voipgate.com:3478",
"stun:stun.voys.nl:3478",
}
return stuninput.AsSnowflakeInput()
Copy link
Contributor

Choose a reason for hiding this comment

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

Rather than having two static copies of STUN targets (one for snowflake and one for stunreachability), I have created a single package that keeps those copies.

pkg/oonimkall/internal/tasks/runner.go Outdated Show resolved Hide resolved
}
r.settings.Inputs = inputs
default:
r.settings.Inputs = append(r.settings.Inputs, "")
Copy link
Contributor

Choose a reason for hiding this comment

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

Ouch, these two lines are wrong, we should make the switch exhaustive I think

@bassosimone
Copy link
Contributor

The code in here is not ready yet. I think it starts to be clear that we need to improve testing a bit inside the pkg/oonimkall package, after I have changed the code handling input. I think we're currently using a lot this example experiment to test for things, but perhaps it would be better to just use the real experiments. This would give us greater confidence. Also, there is some annoying duplication of testing between pkg/oonimkall and pkg/oonimkall/tasks. As bad as it may be to further complicate this diff, I think there is some need to consolidate and improve how we test pkg/oonimkall. Maybe the right thing to do is to move some bits of this diff out to smaller diffs and apply more refactoring. After all, here we are touching code that is quite old, so it's reasonable we have to do some more working. I'm going to convert this PR to draft for the time being to reflect the fact that I think it's not completely ready yet.

@bassosimone
Copy link
Contributor

The work mentioned in #539 (comment) has now been done in ooni/probe#1903. It's now time to resume work on this PR and land it at last!

Conflicts:
	internal/engine/allexperiments.go
	pkg/oonimkall/internal/tasks/runner_integration_test.go
	pkg/oonimkall/taskrunner.go
bassosimone added a commit that referenced this pull request Dec 3, 2021
Here we're refactoring stunreachability to not provide internally a
default input and to take in input an URL rather than a string.

The related ooni/spec change is ooni/spec#227.

This diff has been extracted from #539.

Because the original diff was large, I'm splitting it in a set of
more easily manageable diffs.

The reference issue is ooni/probe#1814, which
is complex enough to require us to proceed incrementally.

This diff WILL need to be backported to release/3.11.
bassosimone added a commit that referenced this pull request Dec 3, 2021
We want stunreachability to use the same STUN servers used by
snowflake, so let's start by making a common package holding the
servers. Let's also use this new package in Snowflake.

We're currently not using this package in stunreachability, but
I am going to apply this as a subsequent diff.

Reference issue: ooni/probe#1814. This
issue is a bit complex to address in a single PR, so we are going
to proceed incremntally.

This diff was extracted from #539.
bassosimone added a commit that referenced this pull request Dec 3, 2021
This commit introduces a new `InputLoader` policy by which, if no
input is provided, we use a static default input list.

We also modify the code to use this policy for dnscheck and
stunreachability, with proper input.

We also modify `miniooni` to pass the new `ExperimentName` field to
the `InputLoader` to indicate which default input list to use.

This diff is part of a set of diffs aiming at fixing
ooni/probe#1814 and has been
extracted from #539.

What remains to be done, after this diff has landed is to ensure
things also work for ooniprobe and oonimkall.
bassosimone added a commit that referenced this pull request Dec 3, 2021
This commit introduces a new `InputLoader` policy by which, if no
input is provided, we use a static default input list.

We also modify the code to use this policy for dnscheck and
stunreachability, with proper input.

We also modify `miniooni` to pass the new `ExperimentName` field to
the `InputLoader` to indicate which default input list to use.

This diff is part of a set of diffs aiming at fixing
ooni/probe#1814 and has been
extracted from #539.

What remains to be done, after this diff has landed is to ensure
things also work for ooniprobe and oonimkall.
Conflicts:
	internal/engine/inputloader.go
	internal/engine/inputloader_test.go
bassosimone added a commit that referenced this pull request Dec 3, 2021
This diff is part of ooni/probe#1814 and
teaches `ooniprobe` to run dnscheck and stunreachability by using the
default static input feature of the `InputLoader`.

I've manually tested that we can still run `websites` like
we did before (including category filtering).

I've also manually tested that now we can run `experimental` and
get parseable results for dnscheck and stunreachability.

With this diff in, we have fixed the original problem highlighted in
the ooni/probe#1814 issue.

Yet, because of the way in which I solved the problem, there is
more work to do. My changes have broken stunreachability for
mobile and now it's time I apply fixes to make it work again.

This diff was extracted from #539,
which at this point only basically contains the remaining fixes to
ensure we can run stunreachability on mobile.

Co-authored-by: Arturo Filastò <arturo@filasto.net>
bassosimone added a commit that referenced this pull request Dec 3, 2021
This diff is part of ooni/probe#1814 and
teaches `ooniprobe` to run dnscheck and stunreachability by using the
default static input feature of the `InputLoader`.

I've manually tested that we can still run `websites` like
we did before (including category filtering).

I've also manually tested that now we can run `experimental` and
get parseable results for dnscheck and stunreachability.

With this diff in, we have fixed the original problem highlighted in
the ooni/probe#1814 issue.

Yet, because of the way in which I solved the problem, there is
more work to do. My changes have broken stunreachability for
mobile and now it's time I apply fixes to make it work again.

This diff was extracted from #539,
which at this point only basically contains the remaining fixes to
ensure we can run stunreachability on mobile.

Co-authored-by: Arturo Filastò <arturo@filasto.net>

Co-authored-by: Arturo Filastò <arturo@filasto.net>
bassosimone added a commit that referenced this pull request Dec 3, 2021
Previous work to make ooni/probe#1814
possible has broken running stunreachability on mobile.

This diff repairs the blunder and allows to run any experiment
using InputOrStaticDefault with oonimkall.

Diff extracted from #539.
bassosimone added a commit that referenced this pull request Dec 3, 2021
Previous work to make ooni/probe#1814
possible has broken running stunreachability on mobile.

This diff repairs the blunder and allows to run any experiment
using InputOrStaticDefault with oonimkall.

Diff extracted from #539.
Conflicts:
	pkg/oonimkall/taskrunner.go
@bassosimone
Copy link
Contributor

All the work that was part of this PR has been split into smaller patches and applied separately. We can close now.

@bassosimone bassosimone closed this Dec 3, 2021
@bassosimone bassosimone deleted the fix/1814 branch December 3, 2021 16:44
bassosimone added a commit that referenced this pull request Dec 3, 2021
…URL (#630)

Here we're refactoring stunreachability to not provide internally a
default input and to take in input an URL rather than a string.

The related ooni/spec change is ooni/spec#227.

This diff has been extracted from #539.

Because the original diff was large, I'm splitting it in a set of
more easily manageable diffs.

The reference issue is ooni/probe#1814, which
is complex enough to require us to proceed incrementally.

This diff WILL need to be backported to release/3.11.
bassosimone added a commit that referenced this pull request Dec 3, 2021
We want stunreachability to use the same STUN servers used by
snowflake, so let's start by making a common package holding the
servers. Let's also use this new package in Snowflake.

We're currently not using this package in stunreachability, but
I am going to apply this as a subsequent diff.

Reference issue: ooni/probe#1814. This
issue is a bit complex to address in a single PR, so we are going
to proceed incremntally.

This diff was extracted from #539.
bassosimone added a commit that referenced this pull request Dec 3, 2021
This commit introduces a new `InputLoader` policy by which, if no
input is provided, we use a static default input list.

We also modify the code to use this policy for dnscheck and
stunreachability, with proper input.

We also modify `miniooni` to pass the new `ExperimentName` field to
the `InputLoader` to indicate which default input list to use.

This diff is part of a set of diffs aiming at fixing
ooni/probe#1814 and has been
extracted from #539.

What remains to be done, after this diff has landed is to ensure
things also work for ooniprobe and oonimkall.
bassosimone added a commit that referenced this pull request Dec 3, 2021
…nput (#633)

This diff is part of ooni/probe#1814 and
teaches `ooniprobe` to run dnscheck and stunreachability by using the
default static input feature of the `InputLoader`.

I've manually tested that we can still run `websites` like
we did before (including category filtering).

I've also manually tested that now we can run `experimental` and
get parseable results for dnscheck and stunreachability.

With this diff in, we have fixed the original problem highlighted in
the ooni/probe#1814 issue.

Yet, because of the way in which I solved the problem, there is
more work to do. My changes have broken stunreachability for
mobile and now it's time I apply fixes to make it work again.

This diff was extracted from #539,
which at this point only basically contains the remaining fixes to
ensure we can run stunreachability on mobile.

Co-authored-by: Arturo Filastò <arturo@filasto.net>

Co-authored-by: Arturo Filastò <arturo@filasto.net>
bassosimone added a commit that referenced this pull request Dec 3, 2021
…#634)

Previous work to make ooni/probe#1814
possible has broken running stunreachability on mobile.

This diff repairs the blunder and allows to run any experiment
using InputOrStaticDefault with oonimkall.

Diff extracted from #539.
bassosimone added a commit that referenced this pull request Dec 3, 2021
* [backport] refactor(stunreachability): input required and must be an URL (#630)

Here we're refactoring stunreachability to not provide internally a
default input and to take in input an URL rather than a string.

The related ooni/spec change is ooni/spec#227.

This diff has been extracted from #539.

Because the original diff was large, I'm splitting it in a set of
more easily manageable diffs.

The reference issue is ooni/probe#1814, which
is complex enough to require us to proceed incrementally.

This diff WILL need to be backported to release/3.11.

* [backport] refactor: create common package for holding STUN input (#631)

We want stunreachability to use the same STUN servers used by
snowflake, so let's start by making a common package holding the
servers. Let's also use this new package in Snowflake.

We're currently not using this package in stunreachability, but
I am going to apply this as a subsequent diff.

Reference issue: ooni/probe#1814. This
issue is a bit complex to address in a single PR, so we are going
to proceed incremntally.

This diff was extracted from #539.

* [backport] refactor: introduce and use InputOrStaticDefault (#632)

This commit introduces a new `InputLoader` policy by which, if no
input is provided, we use a static default input list.

We also modify the code to use this policy for dnscheck and
stunreachability, with proper input.

We also modify `miniooni` to pass the new `ExperimentName` field to
the `InputLoader` to indicate which default input list to use.

This diff is part of a set of diffs aiming at fixing
ooni/probe#1814 and has been
extracted from #539.

What remains to be done, after this diff has landed is to ensure
things also work for ooniprobe and oonimkall.

* [backport] fix(ooniprobe): dnscheck,stunreachability run w/ default input (#633)

This diff is part of ooni/probe#1814 and
teaches `ooniprobe` to run dnscheck and stunreachability by using the
default static input feature of the `InputLoader`.

I've manually tested that we can still run `websites` like
we did before (including category filtering).

I've also manually tested that now we can run `experimental` and
get parseable results for dnscheck and stunreachability.

With this diff in, we have fixed the original problem highlighted in
the ooni/probe#1814 issue.

Yet, because of the way in which I solved the problem, there is
more work to do. My changes have broken stunreachability for
mobile and now it's time I apply fixes to make it work again.

This diff was extracted from #539,
which at this point only basically contains the remaining fixes to
ensure we can run stunreachability on mobile.

Co-authored-by: Arturo Filastò <arturo@filasto.net>

Co-authored-by: Arturo Filastò <arturo@filasto.net>

* [backport] fix(oonimkall): run tests with InputOrStaticDefault policy (#634)

Previous work to make ooni/probe#1814
possible has broken running stunreachability on mobile.

This diff repairs the blunder and allows to run any experiment
using InputOrStaticDefault with oonimkall.

Diff extracted from #539.

Co-authored-by: Arturo Filastò <arturo@filasto.net>
ainghazal pushed a commit to ainghazal/probe-cli that referenced this pull request Mar 8, 2022
Here we're refactoring stunreachability to not provide internally a
default input and to take in input an URL rather than a string.

The related ooni/spec change is ooni/spec#227.

This diff has been extracted from ooni#539.

Because the original diff was large, I'm splitting it in a set of
more easily manageable diffs.

The reference issue is ooni/probe#1814, which
is complex enough to require us to proceed incrementally.

This diff WILL need to be backported to release/3.11.
ainghazal pushed a commit to ainghazal/probe-cli that referenced this pull request Mar 8, 2022
We want stunreachability to use the same STUN servers used by
snowflake, so let's start by making a common package holding the
servers. Let's also use this new package in Snowflake.

We're currently not using this package in stunreachability, but
I am going to apply this as a subsequent diff.

Reference issue: ooni/probe#1814. This
issue is a bit complex to address in a single PR, so we are going
to proceed incremntally.

This diff was extracted from ooni#539.
ainghazal pushed a commit to ainghazal/probe-cli that referenced this pull request Mar 8, 2022
This commit introduces a new `InputLoader` policy by which, if no
input is provided, we use a static default input list.

We also modify the code to use this policy for dnscheck and
stunreachability, with proper input.

We also modify `miniooni` to pass the new `ExperimentName` field to
the `InputLoader` to indicate which default input list to use.

This diff is part of a set of diffs aiming at fixing
ooni/probe#1814 and has been
extracted from ooni#539.

What remains to be done, after this diff has landed is to ensure
things also work for ooniprobe and oonimkall.
ainghazal pushed a commit to ainghazal/probe-cli that referenced this pull request Mar 8, 2022
)

This diff is part of ooni/probe#1814 and
teaches `ooniprobe` to run dnscheck and stunreachability by using the
default static input feature of the `InputLoader`.

I've manually tested that we can still run `websites` like
we did before (including category filtering).

I've also manually tested that now we can run `experimental` and
get parseable results for dnscheck and stunreachability.

With this diff in, we have fixed the original problem highlighted in
the ooni/probe#1814 issue.

Yet, because of the way in which I solved the problem, there is
more work to do. My changes have broken stunreachability for
mobile and now it's time I apply fixes to make it work again.

This diff was extracted from ooni#539,
which at this point only basically contains the remaining fixes to
ensure we can run stunreachability on mobile.

Co-authored-by: Arturo Filastò <arturo@filasto.net>

Co-authored-by: Arturo Filastò <arturo@filasto.net>
ainghazal pushed a commit to ainghazal/probe-cli that referenced this pull request Mar 8, 2022
Previous work to make ooni/probe#1814
possible has broken running stunreachability on mobile.

This diff repairs the blunder and allows to run any experiment
using InputOrStaticDefault with oonimkall.

Diff extracted from ooni#539.
@Xredmi
Copy link

Xredmi commented Nov 13, 2022

Checklist

Description

This diff aims to solve the problem that dnscheck and stunreachability are not easily runnable from ooniprobe. We started with a small diff, and then we needed to hammer other pieces of the codebase to make it WAI.

This diff will need to be backported to the release/3.11 branch. (Also, this diff will work better when using the release/3.11 branch because ooni/probe#1816 and ooni/probe#1808 make the master branch not always ideal, but we started on master and I'd say we merge on master and then backport.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants