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 API access method tests #5798

Merged
merged 7 commits into from
Feb 15, 2024

Conversation

MarkusPettersson98
Copy link
Contributor

@MarkusPettersson98 MarkusPettersson98 commented Feb 9, 2024

This PR add tests for custom API access methods to the integration test suite.


This change is Reviewable

Copy link

linear bot commented Feb 9, 2024

Copy link
Member

@dlon dlon left a comment

Choose a reason for hiding this comment

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

Reviewed 3 of 3 files at r1, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @MarkusPettersson98)


test/test-manager/src/tests/access_methods.rs line 59 at r1 (raw file):

    let bridge = relay_list
        .relays()
        .filter(|relay| matches!(relay.endpoint_data, RelayEndpointData::Bridge))

This should probably filter on active too. Maybe it should also select a random relay to avoid the problem we had earlier.

@MarkusPettersson98 MarkusPettersson98 force-pushed the add-api-access-method-daemon-tests-des-607 branch 2 times, most recently from 1f44008 to 2cfe49e Compare February 12, 2024 08:47
@MarkusPettersson98 MarkusPettersson98 marked this pull request as ready for review February 12, 2024 09:45
Copy link
Member

@dlon dlon left a comment

Choose a reason for hiding this comment

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

Reviewed 1 of 1 files at r2, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved

@MarkusPettersson98 MarkusPettersson98 force-pushed the add-api-access-method-daemon-tests-des-607 branch 2 times, most recently from 509fb32 to 34c0754 Compare February 12, 2024 10:39
Copy link
Member

@dlon dlon left a comment

Choose a reason for hiding this comment

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

Reviewed 3 of 3 files at r3, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved

@MarkusPettersson98 MarkusPettersson98 force-pushed the add-api-access-method-daemon-tests-des-607 branch 5 times, most recently from f3e7806 to ea54490 Compare February 12, 2024 13:32
Copy link
Member

@dlon dlon left a comment

Choose a reason for hiding this comment

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

Reviewed 2 of 2 files at r4, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @MarkusPettersson98)


test/.cargo/config.toml line 5 at r4 (raw file):

[env]
LIBMNL_LIB_DIR   = { value = "../dist-assets/binaries", relative = true }

Awesome. I wonder if we can just use this in the main workspace as well (instead of using env.sh).

Is setting SDKROOT required for macOS?

@MarkusPettersson98 MarkusPettersson98 force-pushed the add-api-access-method-daemon-tests-des-607 branch 2 times, most recently from 307ea7e to dbfcb44 Compare February 12, 2024 13:53
Copy link
Member

@dlon dlon left a comment

Choose a reason for hiding this comment

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

Reviewed 2 of 2 files at r5, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @MarkusPettersson98)

Copy link
Member

@dlon dlon left a comment

Choose a reason for hiding this comment

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

Reviewed 8 of 8 files at r6, all commit messages.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @MarkusPettersson98)


talpid-future/src/lib.rs line 4 at r6 (raw file):

#![deny(missing_docs)]

pub mod future_retry;

Nit: future_ could probably be removed?

@MarkusPettersson98 MarkusPettersson98 force-pushed the add-api-access-method-daemon-tests-des-607 branch 3 times, most recently from 4622fff to e3681f9 Compare February 13, 2024 08:49
Copy link
Member

@dlon dlon left a comment

Choose a reason for hiding this comment

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

Reviewed 8 of 8 files at r7, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @MarkusPettersson98)

@MarkusPettersson98 MarkusPettersson98 force-pushed the add-api-access-method-daemon-tests-des-607 branch 6 times, most recently from 3be8a7c to 6c69738 Compare February 13, 2024 10:48
@MarkusPettersson98 MarkusPettersson98 force-pushed the add-api-access-method-daemon-tests-des-607 branch 4 times, most recently from 965e563 to 2cbd204 Compare February 13, 2024 13:19
Copy link
Member

@dlon dlon left a comment

Choose a reason for hiding this comment

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

Reviewed 15 of 15 files at r8, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved

@MarkusPettersson98 MarkusPettersson98 force-pushed the add-api-access-method-daemon-tests-des-607 branch 3 times, most recently from af16fd5 to 0b88707 Compare February 14, 2024 11:17
Copy link
Member

@dlon dlon left a comment

Choose a reason for hiding this comment

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

Reviewed 6 of 6 files at r9, 2 of 2 files at r11, all commit messages.
Reviewable status: all files reviewed, 3 unresolved discussions (waiting on @MarkusPettersson98)


mullvad-api/src/lib.rs line 177 at r11 (raw file):

            disable_tls: false,
            force_direct: force_direct
                .map(|force_direct_env| force_direct_env.to_lowercase() != "false")

We seem to check if var != "0" for other boolean env vars. false might be objectively better, but it's inconsistent, so maybe we should stick to 0?


mullvad-daemon/src/api.rs line 247 at r9 (raw file):

        let (index, next) = Self::get_next_inner(
            access_method_settings.cardinality(),

Off by one?


test/test-manager/src/tests/ui.rs line 167 at r9 (raw file):

    // `MULLVAD_API_FORCE_DIRECT=false` and restarting the daemon.

    let (host, endpoint) = (mullvad_api::API.host(), mullvad_api::API.address());

We should probably take these from TEST_CONFIG. See get_app_env().


test/test-manager/src/tests/ui.rs line 223 at r11 (raw file):

    tokio::time::timeout(
        std::time::Duration::from_secs(60),
        rpc.set_daemon_environment(env),

In my opinion, we should either make sure that the test always cleans up the environment, somehow, or set must_succeed = true on it. Otherwise, we get sort of an inconsistent state for any remaining tests.

Copy link
Member

@dlon dlon left a comment

Choose a reason for hiding this comment

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

Reviewable status: all files reviewed, 3 unresolved discussions (waiting on @MarkusPettersson98)


mullvad-api/src/lib.rs line 256 at r11 (raw file):

        ];

        if env_vars.map(Self::read_var).iter().any(Option::is_some) {

Nice trick!

@MarkusPettersson98 MarkusPettersson98 force-pushed the add-api-access-method-daemon-tests-des-607 branch 6 times, most recently from 608d1dd to a6b504f Compare February 15, 2024 12:53
Copy link
Contributor Author

@MarkusPettersson98 MarkusPettersson98 left a comment

Choose a reason for hiding this comment

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

Reviewable status: 23 of 32 files reviewed, 3 unresolved discussions (waiting on @dlon)


mullvad-api/src/lib.rs line 177 at r11 (raw file):

Previously, dlon (David Lönnhager) wrote…

We seem to check if var != "0" for other boolean env vars. false might be objectively better, but it's inconsistent, so maybe we should stick to 0?

True, it is better to be consistent. Fixed


mullvad-api/src/lib.rs line 256 at r11 (raw file):

Previously, dlon (David Lönnhager) wrote…

Nice trick!

Thanks!


mullvad-daemon/src/api.rs line 247 at r9 (raw file):

Previously, dlon (David Lönnhager) wrote…

Off by one?

This was fixed in a separate PR


talpid-future/src/lib.rs line 4 at r6 (raw file):

Previously, dlon (David Lönnhager) wrote…

Nit: future_ could probably be removed?

Done


test/test-manager/src/tests/access_methods.rs line 59 at r1 (raw file):

Previously, dlon (David Lönnhager) wrote…

This should probably filter on active too. Maybe it should also select a random relay to avoid the problem we had earlier.

Solved by using mullvad-relay-selector


test/test-manager/src/tests/ui.rs line 167 at r9 (raw file):

Previously, dlon (David Lönnhager) wrote…

We should probably take these from TEST_CONFIG. See get_app_env().

Done


test/.cargo/config.toml line 5 at r4 (raw file):

Previously, dlon (David Lönnhager) wrote…

Awesome. I wonder if we can just use this in the main workspace as well (instead of using env.sh).

Is setting SDKROOT required for macOS?

No longer relevant

Copy link
Contributor Author

@MarkusPettersson98 MarkusPettersson98 left a comment

Choose a reason for hiding this comment

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

Reviewable status: 23 of 32 files reviewed, 3 unresolved discussions (waiting on @dlon)


test/test-manager/src/tests/ui.rs line 223 at r11 (raw file):

Previously, dlon (David Lönnhager) wrote…

In my opinion, we should either make sure that the test always cleans up the environment, somehow, or set must_succeed = true on it. Otherwise, we get sort of an inconsistent state for any remaining tests.

Done by settings must_succeed = true

Copy link
Member

@dlon dlon left a comment

Choose a reason for hiding this comment

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

Reviewed 1 of 1 files at r12, 8 of 9 files at r13, 1 of 1 files at r14, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved

Refactor some parts of `talpid-core` to `talpid-future`.
Add Shadowsocks & SOCKS5 (remote) access method tests. Simply try to
access the Mullvad API using these custom access methods.
Since `test_custom_access_methods_ui` may fail after messing with the
test runner environment, we want to fail fast and abort the entire test
run if the test fails before managing to clean up.
@MarkusPettersson98 MarkusPettersson98 force-pushed the add-api-access-method-daemon-tests-des-607 branch from 23e9644 to 6980530 Compare February 15, 2024 15:28
@MarkusPettersson98 MarkusPettersson98 merged commit bf4fc6d into main Feb 15, 2024
51 of 54 checks passed
@MarkusPettersson98 MarkusPettersson98 deleted the add-api-access-method-daemon-tests-des-607 branch February 15, 2024 16:05
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