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

test: Add v2 test coverage to test_net.py #5247

Merged
merged 14 commits into from
Jun 3, 2024

Conversation

TheRealFalcon
Copy link
Member

Proposed Commit Message

test: Add v2 test coverage to test_net.py

Ensure there is a corresponding v2 test for every v1 test in
`network_configs.py` where possible/reasonable.

Many tests are marked with `xfail` as they will not pass without
additional changes to the network rendering code.

Additional Context

I left the individual commits as they may (or may not) be more useful in reviewing. This PR should be squashed though.

Merge type

  • Squash merge using "Proposed Commit Message"
  • Rebase and merge unique commits. Requires commit messages per-commit each referencing the pull request number (#<PR_NUM>)

@holmanb holmanb self-assigned this May 1, 2024
Copy link

Hello! Thank you for this proposed change to cloud-init. This pull request is now marked as stale as it has not seen any activity in 14 days. If no activity occurs within the next 7 days, this pull request will automatically close.

If you are waiting for code review and you are seeing this message, apologies! Please reply, tagging TheRealFalcon, and he will ensure that someone takes a look soon.

(If the pull request is closed and you would like to continue working on it, please do tag TheRealFalcon to reopen it.)

@github-actions github-actions bot added the stale-pr Pull request is stale; will be auto-closed soon label May 16, 2024
@holmanb holmanb removed the stale-pr Pull request is stale; will be auto-closed soon label May 16, 2024
Copy link

Hello! Thank you for this proposed change to cloud-init. This pull request is now marked as stale as it has not seen any activity in 14 days. If no activity occurs within the next 7 days, this pull request will automatically close.

If you are waiting for code review and you are seeing this message, apologies! Please reply, tagging TheRealFalcon, and he will ensure that someone takes a look soon.

(If the pull request is closed and you would like to continue working on it, please do tag TheRealFalcon to reopen it.)

@github-actions github-actions bot added the stale-pr Pull request is stale; will be auto-closed soon label May 31, 2024
Copy link
Member

@holmanb holmanb left a comment

Choose a reason for hiding this comment

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

I'm just getting back to this after a long while, sorry for the delay.

Overall this looks good, thanks for the PR! I just have a couple of questions inline.

@@ -2265,41 +3495,41 @@
bond-downdelay 10
bond-fail-over-mac active
bond-master bond0
bond_miimon 100
Copy link
Member

Choose a reason for hiding this comment

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

is this change intentional? (repeat the same question for the next several changes)

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes. Github unfortunately renders this very poorly. You're looking at the v2 addition, and when using v2, things get rendered alphabetically. This is a change between v1 and v2 rendering, but it results in no functional difference so it is fine.

This may better demonstrate the difference here. Notice the left has expanded the expected v1 whereas the right has expanded the expected v2:
image

@@ -2586,22 +3729,22 @@
method=manual
may-fail=false
address1=192.168.0.2/24
gateway=192.168.0.1
route1=10.1.3.0/24,192.168.0.3
route1=0.0.0.0/0,192.168.0.1
Copy link
Member

Choose a reason for hiding this comment

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

is this change intentional? (repeat for the next several changes)

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, like the miimon v2 renders slightly differently and github is doing a poor job rendering it. v2 renders a 0.0.0.0 route rather than gateway, but functionally it is the same.

image

)
self._compare_files_to_expected(entry[self.expected_name], found)
self._assert_headers(found)
expected_msg = (
"Network config: ignoring iface0 device-level mtu:8999"
" because ipv4 subnet-level mtu:9000 provided."
)
assert expected_msg in caplog.text
if yaml_file == "yaml_v1":
assert expected_msg in caplog.text
Copy link
Member

Choose a reason for hiding this comment

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

No test for yaml_v2?

Copy link
Member Author

Choose a reason for hiding this comment

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

We get no warning in v2 because we wind up testing slightly different things. v2 has no concept of interface level vs subnet level MTU, so that's not something we can test for in v2.

yaml v1:

            version: 1
            config:
              - type: 'physical'
                name: 'iface0'
                mtu: 8999
                subnets:
                  - type: static
                    address: 192.168.14.2/24
                    mtu: 9000
                  - type: static
                    address: 2001:1::1/64
                    mtu: 1500

yaml v2:

            version: 2
            ethernets:
                iface0:
                    addresses:
                    - 192.168.14.2/24
                    - 2001:1::1/64
                    mtu: 9000

entry = NETWORK_CONFIGS[expected_name]
yaml_name = "yaml" if "yaml" in entry else "yaml_v2"
Copy link
Member

Choose a reason for hiding this comment

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

+1 for cleanup

@holmanb holmanb removed the stale-pr Pull request is stale; will be auto-closed soon label May 31, 2024
Copy link
Member

@holmanb holmanb left a comment

Choose a reason for hiding this comment

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

is this change intentional

I assume not, so setting this to "Request changes".

@TheRealFalcon
Copy link
Member Author

@holmanb , I believe I answered all of your questions. Ready for re-review.

Copy link
Member

@holmanb holmanb left a comment

Choose a reason for hiding this comment

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

Thanks for responding to my questions @TheRealFalcon. Looks good to me!

@TheRealFalcon TheRealFalcon merged commit f93514a into canonical:main Jun 3, 2024
29 checks passed
@TheRealFalcon TheRealFalcon deleted the v2-tests branch June 3, 2024 15:45
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.

None yet

2 participants