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

tests: add new spread based snapd integration test #330

Merged
merged 3 commits into from
Apr 3, 2023

Conversation

mvo5
Copy link
Contributor

@mvo5 mvo5 commented Feb 28, 2023

Description

This is a first draft of adding integration tests for netplan with snapd and dbus. It uses spread and the LXD backend to run inside the github runners. A first test is designed to do basic interactions between netplan and snapd.

I put this into "draft" mode because I ran into the following issues:

  1. following the instruction to make crashes meson inside a 22.04 container (https://paste.ubuntu.com/p/qRnJvjyddN/)
  2. when commenting out the testing the install step fails with:
meson install -C build --destdir=/
...
Installing /home/tests/netplan.completions to //usr/share/bash-completion/completions

ERROR: Tried to install symlink to missing file //lib/netplan/../../usr/libexec/netplan/generate

I suspect (2) is a result in the most recent #323 ?

I also wonder if the build/install/build-dep step could be simplified by getting the debian packaging from somewhere but I could not figure out where it comes from (sorry for that and hints/ideas welcome).

Testing locally via spread

$ GOBIN=~/go/bin go install github.com/snapcore/spread/cmd/spread@latest
$ ~/go/bin/spread -v -debug lxd:

@mvo5 mvo5 force-pushed the integration-test-spread branch 2 times, most recently from d8c94e2 to ca11dfa Compare February 28, 2023 16:16
@slyon
Copy link
Collaborator

slyon commented Feb 28, 2023

FYI: packaging is done in: https://git.launchpad.net/~ubuntu-core-dev/netplan/+git/ubuntu

fi
# fake running on core (netplan only enabled on ubuntu core)
# FIXME: find a more offical way, this if fugly
cp /etc/os-release /etc/os-release.save
Copy link
Contributor Author

@mvo5 mvo5 Feb 28, 2023

Choose a reason for hiding this comment

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

This needs something like canonical/snapd#12607 to really work, this hack will break at some point but we have a plan in 12607

@mvo5 mvo5 force-pushed the integration-test-spread branch 5 times, most recently from ef2fe25 to b7a28ef Compare February 28, 2023 19:42
@mvo5

This comment was marked as resolved.

src/meson.build Outdated
@@ -41,6 +41,6 @@ meson.add_install_script(meson_make_symlink,
# It's only around for legacy reasons, see netplan/cli/utils.py: get_generator_path()
install_symlink(
'generate',
pointing_to: join_paths('..', '..') + join_paths(get_option('prefix'), libexec_netplan, 'generate'),
pointing_to: join_paths('..', '..', '..') + join_paths(get_option('prefix'), libexec_netplan, 'generate'),
Copy link
Contributor Author

@mvo5 mvo5 Feb 28, 2023

Choose a reason for hiding this comment

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

Fwiw, this change fixed the "make install" for me (but not sure if it's correct in all cases, it seems that in 0e2a8ff the path moved from /lib/netplan/generate to /usr/libexec/netplan/generate which is one level more so one more ".." seems to be needed) [but it requires a packaging update which is why the adt test fails right now it seems]

Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm a bit worried about this change. It makes our autopkgtest GH action fail. We need to be careful with meson installation paths, as those can be different on Fedora/Debian/Ubuntu and might need to go hand-in-hand with packaging changes. Can we somehow avoid this change?

Maybe this helps: 2cded2f (i.e. rebase on top of our recent main branch). See #327 for context.

@slyon
Copy link
Collaborator

slyon commented Mar 2, 2023

FYI: I rebased this on top of #331 to see if the spread test is now passing.

@mvo5 mvo5 marked this pull request as ready for review March 2, 2023 19:12
@mvo5
Copy link
Contributor Author

mvo5 commented Mar 2, 2023

FYI: I rebased this on top of #331 to see if the spread test is now passing.

And it looks like it did! Nice job, thanks for fixing the issue :-D !

@mvo5 mvo5 force-pushed the integration-test-spread branch 2 times, most recently from 66aabe4 to 3654e20 Compare March 6, 2023 09:21
@mvo5
Copy link
Contributor Author

mvo5 commented Mar 6, 2023

I pushed a small tweak now to properly setup/restore the state of the /etc/netplan dir (which makes the need to use multiple test bridge interfaces go away as spread will never run the same test in parallel in the same VM/container, when it runs in parallel it does so on multiple VMs/containers but not in the same).

I would love to know if you folks are interested in taking this PR (in principal, happy to tweak as needed) or if you prefer not to. If this has a chance to land I can canonical/snapd#12607 to make the setup in the snapd integration test much nicer and potentially sketch how autopktest can be integrated with spread tests.

While autopkgtest and spread are broadly doing the same our experience in snapd is that spread scales better with the (buildin) concept of suits and the more natural "prepare/execute/restore" patterns that one knows from regular unit test writing. It also scales better when many tests are used as it will use as many VMs/containers as provided (initially not a concern here though as the tests run in 2min right now ;)

Copy link
Collaborator

@slyon slyon left a comment

Choose a reason for hiding this comment

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

Hey @mvo5 Sorry for taking too long to get through my PR review backlog..
Yes, I'm very much interested in landing this! Even as a spread test in GitHub actions, as proposed. We might want to migrate that later on into an autopkgtest, so it's also run at autopkgtest.ubuntu.com (and other instances, like DebCI).

But landing this spread test should be a good first step. It could also help to prepare infrastructure/tooling for further spread test integration, like canonical/network-manager-snap#15

The only thing I'm worried about is the src/meson.build change (see my inline comment), otherwise this LGTM!

mvo5 and others added 3 commits March 23, 2023 15:14
These tests integrate into the GH workflow and run snapd and dbus
based integration tests.
This is archived by moving using the "restore-each" stanza and just
restoring /etc/netplan in there. This avoids the need to have two
br54,br55 (or N for N tests).
@slyon
Copy link
Collaborator

slyon commented Mar 23, 2023

Actually, I think something like this should do the trick:

meson.add_install_script(meson_make_symlink,
    join_paths(get_option('prefix'), libexec_netplan, 'generate'),
    join_paths('/', 'lib', 'netplan', 'generate'))

I rebased and force pushed to your branch. Let's see the CI results.

Copy link
Collaborator

@slyon slyon left a comment

Choose a reason for hiding this comment

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

+1 All tests are green now.

Michael, is there anything you'd like to add/change to this (e.g. regarding canonical/snapd#12607)? Otherwise, I think we could merge this as-is and improve upon in the future.

Copy link
Collaborator

@slyon slyon left a comment

Choose a reason for hiding this comment

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

This is providing value as-is already. So let's get it merged. We can still improve upon this once snapd landed corresponding upstream changes. Or we've prepared an autopkgtest to run those spread tests accordingly.

@slyon slyon merged commit 678de93 into canonical:main Apr 3, 2023
@slyon slyon added community This PR has been proposed by somebody outside of the Netplan team and roadmap commitments. Canonical by Canonical employees outside the Netplan team labels Jul 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Canonical by Canonical employees outside the Netplan team community This PR has been proposed by somebody outside of the Netplan team and roadmap commitments.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants