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
diff --git a/jobs/generic-run-snap-spread-tests b/jobs/generic-run-snap-spread-tests
index ce3d49b..7bb6eff 100644
--- a/jobs/generic-run-snap-spread-tests
+++ b/jobs/generic-run-snap-spread-tests
@@ -36,6 +36,7 @@ fi
3636
37$SSH mkdir -p $REMOTE_WORKSPACE/bin37$SSH mkdir -p $REMOTE_WORKSPACE/bin
3838
39# --- Spread build ---
39cat << EOF > $WORKSPACE/build-spread.sh40cat << EOF > $WORKSPACE/build-spread.sh
40#!/bin/bash41#!/bin/bash
41set -x42set -x
@@ -83,7 +84,8 @@ ensure_package_is_installed() {
83ensure_package_is_installed kpartx84ensure_package_is_installed kpartx
84ensure_package_is_installed qemu-kvm85ensure_package_is_installed qemu-kvm
8586
86cat << EOF > $WORKSPACE/run-spread-tests.sh87# --- Run tests ---
88cat << EOF > $WORKSPACE/run-tests.sh
87#!/bin/bash89#!/bin/bash
88set -x90set -x
89set -e91set -e
@@ -92,12 +94,11 @@ export TERM=linux
92export DEBIAN_FRONTEND=noninteractive94export DEBIAN_FRONTEND=noninteractive
93export PATH=$REMOTE_WORKSPACE/bin:$PATH95export PATH=$REMOTE_WORKSPACE/bin:$PATH
9496
97[ ! -e $REMOTE_WORKSPACE ]; mkdir -p $REMOTE_WORKSPACE
98mv src_branch.tar $REMOTE_WORKSPACE
95cd $REMOTE_WORKSPACE99cd $REMOTE_WORKSPACE
96100
97if [ -e "src_branch" ] ; then101tar xf src_branch.tar
98 rm -rf src_branch
99fi
100git clone -b $SOURCE_GIT_REPO_BRANCH $SOURCE_GIT_REPO src_branch
101cd src_branch102cd src_branch
102# We require either a run-tests.sh interface script for the spread tests103# We require either a run-tests.sh interface script for the spread tests
103# or the basic spread.yaml spread test definition file, otherwise we fail104# or the basic spread.yaml spread test definition file, otherwise we fail
@@ -106,6 +107,7 @@ if [ ! -e "run-tests.sh" ] && [ ! -e "spread.yaml" ]; then
106 echo "ERROR: missing spread test: you must provide a spread test"107 echo "ERROR: missing spread test: you must provide a spread test"
107 exit 1108 exit 1
108fi109fi
110
109if [ -e "run-tests.sh" ] ; then111if [ -e "run-tests.sh" ] ; then
110 if [ ! -z "$CHANNEL" ] ; then112 if [ ! -z "$CHANNEL" ] ; then
111 ./run-tests.sh --channel=$CHANNEL --test-from-channel --debug --force-new-image113 ./run-tests.sh --channel=$CHANNEL --test-from-channel --debug --force-new-image
@@ -122,8 +124,45 @@ fi
122rm -rf src_branch124rm -rf src_branch
123EOF125EOF
124126
125$SCP $WORKSPACE/run-spread-tests.sh $REMOTE_USER@$REMOTE_WORKER:$REMOTE_WORKSPACE/127$SSH sudo apt install -y --force-yes debootstrap
126$SSH chmod u+x $REMOTE_WORKSPACE/run-spread-tests.sh128BUILD_ROOTFS_TARBALL=$REMOTE_WORKSPACE/snap-build-$SERIES.tar
127$SSH sudo systemd-run --scope $REMOTE_WORKSPACE/run-spread-tests.sh129
130# --- Build a rootfs for test running in a chroot ---
131cat << EOF > $WORKSPACE/build-rootfs.sh
132# Get build-scripts:
133cd $REMOTE_WORKSPACE
134
135tar xf $REMOTE_WORKSPACE/build-scripts.tar -C $REMOTE_WORKSPACE
136
137sudo $REMOTE_WORKSPACE/build-scripts/scripts/build-rootfs-create $SERIES $BUILD_ROOTFS_TARBALL
138EOF
139
140tar cf $WORKSPACE/build-scripts.tar $WORKSPACE/build-scripts
141$SCP $WORKSPACE/build-scripts.tar $REMOTE_USER@$REMOTE_WORKER:$REMOTE_WORKSPACE/
142
143# No need to build the rootfs every time, but offer an option to do so
144if [ ! -e $WORKSPACE/snap-build-$SERIES.tar] || [ "$REBUILD_ROOTFS" -eq "1" ]; then
145 # Build rootfs
146 chmod u+x WORKSPACE/build-rootfs.sh
147 $WORKSPACE/build-rootfs.sh
148fi
149
150$SCP $WORKSPACE/snap-build-$SERIES.tar $REMOTE_USER@$REMOTE_WORKER:$REMOTE_WORKSPACE/
151
152# Copy the rootfs and test-running script in place that can be used within the chroot
153$SSH sudo tar xf $BUILD_ROOTFS_TARBALL -C $REMOTE_WORKSPACE
154$SSH sudo chown -R ubuntu:ubuntu $REMOTE_WORKSPACE/rootfs
155$SCP $WORKSPACE/run-tests.sh $REMOTE_USER@$REMOTE_WORKER:$REMOTE_WORKSPACE/rootfs
156$SSH chmod u+x $REMOTE_WORKSPACE/rootfs/run-tests.sh
157
158# Copy the test source branch in place that can be used within the chroot
159if [ -e "src_branch" ] ; then
160 rm -rf src_branch
161fi
162git clone -b $SOURCE_GIT_REPO_BRANCH $SOURCE_GIT_REPO src_branch
163tar cf src_branch.tar src_branch
164$SCP $WORKSPACE/src_branch.tar $REMOTE_USER@$REMOTE_WORKER:$REMOTE_WORKSPACE/rootfs
165
166$SSH sudo chroot $REMOTE_WORKSPACE/rootfs /run-tests.sh
128167
129$SSH sudo rm -rf $REMOTE_WORKSPACE168$SSH sudo rm -rf $REMOTE_WORKSPACE

Subscribers

People subscribed via source and target branches

to all changes: