mirror of
https://github.com/token2/snapd.git
synced 2026-03-13 11:15:47 -07:00
The test breaks on UC24 in a peculiar way. The `netplan` CLI tool is a Python script which attempts to load libnetplan.so.* through ctypes. However, in a snap, the contents of /etc come from the host, so in case on UC24 environment, the netplan client invoked from eg. core20 would observe actual ld.so.cache from UC24. Thus Python's ctype library, would call `ldconfig-p`, which then consumes the ld.so.cache from UC24, thus listing incorrect version of the libnetplan library (specifically UC24 has libnetplan.so.1, while earlier versions had libnetplan.so.0.0). Attempt to fix this by providing a custom wrapper for ldconfig, which generates a cache on the side under $SNAP_DATA, thus using the libraries which are actually visible to the snap. Signed-off-by: Maciej Borzecki <maciej.borzecki@canonical.com>
135 lines
5.4 KiB
YAML
135 lines
5.4 KiB
YAML
summary: Ensure that netplan works on Ubuntu Core with network-setup-{control,observe}
|
|
|
|
details: |
|
|
Netplan apply is used to apply network configuration to the system
|
|
|
|
environment:
|
|
NETPLAN: io.netplan.Netplan
|
|
|
|
prepare: |
|
|
# build the netplan snap for this system
|
|
#shellcheck source=tests/lib/snaps.sh
|
|
. "$TESTSLIB"/snaps.sh
|
|
|
|
# use no base setting to use effectively "base: core"
|
|
sed "$TESTSLIB/snaps/netplan-snap/meta/snap.yaml.in" \
|
|
-e "s/base: %BASESNAP%/# no base snap for core base/" \
|
|
-e "s|%USRMERGE%||" \
|
|
> "$TESTSLIB/snaps/netplan-snap/meta/snap.yaml"
|
|
snap pack "$TESTSLIB/snaps/netplan-snap" --filename=netplan-snap-16.snap
|
|
|
|
# use base: core18
|
|
sed "$TESTSLIB/snaps/netplan-snap/meta/snap.yaml.in" \
|
|
-e "s/base: %BASESNAP%/base: core18/" \
|
|
-e "s|%USRMERGE%||" \
|
|
> "$TESTSLIB/snaps/netplan-snap/meta/snap.yaml"
|
|
snap pack "$TESTSLIB/snaps/netplan-snap" --filename=netplan-snap-18.snap
|
|
|
|
# Skip i386 because core20 is not available for pc-i386 architecture
|
|
if not os.query is-pc-i386; then
|
|
# use base: core20
|
|
sed "$TESTSLIB/snaps/netplan-snap/meta/snap.yaml.in" \
|
|
-e "s/base: %BASESNAP%/base: core20/" \
|
|
-e "s|%USRMERGE%|/usr|" \
|
|
> "$TESTSLIB/snaps/netplan-snap/meta/snap.yaml"
|
|
snap pack "$TESTSLIB/snaps/netplan-snap" --filename=netplan-snap-20.snap
|
|
fi
|
|
|
|
# TODO add core22 and 24?
|
|
|
|
execute: |
|
|
# test all base versions of netplan on all combos of core releases
|
|
versions="16 18 20"
|
|
# Skip i386 because core20 is not available for pc-i386 architecture
|
|
if os.query is-pc-i386; then
|
|
versions="16 18"
|
|
fi
|
|
for rel in $versions; do
|
|
snap install --dangerous "netplan-snap-$rel.snap"
|
|
echo "The interface is disconnected by default"
|
|
snap connections netplan-snap | MATCH 'network-setup-control +netplan-snap:network-setup-control +- +-'
|
|
|
|
echo "Running netplan apply without network-setup-control fails"
|
|
if netplan-snap.netplan apply; then
|
|
echo "Expected access denied error for netplan apply"
|
|
exit 1
|
|
fi
|
|
|
|
if ! os.query is-core16 && test "$rel" -ne 16; then
|
|
echo "Running netplan generate without network-setup-control fails"
|
|
if netplan-snap.netplan generate; then
|
|
echo "Expected access denied error for netplan generate"
|
|
exit 1
|
|
fi
|
|
else
|
|
echo "Skipping netplan generate on UC16"
|
|
fi
|
|
|
|
echo "Count how many network service restarts happened before calling netplan apply"
|
|
stopped_before="$("$TESTSTOOLS"/journal-state get-log -u systemd-networkd | grep -c 'Stopped Network Service.' || true)"
|
|
started_before="$("$TESTSTOOLS"/journal-state get-log -u systemd-networkd | grep -c 'Started Network Service.' || true)"
|
|
|
|
echo "When the interface is connected"
|
|
snap connect netplan-snap:network-setup-control
|
|
|
|
# sometimes the systems becomes unreachable after "netplan apply"
|
|
# (see LP:1949708), adding --debug might give us clues why
|
|
echo "Running netplan apply now works"
|
|
if ! netplan-snap.netplan --debug apply; then
|
|
echo "Unexpected error running netplan apply"
|
|
exit 1
|
|
fi
|
|
|
|
if ! os.query is-core16 && test "$rel" -ne 16; then
|
|
echo "Running netplan generate now works"
|
|
if ! netplan-snap.netplan generate; then
|
|
echo "Unexpected error running netplan generate"
|
|
exit 1
|
|
fi
|
|
else
|
|
echo "Skipping netplan generate on UC16"
|
|
fi
|
|
|
|
echo "Ensure that network config was stopped and restarted from netplan"
|
|
for _ in $(seq 60); do
|
|
stopped_after="$("$TESTSTOOLS"/journal-state get-log -u systemd-networkd | grep -c 'Stopped Network Service.' || true)"
|
|
started_after="$("$TESTSTOOLS"/journal-state get-log -u systemd-networkd | grep -c 'Started Network Service.' || true)"
|
|
if [ "$stopped_after" -gt "$stopped_before" ] && \
|
|
[ "$started_after" -gt "$started_before" ] ; then
|
|
break
|
|
fi
|
|
sleep 1
|
|
done
|
|
|
|
echo "Ensure that the number of network restarts is greater after netplan apply was run"
|
|
[ "$stopped_after" -gt "$stopped_before" ] && [ "$started_after" -gt "$started_before" ]
|
|
|
|
if os.query is-core16; then
|
|
echo "Skipping Ubuntu Core 16 which does not have Info D-Bus method"
|
|
exit 0
|
|
fi
|
|
|
|
echo "Disconnecting network-setup-control to test network-setup-observe"
|
|
snap disconnect netplan-snap:network-setup-control
|
|
|
|
echo "The network-setup-observe interface is disconnected by default"
|
|
snap connections netplan-snap | MATCH 'network-setup-observe +netplan-snap:network-setup-observe +- +-'
|
|
|
|
echo "Running netplan info via D-Bus without network-setup-observe fails"
|
|
if netplan-snap.netplan-info; then
|
|
echo "Expected access denied error for netplan info via D-Bus"
|
|
exit 1
|
|
fi
|
|
|
|
echo "When the interface is connected"
|
|
snap connect netplan-snap:network-setup-observe
|
|
|
|
echo "Running netplan info via D-Bus now works"
|
|
if ! netplan-snap.netplan-info; then
|
|
echo "Unexpected error running netplan info via D-Bus"
|
|
exit 1
|
|
fi
|
|
|
|
snap remove netplan-snap
|
|
done
|