Merge ~jhodapp/snappy-hwe-snaps/+git/build-scripts:run-tests into ~snappy-hwe-team/snappy-hwe-snaps/+git/build-scripts:master

Proposed by Jim Hodapp
Status: Merged
Approved by: Simon Fels
Approved revision: c974dee035b2bd559fb9d0c902bb9999e7233708
Merged at revision: 72c94f9244b54ebc9cb71f875bae07345e877724
Proposed branch: ~jhodapp/snappy-hwe-snaps/+git/build-scripts:run-tests
Merge into: ~snappy-hwe-team/snappy-hwe-snaps/+git/build-scripts:master
Diff against target: 95 lines (+47/-8)
1 file modified
jobs/generic-run-snap-spread-tests (+47/-8)
Reviewer Review Type Date Requested Status
Simon Fels Approve
System Enablement Bot continuous-integration Approve
Review via email: mp+317150@code.launchpad.net

Description of the change

Run the run-tests.sh script in a chroot which allows any type of tests to be run and not just spread tests (e.g. upstream project unit tests).

To post a comment you must log in.
Revision history for this message
System Enablement Bot (system-enablement-ci-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
Simon Fels (morphis) :
review: Needs Fixing
Revision history for this message
Jim Hodapp (jhodapp) :
Revision history for this message
Simon Fels (morphis) :
Revision history for this message
System Enablement Bot (system-enablement-ci-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
Simon Fels (morphis) wrote :

LGTM

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/jobs/generic-run-snap-spread-tests b/jobs/generic-run-snap-spread-tests
2index ce3d49b..7bb6eff 100644
3--- a/jobs/generic-run-snap-spread-tests
4+++ b/jobs/generic-run-snap-spread-tests
5@@ -36,6 +36,7 @@ fi
6
7 $SSH mkdir -p $REMOTE_WORKSPACE/bin
8
9+# --- Spread build ---
10 cat << EOF > $WORKSPACE/build-spread.sh
11 #!/bin/bash
12 set -x
13@@ -83,7 +84,8 @@ ensure_package_is_installed() {
14 ensure_package_is_installed kpartx
15 ensure_package_is_installed qemu-kvm
16
17-cat << EOF > $WORKSPACE/run-spread-tests.sh
18+# --- Run tests ---
19+cat << EOF > $WORKSPACE/run-tests.sh
20 #!/bin/bash
21 set -x
22 set -e
23@@ -92,12 +94,11 @@ export TERM=linux
24 export DEBIAN_FRONTEND=noninteractive
25 export PATH=$REMOTE_WORKSPACE/bin:$PATH
26
27+[ ! -e $REMOTE_WORKSPACE ]; mkdir -p $REMOTE_WORKSPACE
28+mv src_branch.tar $REMOTE_WORKSPACE
29 cd $REMOTE_WORKSPACE
30
31-if [ -e "src_branch" ] ; then
32- rm -rf src_branch
33-fi
34-git clone -b $SOURCE_GIT_REPO_BRANCH $SOURCE_GIT_REPO src_branch
35+tar xf src_branch.tar
36 cd src_branch
37 # We require either a run-tests.sh interface script for the spread tests
38 # or the basic spread.yaml spread test definition file, otherwise we fail
39@@ -106,6 +107,7 @@ if [ ! -e "run-tests.sh" ] && [ ! -e "spread.yaml" ]; then
40 echo "ERROR: missing spread test: you must provide a spread test"
41 exit 1
42 fi
43+
44 if [ -e "run-tests.sh" ] ; then
45 if [ ! -z "$CHANNEL" ] ; then
46 ./run-tests.sh --channel=$CHANNEL --test-from-channel --debug --force-new-image
47@@ -122,8 +124,45 @@ fi
48 rm -rf src_branch
49 EOF
50
51-$SCP $WORKSPACE/run-spread-tests.sh $REMOTE_USER@$REMOTE_WORKER:$REMOTE_WORKSPACE/
52-$SSH chmod u+x $REMOTE_WORKSPACE/run-spread-tests.sh
53-$SSH sudo systemd-run --scope $REMOTE_WORKSPACE/run-spread-tests.sh
54+$SSH sudo apt install -y --force-yes debootstrap
55+BUILD_ROOTFS_TARBALL=$REMOTE_WORKSPACE/snap-build-$SERIES.tar
56+
57+# --- Build a rootfs for test running in a chroot ---
58+cat << EOF > $WORKSPACE/build-rootfs.sh
59+# Get build-scripts:
60+cd $REMOTE_WORKSPACE
61+
62+tar xf $REMOTE_WORKSPACE/build-scripts.tar -C $REMOTE_WORKSPACE
63+
64+sudo $REMOTE_WORKSPACE/build-scripts/scripts/build-rootfs-create $SERIES $BUILD_ROOTFS_TARBALL
65+EOF
66+
67+tar cf $WORKSPACE/build-scripts.tar $WORKSPACE/build-scripts
68+$SCP $WORKSPACE/build-scripts.tar $REMOTE_USER@$REMOTE_WORKER:$REMOTE_WORKSPACE/
69+
70+# No need to build the rootfs every time, but offer an option to do so
71+if [ ! -e $WORKSPACE/snap-build-$SERIES.tar] || [ "$REBUILD_ROOTFS" -eq "1" ]; then
72+ # Build rootfs
73+ chmod u+x WORKSPACE/build-rootfs.sh
74+ $WORKSPACE/build-rootfs.sh
75+fi
76+
77+$SCP $WORKSPACE/snap-build-$SERIES.tar $REMOTE_USER@$REMOTE_WORKER:$REMOTE_WORKSPACE/
78+
79+# Copy the rootfs and test-running script in place that can be used within the chroot
80+$SSH sudo tar xf $BUILD_ROOTFS_TARBALL -C $REMOTE_WORKSPACE
81+$SSH sudo chown -R ubuntu:ubuntu $REMOTE_WORKSPACE/rootfs
82+$SCP $WORKSPACE/run-tests.sh $REMOTE_USER@$REMOTE_WORKER:$REMOTE_WORKSPACE/rootfs
83+$SSH chmod u+x $REMOTE_WORKSPACE/rootfs/run-tests.sh
84+
85+# Copy the test source branch in place that can be used within the chroot
86+if [ -e "src_branch" ] ; then
87+ rm -rf src_branch
88+fi
89+git clone -b $SOURCE_GIT_REPO_BRANCH $SOURCE_GIT_REPO src_branch
90+tar cf src_branch.tar src_branch
91+$SCP $WORKSPACE/src_branch.tar $REMOTE_USER@$REMOTE_WORKER:$REMOTE_WORKSPACE/rootfs
92+
93+$SSH sudo chroot $REMOTE_WORKSPACE/rootfs /run-tests.sh
94
95 $SSH sudo rm -rf $REMOTE_WORKSPACE

Subscribers

People subscribed via source and target branches

to all changes: