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

Use type safe protobuf client in test framework #5682

Conversation

MarkusPettersson98
Copy link
Contributor

@MarkusPettersson98 MarkusPettersson98 commented Jan 12, 2024

Re-write some code in the test framework to prefer the type safe wrapper around the Mullvad app gRPC client instead of its auto-generated dito.

ManagementServiceClient is automatically generated from the protobuf definitions found in management_interface.proto, and contains some very crude types. The MullvadProxyClient is a type-safe wrapper around ManagementServiceClient which performs conversions & validation of the data types from the gRPC server (the daemon) to their respective mappings in the talpid-* and mullvad-* crates. These types are more ergonomic to work with, and since we already have the conversions in place we should prefer those.

This PR also adds a clippy.toml to the test framework workspace. The only configuration for now is the lint disallowed-types which will warn on use of ManagementServiceClient.


This change is Reviewable

Copy link

linear bot commented Jan 12, 2024

@MarkusPettersson98 MarkusPettersson98 force-pushed the use-the-client-from-mullvad_management_interfaceclient-des-522 branch 2 times, most recently from ee643c9 to 7425298 Compare January 12, 2024 10:24
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.

Great stuff! 🥳

Reviewed 11 of 13 files at r1, 2 of 2 files at r2, 1 of 1 files at r3, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @MarkusPettersson98)


test/test-manager/src/tests/account.rs line 264 at r3 (raw file):

                tokio::time::sleep(THROTTLE_RETRY_DELAY).await;
            }
            Err(err) => return Err(err),

Does not truly matter, but it bothers me that we're using return here but break below for no good reason. 😅


test/test-manager/src/tests/mod.rs line 129 at r3 (raw file):

        .await
        .context("Could not clear split tunnel apps in cleanup")?;
    #[cfg(not(target_os = "macos"))]

This should only called on Linux.

@MarkusPettersson98 MarkusPettersson98 force-pushed the use-the-client-from-mullvad_management_interfaceclient-des-522 branch from 7425298 to f768135 Compare January 12, 2024 12:10
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: 12 of 14 files reviewed, 1 unresolved discussion (waiting on @dlon)


test/test-manager/src/tests/account.rs line 264 at r3 (raw file):

Previously, dlon (David Lönnhager) wrote…

Does not truly matter, but it bothers me that we're using return here but break below for no good reason. 😅

Yeah, changed this return to a break for consistency 😅


test/test-manager/src/tests/mod.rs line 129 at r3 (raw file):

Previously, dlon (David Lönnhager) wrote…

This should only called on Linux.

🤦
Fixed!

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.

:lgtm:

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

@MarkusPettersson98 MarkusPettersson98 force-pushed the use-the-client-from-mullvad_management_interfaceclient-des-522 branch 3 times, most recently from 6023cc7 to 8c1e963 Compare January 12, 2024 15:48
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 r5, 3 of 3 files at r6, 1 of 1 files at r7, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved

Re-write some code in the test framework to prefer the type safe wrapper
around the Mullvad app gRPC client instead of its auto-generated dito.

`ManagementServiceClient` is automatically generated from the protobuf
definitions found in `management_interface.proto`, and contains some
very crude types. The `MullvadProxyClient` is a type-safe wrapper around
`ManagementServiceClient` which performs conversions & validation of the
data types from the gRPC server (the daemon) to their respective
mappings in the `talpid-*` and `mullvad-*` crates. These types are more
ergonomic to work with, and since we already have the conversions in
place we should prefer those.
@MarkusPettersson98 MarkusPettersson98 force-pushed the use-the-client-from-mullvad_management_interfaceclient-des-522 branch from 8c1e963 to 87a7650 Compare January 15, 2024 07:14
@MarkusPettersson98 MarkusPettersson98 merged commit f653cde into main Jan 15, 2024
28 checks passed
@MarkusPettersson98 MarkusPettersson98 deleted the use-the-client-from-mullvad_management_interfaceclient-des-522 branch January 15, 2024 07:14
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