-
Notifications
You must be signed in to change notification settings - Fork 195
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
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
name: Run spread | ||
|
||
on: | ||
push: | ||
branches: [ main ] | ||
pull_request: | ||
branches: [ main ] | ||
|
||
jobs: | ||
spread: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: canonical/setup-lxd@ea57509243d3cf39f8ab926e021bb353947b01b5 | ||
- uses: actions/checkout@v2 | ||
- name: Install spread | ||
run: | | ||
go install github.com/snapcore/spread/cmd/spread@latest | ||
- name: Run the spread test inside LXD | ||
run: | | ||
~/go/bin/spread -v lxd: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
project: netplan | ||
|
||
backends: | ||
lxd: | ||
systems: [ubuntu-22.04] | ||
qemu: | ||
systems: | ||
- ubuntu-22.04-64: | ||
username: ubuntu | ||
password: ubuntu | ||
|
||
suites: | ||
tests/spread/: | ||
summary: integration tests | ||
|
||
path: /home/tests | ||
|
||
prepare: | | ||
# FIXME: remove after legacy symlink in 107 gets dropped (see meson.build) | ||
# This is needed as the git netplan puts a symlink to /lib/netplan/generate | ||
# but the package has the real generate there | ||
rm -f /lib/netplan/generate | ||
# FIXME: having the debian packging available would allow "apt | ||
# build-dep -y ./" would make this easier :) | ||
apt update -qq | ||
apt install -y build-essential meson pkg-config libyaml-dev \ | ||
libglib2.0-dev uuid-dev python3 libsystemd-dev pandoc python3-pytest \ | ||
python3-coverage libcmocka-dev python3-rich | ||
# install, a bit ugly but this is a container (did I mention the packaging?) | ||
meson setup build --prefix=/usr | ||
meson compile -C build | ||
# FIXME: enable, this crashes right now with: | ||
# https://paste.ubuntu.com/p/qRnJvjyddN/ | ||
#meson test -C build --verbose | ||
meson install -C build --destdir=/ | ||
# set some defaults | ||
cat > /etc/netplan/0-snapd-defaults.yaml <<'EOF' | ||
network: | ||
version: 2 | ||
bridges: | ||
br54: | ||
dhcp4: true | ||
EOF | ||
chmod 0600 /etc/netplan/0-snapd-defaults.yaml | ||
echo "Precondition check, the basics work" | ||
netplan get bridges.br54.dhcp4 | MATCH true | ||
# keep original config around | ||
tar cvf "$SPREAD_PATH"/etc-netplan.tar.gz /etc/netplan/ | ||
|
||
restore-each: | | ||
# restore original netplan dir | ||
rm -rf /etc/netplan/* | ||
(cd / && tar xvf "$SPREAD_PATH"/etc-netplan.tar.gz) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
summary: Check that the dbus integration works | ||
|
||
debug: | | ||
netplan get | ||
|
||
execute: | | ||
# see the basics work | ||
netplan get bridges.br54.dhcp4 | MATCH true | ||
# TODO: actually use busctl | ||
obj_path=$(dbus-send --system --print-reply --type=method_call \ | ||
--dest=io.netplan.Netplan /io/netplan/Netplan \ | ||
io.netplan.Netplan.Config|tail -1 | sed 's/.*"\(.*\)".*/\1/' ) | ||
dbus-send --print-reply --system --type=method_call \ | ||
--dest=io.netplan.Netplan "$obj_path" \ | ||
io.netplan.Netplan.Config.Get | MATCH "version: 2" | ||
# and updating via dbus netplan works (use 90-test origin hint for | ||
# easier test cleanup) | ||
dbus-send --print-reply --system --type=method_call \ | ||
--dest=io.netplan.Netplan "$obj_path" \ | ||
io.netplan.Netplan.Config.Set \ | ||
string:bridges.br54.dhcp4=false string:90-test | ||
# not applied yet | ||
test ! -e /etc/netplan/90-test.yaml | ||
netplan get bridges.br54.dhcp4 | MATCH true | ||
# apply | ||
dbus-send --print-reply --system --type=method_call \ | ||
--dest=io.netplan.Netplan "$obj_path" \ | ||
io.netplan.Netplan.Config.Apply | ||
# and now it's active | ||
test -e /etc/netplan/90-test.yaml | ||
netplan get bridges.br54.dhcp4 | MATCH false | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
summary: Check that the snapd/netplan integration works | ||
|
||
prepare: | | ||
# put snapd in debug mode for good logs | ||
mkdir -p /etc/systemd/system/snapd.service.d | ||
cat <<EOF > /etc/systemd/system/snapd.service.d/local.conf | ||
[Service] | ||
Environment=SNAPD_DEBUG=1 | ||
EOF | ||
systemctl daemon-reload | ||
# install snapd if needed (should be installed on most lxd images) | ||
if ! dpkg -l snapd >/dev/null; then | ||
apt install -y snapd | ||
echo "apt autoremove -y snapd" >> defered.cleanup | ||
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 | ||
sed -i s/ID=ubuntu/ID=ubuntu-core/ /etc/os-release | ||
M=/var/lib/snapd/assertions/asserts-v0/model/16/generic/generic-classic/active | ||
cp "$M" model.save | ||
sed -i 's/classic: true/architecture: amd64\ngadget: pc\nkernel: pc-kernel/g' "$M" | ||
# restart snapd | ||
systemctl restart snapd | ||
|
||
restore: | | ||
mv /etc/os-release.save /etc/os-release | ||
mv model.save /var/lib/snapd/assertions/asserts-v0/model/16/generic/generic-classic/active | ||
sudo systemctl restart snapd | ||
if [ -e defered.cleanup ]; then | ||
sh -ex defered.cleanup | ||
fi | ||
rm -f model.* | ||
|
||
debug: | | ||
journalctl -u snapd | ||
snap get system -d | ||
snap version | ||
|
||
execute: | | ||
# see the basics work | ||
netplan get bridges.br54.dhcp4 | MATCH true | ||
snap get system system.network.netplan.network.bridges.br54.dhcp4 | MATCH true | ||
# and updating netplan works | ||
snap set system system.network.netplan.network.bridges.br54.dhcp4=false | ||
netplan get bridges.br54.dhcp4 | MATCH false | ||
snap get system system.network.netplan.network.bridges.br54.dhcp4 | MATCH false |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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