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

Add netemx tests for webconnectivitylte #1185

Closed
wants to merge 36 commits into from

Conversation

kelmenhorst
Copy link
Contributor

Checklist

Description

This diff implements netemx testing for webconnectivitylte by doing the following high-level things:

  • Move most code in internal/cmd/oohelperd to internal/oohelperd such that this library can be used by our tests.
  • Refactor netxlite w.r.t. the underlying network (this change enables us to run multiple stacks in the QAEnv)
    • stdlib dialers/resolvers/handshakers now optionally own an instance of model.UnderlyingNetwork that, if set, is used instead of tproxySingleton()
    • internal/netxlite/net.go now contains the high-level struct Net which wraps an UnderlyingNetwork. Its methods are constructors that mimic constructors in netxlite, e.g. NewDialerWithResolver. These constructor methods return dialers/resolvers/handshakers which use this Net's UnderlyingNetwork.
  • Add a success case and DPI case as integration tests for webconnectivitylte. Note that we can now run both the probe as well as the testhelper as separate stacks in the testing environment.

bassosimone added a commit that referenced this pull request Aug 23, 2023
This diff has been extracted from
#1185 and modifies
netxlite/filtering to export the DNSComposeResponse function. The
reference issue is ooni/probe#2461.

---------

Co-authored-by: kelmenhorst <k.elmenhorst@mailbox.org>
ipAddr := net.ParseIP(addr)
runtimex.Assert(ipAddr != nil, "invalid IP addr")
handler := factory.NewHandler(stack)
closables = env.serverListen(stack, handler, addr)
Copy link
Contributor

Choose a reason for hiding this comment

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

I think here we should append to the closables rather than assigning.

bassosimone added a commit that referenced this pull request Aug 24, 2023
This diff factors the function used for listening out of the loop where we
create all the servers stacks. The same diff is part of the original PR that
introduced these changes: #1185.

The intent of pushing this commit is to make sure the diff we're merging
next is easier to understand because there's no refactoring noise.

Reference issue: ooni/probe#2461.
bassosimone added a commit that referenced this pull request Aug 24, 2023
This diff factors the function used for listening out of the loop where
we create all the servers stacks. The same diff is part of the original
PR that introduced these changes:
#1185.

The intent of pushing this commit is to make sure the diff we're merging
next is easier to understand because there's no refactoring noise.

Reference issue: ooni/probe#2461.

---------

Co-authored-by: kelmenhorst <k.elmenhorst@mailbox.org>
bassosimone added a commit that referenced this pull request Aug 24, 2023
The oohelperd `http.Handler` constructor needs a reference to a
`model.UnderlyingNetwork` that will be used for fetching websites and
verifying that they're accessible. This diff changes how `netemx` works
such that we can construct an `http.Handler` that depends on a
`model.UnderlyingNetwork`, thus enabling this use case.

This diff has been adapted from
#1185.

The reference issue is ooni/probe#2461.

---------

Co-authored-by: kelmenhorst <k.elmenhorst@mailbox.org>
bassosimone added a commit that referenced this pull request Aug 24, 2023
This diff implements the subset of the OONI API required for testing Web
Connectivity LTE using netemx.

Diff adapted from: #1185.

Reference issue: ooni/probe#2461.

---------

Co-authored-by: kelmenhorst <k.elmenhorst@mailbox.org>
bassosimone added a commit that referenced this pull request Aug 24, 2023
This diff extends netemx to add support for simulating the oohelperd
using netem.

We extracted this diff from #1185.

The reference issue is ooni/probe#2461.

We're now well positioned to write netemx-based tests for Web
Connectivity 🥳 🥳 🥳 🥳 !

---------

Co-authored-by: kelmenhorst <k.elmenhorst@mailbox.org>
bassosimone added a commit that referenced this pull request Aug 24, 2023
This diff introduces code to emulate a large-scale scenario with several
servers. This scenario is suitable for writing Web Connectivity
integration tests because it includes a test helper, the OONI API, a
GeoIP service, etc.

This work derives from #1185 and
is part of ooni/probe#2461.

---------

Co-authored-by: kelmenhorst <k.elmenhorst@mailbox.org>
@bassosimone
Copy link
Contributor

I have split this PR in several smaller PRs and integrated the code in master.

Murphy-OrangeMud pushed a commit to Murphy-OrangeMud/probe-cli that referenced this pull request Feb 13, 2024
This diff has been extracted from
ooni#1185 and modifies
netxlite/filtering to export the DNSComposeResponse function. The
reference issue is ooni/probe#2461.

---------

Co-authored-by: kelmenhorst <k.elmenhorst@mailbox.org>
Murphy-OrangeMud pushed a commit to Murphy-OrangeMud/probe-cli that referenced this pull request Feb 13, 2024
Code in netxlite is currently tightly coupled with the tproxy singleton
(i.e., with a `model.UnderlyingNetwork`). Unfortunately, to write netemx
tests for Web Connectivity v0.5, we need to break this coupling. In
fact, we need the test helper's code to use a different underlying
network that uses a different IP address and is not censored, unlike the
network used by the probe.

To this end, in this diff we're introducing a nil-safe provider for a
tproxy. When the provider struct pointer is nil or the tproxy field is
nil, the code behaves as before and uses the tproxy singleton.
Otherwise, the code will use the given tproxy. Then we modify
fundamental types to explicitly depend on this nil-safe provider rather
than implicitly depending on the tproxy singleton.

We're soon going to take advantage of this diff and introduce support
for constructing common netxlite types using a custom tproxy that is not
a singleton but rather is a field of a concrete "net" structure.

This work has been extracted and adapted from
ooni#1185. The reference issue for
this pull request is ooni/probe#2461.

---------

Co-authored-by: kelmenhorst <k.elmenhorst@mailbox.org>
Murphy-OrangeMud pushed a commit to Murphy-OrangeMud/probe-cli that referenced this pull request Feb 13, 2024
)

This diff introduces the netxlite.Netx type. This type depends on a
model.UnderlyingNetwork. When the underlying network is nil, using this
type is equivalent to using netxlite toplevel functions directly.

To simplify testing this diff, let's move the netem->netxlite
UnderlyingNetworkAdapter from netemx and let's use netem to write tests,
so we can have confidence specifically about the most common use case of
overriding the underlying network.

Originally part of ooni#1185.

The reference issue is ooni/probe#2461.

---------

Co-authored-by: kelmenhorst <k.elmenhorst@mailbox.org>
Murphy-OrangeMud pushed a commit to Murphy-OrangeMud/probe-cli that referenced this pull request Feb 13, 2024
The ooni#1185 PR originally defined
this server in the `internal/netemx` package, but I chose to move this
functionality into the much-lower-level `testingx` package. The
rationale for moving this functionality is that a DNS-over-HTTPS server
is useful in several test cases, so it should be as general as possible.

This work is part of ooni/probe#2461

---------

Co-authored-by: kelmenhorst <k.elmenhorst@mailbox.org>
Murphy-OrangeMud pushed a commit to Murphy-OrangeMud/probe-cli that referenced this pull request Feb 13, 2024
This diff implements the Ubuntu GeoIP resolver service inside of the
testingx package.

Original code: ooni#1185.

Reference issue: ooni/probe#2461.

---------

Co-authored-by: kelmenhorst <k.elmenhorst@mailbox.org>
Murphy-OrangeMud pushed a commit to Murphy-OrangeMud/probe-cli that referenced this pull request Feb 13, 2024
This diff factors the function used for listening out of the loop where
we create all the servers stacks. The same diff is part of the original
PR that introduced these changes:
ooni#1185.

The intent of pushing this commit is to make sure the diff we're merging
next is easier to understand because there's no refactoring noise.

Reference issue: ooni/probe#2461.

---------

Co-authored-by: kelmenhorst <k.elmenhorst@mailbox.org>
Murphy-OrangeMud pushed a commit to Murphy-OrangeMud/probe-cli that referenced this pull request Feb 13, 2024
The oohelperd `http.Handler` constructor needs a reference to a
`model.UnderlyingNetwork` that will be used for fetching websites and
verifying that they're accessible. This diff changes how `netemx` works
such that we can construct an `http.Handler` that depends on a
`model.UnderlyingNetwork`, thus enabling this use case.

This diff has been adapted from
ooni#1185.

The reference issue is ooni/probe#2461.

---------

Co-authored-by: kelmenhorst <k.elmenhorst@mailbox.org>
Murphy-OrangeMud pushed a commit to Murphy-OrangeMud/probe-cli that referenced this pull request Feb 13, 2024
This diff implements the subset of the OONI API required for testing Web
Connectivity LTE using netemx.

Diff adapted from: ooni#1185.

Reference issue: ooni/probe#2461.

---------

Co-authored-by: kelmenhorst <k.elmenhorst@mailbox.org>
Murphy-OrangeMud pushed a commit to Murphy-OrangeMud/probe-cli that referenced this pull request Feb 13, 2024
This diff extends netemx to add support for simulating the oohelperd
using netem.

We extracted this diff from ooni#1185.

The reference issue is ooni/probe#2461.

We're now well positioned to write netemx-based tests for Web
Connectivity 🥳 🥳 🥳 🥳 !

---------

Co-authored-by: kelmenhorst <k.elmenhorst@mailbox.org>
Murphy-OrangeMud pushed a commit to Murphy-OrangeMud/probe-cli that referenced this pull request Feb 13, 2024
This diff introduces code to emulate a large-scale scenario with several
servers. This scenario is suitable for writing Web Connectivity
integration tests because it includes a test helper, the OONI API, a
GeoIP service, etc.

This work derives from ooni#1185 and
is part of ooni/probe#2461.

---------

Co-authored-by: kelmenhorst <k.elmenhorst@mailbox.org>
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.

2 participants