tests, spread: add Arch Linux to CI systems #4285

Open
wants to merge 80 commits into
from

Conversation

Projects
None yet
5 participants
Contributor

bboozzoo commented Nov 23, 2017

This is an early PR adding support for Arch Linux in the CI pipeline. Hopefully this will allow to catch the cross-distro incompatibilities sooner.

Related forum topic: https://forum.snapcraft.io/t/integrate-arch-linux-into-ci-pipeline/2904

bboozzoo added some commits Nov 23, 2017

tests/lib/pkgdb: add Arch Linux pacman glue
Add required bits for integration with Arch's pacman

Signed-off-by: Maciej Borzecki <maciej.zenon.borzecki@canonical.com>
tests/lib/dirs: add Arch specific exports
Signed-off-by: Maciej Borzecki <maciej.zenon.borzecki@canonical.com>
tests/lib/prepare-project: use common useradd calls to create test us…
…er on Arch

Signed-off-by: Maciej Borzecki <maciej.zenon.borzecki@canonical.com>
tests/lib/prepare-project: support for building Arch Linux packages i…
…n 'prepare' step

Build Arch Linux package using in tree PKGBUILD. Tune the PKGBUILD to use a
locally generated tar archive, build the package named 'snapd' and use a fixed
package version number.

Signed-off-by: Maciej Borzecki <maciej.zenon.borzecki@canonical.com>
spread: support for Arch Linux on Linode
Signed-off-by: Maciej Borzecki <maciej.zenon.borzecki@canonical.com>

zyga approved these changes Nov 23, 2017

LGMT with one remark.

tests/lib/prepare-project.sh
@@ -237,6 +277,9 @@ if [ -z "$SNAPD_PUBLISHED_VERSION" ]; then
fedora-*|opensuse-*)
build_rpm
;;
+ arch-*)
+ build_pkg
@zyga

zyga Nov 23, 2017

Contributor

Can we please call this build_arch_pkg, people may find this confusing as package is a generic term.

@bboozzoo

bboozzoo Nov 23, 2017

Contributor

renamed

bboozzoo added some commits Nov 23, 2017

tests/lib/pkgdb: there is no --quiet switch for pacman -U
Signed-off-by: Maciej Borzecki <maciej.zenon.borzecki@canonical.com>
packaging/arch: pre-create snapd directories when packaging
Signed-off-by: Maciej Borzecki <maciej.zenon.borzecki@canonical.com>
tests/lib/prepare-project: rename build_pkg -> build_arch_pkg
Signed-off-by: Maciej Borzecki <maciej.zenon.borzecki@canonical.com>
tests/lib/pkgdb: install openbsd-netcat on Arch
Signed-off-by: Maciej Borzecki <maciej.zenon.borzecki@canonical.com>
packaging/arch: fix directory creation
Signed-off-by: Maciej Borzecki <maciej.zenon.borzecki@canonical.com>
tests/lib: fix shellcheck errors
Fix the following warnings:

In ./tests/lib/prepare.sh line 198:
            cd $TESTSLIB/cache/
               ^-- SC2086: Double quote to prevent globbing and word splitting.

In ./tests/lib/store.sh line 45:
    snap ack $p
             ^-- SC2086: Double quote to prevent globbing and word splitting.

In ./tests/lib/store.sh line 47:
    snap ack $p
             ^-- SC2086: Double quote to prevent globbing and word splitting.

Signed-off-by: Maciej Borzecki <maciej.zenon.borzecki@canonical.com>
tests/lib/pkgdb: there is no --quiet option in pacman -R
Signed-off-by: Maciej Borzecki <maciej.zenon.borzecki@canonical.com>
tests/lib/reset: reuse snap-mgmt.sh from Fedora for performing cleanu…
…p on Arch

Signed-off-by: Maciej Borzecki <maciej.zenon.borzecki@canonical.com>
tests/lib/pkgdb, spread: use pacman -S[y]u when installig packages
This is a workaround for Arch's pacman not being smart enough. The way pacman
works is that when a dependency for a package being installed is already
present, it will not be upgraded. Thus it is important that package installation
is done by calling `pacman -Syu ..` which has a side effect of upgrading all
packages in the system.

The patch introduces --sysupgrade option where possible

Signed-off-by: Maciej Borzecki <maciej.zenon.borzecki@canonical.com>
tests/lib/pkgdb: stub for package autoremove on Arch
There is no explicit autoremove operation in pacman.

Signed-off-by: Maciej Borzecki <maciej.zenon.borzecki@canonical.com>
Contributor

zyga commented Nov 23, 2017

We are still running on the Linode kernel: 5,0,0,-;Linux version 4.9.50-x86_64-linode86 (maker@build.linode.com) (gcc version 4.9.2 (Debian 4.9.2-10) ) #1 SMP Thu Sep 14 19:28:20 UTC 2017

bboozzoo added some commits Nov 24, 2017

spread: when running on Arch do not try to remove packages that do no…
…t exist

pacman is picky about trying to remove a package that does not exist and fails
in such case. Rather than covering the error with `.. || true`, do not attempt
to remove the package at all.

Signed-off-by: Maciej Borzecki <maciej.zenon.borzecki@canonical.com>
tests/lib/pkgdb: add distro_upgrade helper
Implement the operation for Arch and show a warning for other systems.

Signed-off-by: Maciej Borzecki <maciej.zenon.borzecki@canonical.com>
spread: source prepare-restore.sh in prepare[-each] & restore[-each]
Parts that were previously inside spread.yaml prepare/restore steps are now
moved to prepare-restore.sh script. Since this the script is executed in a
separate shell, the utility functions REBOOT and MATCH are not available. Both
actions may be needed when preparing the test host. Source the script so that we
can regain access to these functions.

Signed-off-by: Maciej Borzecki <maciej.zenon.borzecki@canonical.com>
tests/lib/prepare-restore: add optional system upgrade on Arch systems
Arch requires system upgrade to be performed in order to have a consistent state
of packages. Add the sysupgrade followed by reboot step for Arch systems only.

Signed-off-by: Maciej Borzecki <maciej.zenon.borzecki@canonical.com>
tests/main/security-device-cgroups-strict: disable the test on Arch s…
…ystems

Disable the test until we can run Arch with the kernel from its repostories.

Signed-off-by: Maciej Borzecki <maciej.zenon.borzecki@canonical.com>
tests/main/create-user: disable the test on arch-* systems
Signed-off-by: Maciej Borzecki <maciej.zenon.borzecki@canonical.com>
tests/regression/lp-1595444: disable the test on arch-* systems
The test requires AppArmor which is not available on Arch

Signed-off-by: Maciej Borzecki <maciej.zenon.borzecki@canonical.com>
tests/regression/lp-1599891: disable the test on arch-* systems
The test requires AppArmor which is not available on Arch

Signed-off-by: Maciej Borzecki <maciej.zenon.borzecki@canonical.com>
tests/main/security-setuid-root: disable the test for Arch
Arch does not support AppArmor which is required to run the test.

Signed-off-by: Maciej Borzecki <maciej.zenon.borzecki@canonical.com>
spread: use distribution kernel for Arch
Ensure that Arch system boots with distribution provided kernel instead of the
Linode one.

Signed-off-by: Maciej Borzecki <maciej.zenon.borzecki@canonical.com>
tests/main/classic-custom-device-reg: disable test on Arch
The test currently fails on Arch, disable it temporarily.

Signed-off-by: Maciej Borzecki <maciej.zenon.borzecki@canonical.com>
tests/lib/pkgdb: update package dependencies on Arch
Signed-off-by: Maciej Borzecki <maciej.zenon.borzecki@canonical.com>
tests/main/manpages: set LC_ALL=C as man may complain if the locale i…
…s unset

Signed-off-by: Maciej Borzecki <maciej.zenon.borzecki@canonical.com>
tests/lib/pkgdb: man is called man-db in Arch
Signed-off-by: Maciej Borzecki <maciej.zenon.borzecki@canonical.com>

Change looks promising, question inline.

@@ -339,13 +345,13 @@ prepare: |
# NOTE: At this stage the source tree is available and no more special
# considerations apply.
- "$TESTSLIB"/prepare-restore.sh --prepare-project
+ ( . "$TESTSLIB"/prepare-restore.sh --prepare-project )
@sergiocazzolato

sergiocazzolato Nov 24, 2017

Contributor

why you are changing this?

@bboozzoo

bboozzoo Nov 24, 2017

Contributor

We need to do a system upgrade in Arch in order to get a consistent system state. I figured that moving this operation into project prepare was the best fit (see 7773050 for implementation). However, there is a slight complication, in order to do a reboot properly, we use the REBOOT command which is only defined at the top level spread prepare|restore.. and so on, so it's not visible in prepare-restore.sh which is executed in a separate shell. To work around this problem, I've opted for sourcing the script instead. 😞

Other options are to move the upgrade piece to prepare block, or use some special exit code in prepare-restore.sh to indicate that reboot is needed.

@mvo5

mvo5 Nov 27, 2017

Collaborator

Could you please add a comment (copy/paste this here is probably fine) about the details why this is done in the way you do it?

+distro_upgrade() {
+ case "$SPREAD_SYSTEM" in
+ arch-*)
+ if pacman -Syu --noconfirm 2>&1 | grep -q "there is nothing to do" ; then
@sergiocazzolato

sergiocazzolato Nov 24, 2017

Contributor

perhaps you could use MATCH here

@bboozzoo

bboozzoo Nov 24, 2017

Contributor

MATCH is only defined in the shell that runs the script defined in spread.yaml or task.yaml. If pkgdb.sh is used in separate shell, the function may not be defined.

@zyga

zyga Nov 24, 2017

Contributor

I have a solution for missing MATCH that came out of my refactoring. I have it ready but I'll only post it on Monday to let you guys rest too :)

@mvo5

mvo5 Nov 27, 2017

Collaborator

This margin is too small to contain it ;)?

bboozzoo added some commits Nov 24, 2017

tests/main/confinement-classic: add arch triplet translation for x86_…
…64-pc-linux-gnu

x86_64-pc-linux-gnu can be reported by gcc on Arch or other vanilla systems

Signed-off-by: Maciej Borzecki <maciej.zenon.borzecki@canonical.com>
tests/main/prepare-image-grub: disable the test on Arch
Signed-off-by: Maciej Borzecki <maciej.zenon.borzecki@canonical.com>
tests/main/dirs-not-shared-with-host: create /etc/alternatives on Arch
Arch does not use the alternatives system, so /etc/alternatives does not exist
in the default installation. Workaround this by creating a temporary
/etc/alternatives directory just for the test run

Signed-off-by: Maciej Borzecki <maciej.zenon.borzecki@canonical.com>
tests/main/interfaces-cups-control: disable the test on Arch
Temporarily disable the test on Arch due to differences in setup. For future,
on Arch there is no separate cups.service and socket activation is used.

Signed-off-by: Maciej Borzecki <maciej.zenon.borzecki@canonical.com>
tests/main/snap-repair: disable the test on Arch
Signed-off-by: Maciej Borzecki <maciej.zenon.borzecki@canonical.com>
packaging/arch: update /var/lib directories
Include directories that were missed during packaging. Make sure that the
permission bits are set correctly.

Signed-off-by: Maciej Borzecki <maciej.zenon.borzecki@canonical.com>
packaging/arch: generate and ship snap(1) manpage
Signed-off-by: Maciej Borzecki <maciej.zenon.borzecki@canonical.com>
packaging/arch: install snapd version info file
Signed-off-by: Maciej Borzecki <maciej.zenon.borzecki@canonical.com>
packaging/arch: support for building with test keys enabled
The caller can set WITH_TEST_KEYS environment variable to 1 to enable building
with test keys.

Signed-off-by: Maciej Borzecki <maciej.zenon.borzecki@canonical.com>
tests/lib/prepare-restore: enable building with test keys enabled on …
…Arch

Signed-off-by: Maciej Borzecki <maciej.zenon.borzecki@canonical.com>
packaging/arch: import fedora snap-mgmt.sh tool
Signed-off-by: Maciej Borzecki <maciej.zenon.borzecki@canonical.com>
packaging/arch: install snap-mgmt.sh tool into /usr/lib/snapd/snap-mgmt
Signed-off-by: Maciej Borzecki <maciej.zenon.borzecki@canonical.com>
packaging/arch: purge snaps when removing the package
Signed-off-by: Maciej Borzecki <maciej.zenon.borzecki@canonical.com>

zyga approved these changes Nov 27, 2017

Looks good, nice to see more tests enabled!

spread.yaml
@@ -74,6 +74,9 @@ backends:
- opensuse-42.2-64:
workers: 3
manual: true
+ - arch-2017.07.01:
+ workers: 1
@mvo5

mvo5 Nov 27, 2017

Collaborator

We probably need more than a single worker here.

Thanks a driving this, really great to see arch in the CI. Some questions/suggestion inline.

@@ -339,13 +345,13 @@ prepare: |
# NOTE: At this stage the source tree is available and no more special
# considerations apply.
- "$TESTSLIB"/prepare-restore.sh --prepare-project
+ ( . "$TESTSLIB"/prepare-restore.sh --prepare-project )
@sergiocazzolato

sergiocazzolato Nov 24, 2017

Contributor

why you are changing this?

@bboozzoo

bboozzoo Nov 24, 2017

Contributor

We need to do a system upgrade in Arch in order to get a consistent system state. I figured that moving this operation into project prepare was the best fit (see 7773050 for implementation). However, there is a slight complication, in order to do a reboot properly, we use the REBOOT command which is only defined at the top level spread prepare|restore.. and so on, so it's not visible in prepare-restore.sh which is executed in a separate shell. To work around this problem, I've opted for sourcing the script instead. 😞

Other options are to move the upgrade piece to prepare block, or use some special exit code in prepare-restore.sh to indicate that reboot is needed.

@mvo5

mvo5 Nov 27, 2017

Collaborator

Could you please add a comment (copy/paste this here is probably fine) about the details why this is done in the way you do it?

+distro_upgrade() {
+ case "$SPREAD_SYSTEM" in
+ arch-*)
+ if pacman -Syu --noconfirm 2>&1 | grep -q "there is nothing to do" ; then
@sergiocazzolato

sergiocazzolato Nov 24, 2017

Contributor

perhaps you could use MATCH here

@bboozzoo

bboozzoo Nov 24, 2017

Contributor

MATCH is only defined in the shell that runs the script defined in spread.yaml or task.yaml. If pkgdb.sh is used in separate shell, the function may not be defined.

@zyga

zyga Nov 24, 2017

Contributor

I have a solution for missing MATCH that came out of my refactoring. I have it ready but I'll only post it on Monday to let you guys rest too :)

@mvo5

mvo5 Nov 27, 2017

Collaborator

This margin is too small to contain it ;)?

+ -e "s/pkgver=.*/pkgver=$version/" \
+ -e "s/package_snapd-git()/package_snapd()/" \
+ /tmp/pkg/PKGBUILD
+ awk '
@mvo5

mvo5 Nov 27, 2017

Collaborator

Hm, is this really the only way? It looks really hard to read, what are the inputs/outputs here?

@bboozzoo

bboozzoo Nov 29, 2017

Contributor

We need to comment out this whole pkgver section: https://github.com/bboozzoo/snapd/blob/a3a463199cc12b4dbb70e92339f7c45c518317eb/packaging/arch/PKGBUILD#L33 then
update source=("git+ssh://...") to point to tar.gz, rename package_snapd-git() to package_snapd() and rename the pacakge to snapd.

@@ -12,6 +12,16 @@ prepare: |
echo "Having installed the test snap"
. $TESTSLIB/snaps.sh
install_local test-snapd-tools
+ # Arch does not use /etc/alternatives
+ if [[ "$SPREAD_SYSTEM" == arch-* ]]; then
+ mkdir /etc/alternatives
@mvo5

mvo5 Nov 27, 2017

Collaborator

Hm, I get the feeling this may hide a bug in our code? Shouldn't we fail gracefully if this dir does not exists? cc @zyga

@zyga

zyga Nov 27, 2017

Contributor

I think so though perhaps some tests are overzealous. What did you see @bboozzoo ?

@bboozzoo

bboozzoo Nov 27, 2017

Contributor

DIRECTORY/alternatives fails because it tries to get a inode of this directory in the host's filesystem and fails as there is no such directory on Arch.

codecov-io commented Nov 28, 2017

Codecov Report

Merging #4285 into master will decrease coverage by 0.01%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #4285      +/-   ##
==========================================
- Coverage   78.05%   78.03%   -0.02%     
==========================================
  Files         450      450              
  Lines       30899    30899              
==========================================
- Hits        24118    24113       -5     
- Misses       4772     4776       +4     
- Partials     2009     2010       +1
Impacted Files Coverage Δ
overlord/hookstate/hookmgr.go 71.67% <0%> (-1.16%) ⬇️
overlord/ifacestate/helpers.go 63.48% <0%> (-0.83%) ⬇️
cmd/snap-seccomp/main.go 52.6% <0%> (-0.53%) ⬇️
interfaces/builtin/system_observe.go 100% <0%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 87e197c...be14ed4. Read the comment docs.

tests/lib/prepare-restore: update arch package build
Update the code for building Arch package to not break the PKGBUILD when more
than one source file is listed.

Signed-off-by: Maciej Borzecki <maciej.zenon.borzecki@canonical.com>
Contributor

bboozzoo commented Nov 29, 2017

Another Arch curiosity:

2017-11-29 12:35:04 Error preparing linode:arch-2017.07.01:tests/main/interfaces-dbus : 
...
And the provider dbus loop is started
+ . /home/gopath/src/github.com/snapcore/snapd/tests/lib/dbus.sh
+ start_dbus_unit /var/lib/snapd/snap/bin/test-snapd-dbus-provider.provider
+ local executable=/var/lib/snapd/snap/bin/test-snapd-dbus-provider.provider
+ dbus-launch
dbus-launch: error while loading shared libraries: libX11.so.6: cannot open shared object file: No such file or directory

Turns out dbus does not depend on libx11 😕

bboozzoo added some commits Nov 29, 2017

tests/lib/pkgdb: include libx11 in dependencies on Arch
We are using dbus-launch in the tests, but the `dbus` package is missing a
necessary dependency on `libx11`. Make sure that `libx11` is installed.

Signed-off-by: Maciej Borzecki <maciej.zenon.borzecki@canonical.com>
tests/main/interfaces-locale-control: disable the test on Arch
There is no /etc/default/locale on Arch

Signed-off-by: Maciej Borzecki <maciej.zenon.borzecki@canonical.com>
tests/main/interfaces-hardware-random-control: disable test on Arch
/dev/hwrng is not created by default on Arch

Signed-off-by: Maciej Borzecki <maciej.zenon.borzecki@canonical.com>
tests/main/server-snap: use ::1 instead of ip6-localhost
ip6-localhost alias may not be defined on a particular distribution, use ::1
instead

Signed-off-by: Maciej Borzecki <maciej.zenon.borzecki@canonical.com>
tests/lib/pkgdb: add bash-completion dependency on Arch
bash-completion provides the necessary library functions executing snapd bash
completion tests

Signed-off-by: Maciej Borzecki <maciej.zenon.borzecki@canonical.com>
packaging/arch: add bash-completion as optional dependency
Signed-off-by: Maciej Borzecki <maciej.zenon.borzecki@canonical.com>

bboozzoo added some commits Dec 1, 2017

tests/main/interfaces-kernel-module-control: use globbing in MODULE_PATH
Some distributions use compressed kernel modules (*.ko.gz). Use globbing in
MODULE_PATH to cover differences.

Signed-off-by: Maciej Borzecki <maciej.zenon.borzecki@canonical.com>
tests/main/snapd-reexec: disable on Arch
Reexec is not supported on Arch yet.

Signed-off-by: Maciej Borzecki <maciej.zenon.borzecki@canonical.com>
tests/main/security-device-cgroups-serial-port: disable on Arch
Signed-off-by: Maciej Borzecki <maciej.zenon.borzecki@canonical.com>
tests/main/security-device-cgroups-jailmode: disable on Arch
Arch does not support 'jailmode'.

Signed-off-by: Maciej Borzecki <maciej.zenon.borzecki@canonical.com>
tests/main/interfaces-avahi-observe: disable on Arch
Avahi package is named 'avahi' on Arch. Disable the test for now until a
translation is added to tests/lib/pkgdb.sh

Signed-off-by: Maciej Borzecki <maciej.zenon.borzecki@canonical.com>
tests/main/debs-have-built-using: disable on Arch
Arch does not support debs.

Signed-off-by: Maciej Borzecki <maciej.zenon.borzecki@canonical.com>
tests/main/classic-ubuntu-core-transition[-auth]: disable on Arch
Disable both tests on Arch.

Signed-off-by: Maciej Borzecki <maciej.zenon.borzecki@canonical.com>
tests/main/manpages: workaround mandb index not updated on Arch
We are hitting a special case on Arch, where man-db is only updated on a timer
service and not in package post install hooks. This causes man commands that use
index cache to not find snapd man pages.

Signed-off-by: Maciej Borzecki <maciej.zenon.borzecki@canonical.com>
spread: bump the number of Arch workers to 3
Signed-off-by: Maciej Borzecki <maciej.zenon.borzecki@canonical.com>
tests/lib: introduce helpers for setting up /dev/random using /dev/ur…
…andom in project prepare

The hosts used for testing may run out of entropy in /dev/random, thus causing
any crypto operations to potentially block. Since we do not need a high quality
RNG source for the tests, set up /dev/random to be the same as /dev/urandom in
project prepare and restore it back to the proper state in project restore
phase.

Signed-off-by: Maciej Borzecki <maciej.zenon.borzecki@canonical.com>
tests/regression/lp-1618683: disable on Arch, no CONFIG_USER_NS
Arch's default kernel does not ship with CONFIG_USER_NS yet. Disable the test
until this changes upstream.

Signed-off-by: Maciej Borzecki <maciej.zenon.borzecki@canonical.com>
spread: disable unit and nightly tests on Arch
Signed-off-by: Maciej Borzecki <maciej.zenon.borzecki@canonical.com>
tests/upgrade/snapd-xdg-open: disable on Arch
Signed-off-by: Maciej Borzecki <maciej.zenon.borzecki@canonical.com>
tests/regression/lp-1641885: disable on Arch
Signed-off-by: Maciej Borzecki <maciej.zenon.borzecki@canonical.com>
tests/main/snap-confine-from-core: disable on Arch
Signed-off-by: Maciej Borzecki <maciej.zenon.borzecki@canonical.com>
tests/main/interfaces-kernel-module-control: disable on Arch
Signed-off-by: Maciej Borzecki <maciej.zenon.borzecki@canonical.com>
tests/lib/pkgdb: make sure we do systemd daemon-reload on Arch
Arch policy does not allow doing daemon-reloads in package install scripts.
Let's do this ourselves before enabling the socket.

Signed-off-by: Maciej Borzecki <maciej.zenon.borzecki@canonical.com>
tests/regression/lp-1618683: properly disable the test on Arch
Signed-off-by: Maciej Borzecki <maciej.zenon.borzecki@canonical.com>
tests/upgrade/basic: workaround Arch issues
Signed-off-by: Maciej Borzecki <maciej.zenon.borzecki@canonical.com>
spread/arch: prefer mirrors.kernel.org
Prefer a mirror that should work good most of the time

Signed-off-by: Maciej Borzecki <maciej.zenon.borzecki@canonical.com>
tests/main/snap-info: handle non utf-8 input encoding in checks
The tests set LANG to C.UTF-8, which is not a standard locale (at least not
present in the vanilla glibc). On Arch this results in all input to be
'C' encoded. `snap info` outputs UTF-8 encoded output regardless of locale.
Apply conversions in the check.py script to handle input in different encoding.

Mark check.py as utf-8 encoded, since it contains Unicode codepoints inside

Signed-off-by: Maciej Borzecki <maciej.zenon.borzecki@canonical.com>
packaging/arch: disable services when removing
Disable all snapd services when removing the package. This prevents the symlinks
to be left behind when the package is removed.

Signed-off-by: Maciej Borzecki <maciej.zenon.borzecki@canonical.com>
tests/main/media-sharing: detect and handle merged usr /media location
Signed-off-by: Maciej Borzecki <maciej.zenon.borzecki@canonical.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment