Skip to content

tests: add network test for 'Wired Connection' assumptions in Cockpit#1186

Open
rvykydal wants to merge 1 commit intorhinstaller:mainfrom
rvykydal:network-check-wired-conneciton-props
Open

tests: add network test for 'Wired Connection' assumptions in Cockpit#1186
rvykydal wants to merge 1 commit intorhinstaller:mainfrom
rvykydal:network-check-wired-conneciton-props

Conversation

@rvykydal
Copy link
Copy Markdown
Contributor

Related: COCKPIT-1750

@gemini-code-assist
Copy link
Copy Markdown

Summary of Changes

Hello @rvykydal, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request enhances the network test suite by adding a dedicated test to verify the expected behavior and properties of the default 'Wired Connection' managed by NetworkManager. This ensures that Cockpit's interactions with these connections, particularly when making them persistent, are based on correct assumptions, thereby preventing potential regressions and improving stability.

Highlights

  • New Network Test: Introduced a new test case, test_wired_connection_assumptions, to validate the properties of the default 'Wired Connection' created by NetworkManager in the initramfs.
  • NetworkManager Wired Connection Assertions: Added a new helper method, assert_default_nm_wired_connection_props, which checks if the default 'Wired Connection' is active, non-persistent, and has specific connection.interface-name, connection.type, and connection.multi-connect properties, as assumed by Cockpit.
  • Addressing COCKPIT-1750: This test directly relates to COCKPIT-1750, ensuring that Cockpit's assumptions about the default wired connection remain valid when it attempts to replace it with a persistent connection upon editing.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • test/check-network
    • Added a call to n.assert_default_nm_wired_connection_props(iface) within the test_wired_connection_assumptions method.
  • test/helpers/network.py
    • Implemented a new method assert_default_nm_wired_connection_props to check NetworkManager's default wired connection properties.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request adds a new test to verify assumptions about the default 'Wired Connection' created by NetworkManager, which is relevant for an issue in Cockpit. The changes involve adding a new helper function and calling it from an existing test. The implementation is sound, but I've provided a suggestion to improve code clarity by removing an unnecessary variable.

Comment thread test/helpers/network.py
@rvykydal rvykydal marked this pull request as ready for review February 26, 2026 12:28
@rvykydal rvykydal requested a review from KKoukiou February 26, 2026 12:29
Copy link
Copy Markdown

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey - I've found 2 issues, and left some high level feedback:

  • There is a small typo in the docstring (connecitonconnection) that would be good to fix for clarity.
  • The hard-coded value "3" for connection.multi-connect is a bit opaque; consider using a named constant or adding a brief comment explaining what this value represents.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- There is a small typo in the docstring (`conneciton``connection`) that would be good to fix for clarity.
- The hard-coded value `"3"` for `connection.multi-connect` is a bit opaque; consider using a named constant or adding a brief comment explaining what this value represents.

## Individual Comments

### Comment 1
<location path="test/helpers/network.py" line_range="318-321" />
<code_context>
+
+        The 'Wired Connection' is created in initramfs by NM as a default
+        connection. Cockpit has some assumptions about properties of the
+        connection when replacing it with persistent conneciton upon editing
+        (COCKPIT-1750)
+        This check should assert that these assumptions hold.
</code_context>
<issue_to_address>
**nitpick (typo):** Fix typo in docstring to avoid confusion when searching for this helper

`conneciton` is misspelled; please change to `connection` to keep the documented behavior easy to read and search for.

```suggestion
        The 'Wired Connection' is created in initramfs by NM as a default
        connection. Cockpit has some assumptions about properties of the
        connection when replacing it with persistent connection upon editing
        (COCKPIT-1750)
```
</issue_to_address>

### Comment 2
<location path="test/helpers/network.py" line_range="336-339" />
<code_context>
+        # The connection is not persistent
+        n.check_con_profile_files(con_name, 1, persistent=False)
+        # The properties assumed by Cockpit
+        n.check_con_settings([
+            [con_name, "connection.interface-name", "", None],
+            [con_name, "connection.type", "802-3-ethernet", None],
+            [con_name, "connection.multi-connect", "3", None],
+        ])
</code_context>
<issue_to_address>
**suggestion:** Clarify or centralize the magic value for `connection.multi-connect` in the test

The hardcoded `"3"` for `"connection.multi-connect"` is a magic value tied to Cockpit’s contract with NM. Please either add a brief comment describing what `3` represents in NM terms, or extract it into a named constant shared across tests so future changes to NM behavior or supported values are easier to handle.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment thread test/helpers/network.py
Comment thread test/helpers/network.py
@rvykydal rvykydal force-pushed the network-check-wired-conneciton-props branch from 4d13780 to d51e711 Compare February 26, 2026 15:51
Copy link
Copy Markdown
Contributor

@KKoukiou KKoukiou left a comment

Choose a reason for hiding this comment

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

Does this check really belong to WebUI? Is there anything WebUI does to affect this? I don't see any UI visible data either.

@rvykydal
Copy link
Copy Markdown
Contributor Author

Does this check really belong to WebUI? Is there anything WebUI does to affect this? I don't see any UI visible data either.

The use case is specific to Anaconda (autoconnection created in initramfs on installer boot).
The UI that depends on it (the assumptions) is in Cockpit (network module and handling of such connection), but it would be hit only in Anaconda (during installation). So I was thinking it belongs to installer tests.
It could go as well into kickstart test, but I thought it fits better here because it done for the Cockpit code. Also kickstart functionality does not depend on this exact assumption.
But wrt functionality it is tested by another test. This test would just reveal the cause directly. And explicitly define the assumptions (which are checked in the Cockpit code). So it is in fact kind of unit test? perhaps not worth separate run of functional test. I think I'll remove it.

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