Add testing infrastructure #8

Merged
merged 19 commits into from Dec 7, 2017

Conversation

Projects
None yet
2 participants
Contributor

zyga commented Dec 6, 2017

This patch adds a very crude way for boot-testing the new
base-18 base snap and to run spread tests against it.

There are a lot of shortcomings but it boots to the familiar-looking
"Welcome to Ubuntu Core 18" message and to a root shell.

The typical workflow involves updating the base snap (e.g. via snapcraft)
and then running make -C tests/lib which will boot the image and give us
a root shell to explore the system.

EDIT: This is now updated to support basic spread tests.

Signed-off-by: Zygmunt Krynicki zygmunt.krynicki@canonical.com

zyga added some commits Dec 6, 2017

Add rudimentary testing infrastructure
This patch adds a very simple (crude) way for boot-testing the new
base-18 base snap. There are a lot of shortcomings but it boots to the
familiar-looking "Welcome to Ubuntu Core 18" message.

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
Refactor testing scripts to allow easier interactive editing of rootfs
Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
Boot qemu with systemd.debug-shell=1
This allows one to navigate to tty7 and get a root shell.
In qemu just alt+{left,right}-arrow to do that.
In a wayland session this is broken so you may want to log into X11.

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
Update main README about testing
Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
Use deterministic values for various generated UUIDs
Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
Tweak kpartx grep to capture base loop device name
Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
Construct barren EFI system partition
This is not really needed yet but once we get to snapd booting it will
want to see the files it expects there.

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
Move all the test support to tests/lib
This just for familiarity with snapd

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
Remove empty whitespace
Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
Dist-upgrade the chroot
Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
Add a spread support hook
This hook gives us an ubuntu/ubuntu user that can sudo without a password.
The system will boot up with DHCP network and SSH enabled out of the box.

We obviously don't want this (eventually) but it is a simple thing to
do from a hook. Later on this should be done in a step that occurs after
the snap is built (ideally just hack the user and enable stuff by default,
packages should be pre-installed).

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
Add a hacked version of writable-paths
This is way smaller (improvements should just reduce it to zero) than
what we ship in base-16 but enough for the system to "stand up".

Notably missing is /home as this preserves our /home user that is hacked
by the spread support hook.

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
Add spread suite!
Just very raw spread support. You have to build and update the image
manually with:

 - sudo snapcraft clean
 - sudo snapcraft
 - make -C tests/lib (and then exit the VM)

After that is done spread will operate correctly.

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
Update README with testing instructions
Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
tests: add convenience targets and document things better
Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
tests: have spread run without a console (headless)
Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
makefile: add update-image target
This target runs spread but should be extended to just build the
snap manually, faster and without such CPU-heavy compression.
The goal is to accelerate development cycles while still retain
the ability to build with spread for production.

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>

@zyga zyga changed the title from Add rudimentary testing infrastructure to Add testing infrastructure Dec 7, 2017

Update README
Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>

mvo5 approved these changes Dec 7, 2017

Looks good, I want to trim writable-path but we can do that step-by-step.

set -eux
apt update
+apt dist-upgrade -y
@mvo5

mvo5 Dec 7, 2017

Collaborator

Aha, we need this to avoid extra bootstraps when iterating?

@zyga

zyga Dec 7, 2017

Contributor

Not really, I just added it felt right.

@@ -0,0 +1,36 @@
+#!/bin/sh -x
+
@mvo5

mvo5 Dec 7, 2017

Collaborator

Maybe a comment here that this is really only required while developing? I'm a bit scared that this may be forgotten and leak at some point into the store :/

@zyga

zyga Dec 7, 2017

Contributor

Sure, done now.

+#
+# See writable-paths(5) for full details.
+# --------------------------------------------------------------------
+/etc/apparmor.d/cache auto persistent none none
@mvo5

mvo5 Dec 7, 2017

Collaborator

/o\ - do we need all of those?

@zyga

zyga Dec 7, 2017

Contributor

No, but I gave up with trimming the list. I suspect we get better result by speeding up make update-image and then fix this list.

@mvo5 mvo5 merged commit be98dbd into snapcore:master Dec 7, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment