Merge lp:~mwhudson/ubuntu-test-cases/live-server-testing into lp:ubuntu-test-cases/live-server

Proposed by Michael Hudson-Doyle
Status: Merged
Approved by: Joshua Powers
Approved revision: no longer in the source branch.
Merged at revision: 13
Proposed branch: lp:~mwhudson/ubuntu-test-cases/live-server-testing
Merge into: lp:ubuntu-test-cases/live-server
Diff against target: 154 lines (+118/-0)
7 files modified
preseeds/reuse-existing-partitions-simple.preseed (+41/-0)
runlists/reuse-existing-partitions-simple.run (+4/-0)
scripts/reuse-existing-partitions-simple.sh (+24/-0)
testsuites/reuse-existing-partitions-simple/test_reuse_existing_partitions_simple/tc_control (+10/-0)
testsuites/reuse-existing-partitions-simple/test_reuse_existing_partitions_simple/test.py (+36/-0)
testsuites/reuse-existing-partitions-simple/ts_control (+1/-0)
testsuites/reuse-existing-partitions-simple/tslist.run (+2/-0)
To merge this branch: bzr merge lp:~mwhudson/ubuntu-test-cases/live-server-testing
Reviewer Review Type Date Requested Status
Subiquity Pending
Review via email: mp+369982@code.launchpad.net

Commit message

simple test of reusing existing partition

Description of the change

So this works if I run it by hand locally and so might work in automation too :)

There are a couple of things that need to be cleared up before we start running this for real though:

0) it depends on changes I made to utah yesterday, so utah needs to be updated on venonat.
1) the "script" reuse.sh that constructs the image needs to run as root. I don't know if the scripts are run as root by default or if we need to do something different or if it's just a matter of putting "sudo sh -c" in the right place.
2) the image that it creates will (I think) end up in the workspace and so waste heaps of disk. This could be fixed by agreeing a location in the workspace that run-iso-test.sh in qa-jenkins-jobs should clear out after utah has run.

To post a comment you must log in.
Revision history for this message
Paride Legovini (paride) wrote :

Hi Michael,

0) Done, I merged your changes, the packages have been rebuilt and I updated utah on venonat.

1) The jobs do not normally run as root, but sudo can be used when needed.

2) The best way to handle this is via the "Workspace Cleanup" Jenkins plugin, which is currently not installed in the platform-qa-jenkins, but we can request it. In the meantime I don't think this is a blocker: venonat has quite a lot of disk space, if we keep an eye on it I think we can manage without the cleanup for the moment. Workspace are re-used in each job run, so the number of images won't grow indefinitely.

In general the test looks good. A couple of ideas/questions:

0) reuse.sh creates an image which is identical every time. We could avoid running commands as root by shipping root.img with the test, or making downloading it from somewhere. The image file looks 10G big, but du(1) reveals the actual disk usage is of just 17MB, and the file is 10MB gzipped.

1) Can we call the test 'reuse-existing-partitions' instead of 'reuse'? This whole thing is already convoluted enough :-)

Paride

Revision history for this message
Michael Hudson-Doyle (mwhudson) wrote :

On Fri, 12 Jul 2019 at 22:42, Paride Legovini <email address hidden>
wrote:

> Hi Michael,
>
> 0) Done, I merged your changes, the packages have been rebuilt and I
> updated utah on venonat.
>

Thanks!

> 1) The jobs do not normally run as root, but sudo can be used when needed.
>

OK, I'll shuffle that around.

> 2) The best way to handle this is via the "Workspace Cleanup" Jenkins
> plugin, which is currently not installed in the platform-qa-jenkins, but we
> can request it. In the meantime I don't think this is a blocker: venonat
> has quite a lot of disk space, if we keep an eye on it I think we can
> manage without the cleanup for the moment. Workspace are re-used in each
> job run, so the number of images won't grow indefinitely.
>

Oh if workspaces are per-project not per-run then that's not so bad.

> In general the test looks good. A couple of ideas/questions:
>
> 0) reuse.sh creates an image which is identical every time. We could avoid
> running commands as root by shipping root.img with the test, or making
> downloading it from somewhere. The image file looks 10G big, but du(1)
> reveals the actual disk usage is of just 17MB, and the file is 10MB gzipped.
>

We could but ... hm. 10MB seems a bit big to just check into the branch
(there will be more of these I hope!) and there already enough moving parts
here without having to worry about hosting the files somewhere else and
keeping them in sync with test expectations. So I think I'd prefer to keep
on doing things this way. You can argue me around if you feel strongly
enough about this though :)

> 1) Can we call the test 'reuse-existing-partitions' instead of 'reuse'?
> This whole thing is already convoluted enough :-)
>

Yeah that's definitely a good idea! I've pushed a rename to
reuse-existing-partitions-simple.

Cheers,
mwh

Revision history for this message
Michael Hudson-Doyle (mwhudson) wrote :

Is there any reason we can't merge this now?

13. By Michael Hudson-Doyle

merge simple test of reusing partitions

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added file 'preseeds/reuse-existing-partitions-simple.preseed'
2--- preseeds/reuse-existing-partitions-simple.preseed 1970-01-01 00:00:00 +0000
3+++ preseeds/reuse-existing-partitions-simple.preseed 2019-07-18 04:22:28 +0000
4@@ -0,0 +1,41 @@
5+Welcome:
6+ lang: en_US
7+Refresh:
8+ update: no
9+Keyboard:
10+ layout: us
11+Installpath:
12+ path: ubuntu
13+Network:
14+ accept-default: yes
15+Proxy:
16+ proxy: ""
17+Mirror:
18+ mirror: "http://us.archive.ubuntu.com/ubuntu"
19+Filesystem:
20+ manual:
21+ - obj: [disk index 0]
22+ action: MAKE_BOOT
23+ - # Mount second partition at /srv without reformatting
24+ obj: [disk index 0, part 1]
25+ action: EDIT
26+ data:
27+ fstype: null
28+ mount: /srv
29+ - # Reformat third partition and use it as /
30+ obj: [disk index 0, part 2]
31+ action: EDIT
32+ data:
33+ fstype: ext4
34+ mount: /
35+ - action: done
36+# Utah fills out the Identity section by itself
37+SnapList:
38+ snaps:
39+ hello:
40+ channel: stable
41+ is_classic: false
42+InstallProgress:
43+ reboot: yes
44+
45+
46
47=== added file 'runlists/reuse-existing-partitions-simple.run'
48--- runlists/reuse-existing-partitions-simple.run 1970-01-01 00:00:00 +0000
49+++ runlists/reuse-existing-partitions-simple.run 2019-07-18 04:22:28 +0000
50@@ -0,0 +1,4 @@
51+testsuites:
52+ - name: reuse-existing-partitions-simple
53+ fetch_method: bzr-export
54+ fetch_location: lp:~mwhudson/ubuntu-test-cases/live-server/testsuites/reuse-existing-partitions-simple
55
56=== added file 'scripts/reuse-existing-partitions-simple.sh'
57--- scripts/reuse-existing-partitions-simple.sh 1970-01-01 00:00:00 +0000
58+++ scripts/reuse-existing-partitions-simple.sh 2019-07-18 04:22:28 +0000
59@@ -0,0 +1,24 @@
60+#!/bin/sh
61+SCRIPT_DIR=$(readlink -e $(dirname $0))
62+set -eu
63+sudo sh -euxc '
64+ mkdir -p images
65+ rm -f images/root.img
66+ truncate -s 10G images/root.img
67+ parted --script --align optimal images/root.img -- \
68+ mklabel gpt \
69+ mkpart primary ext4 1MiB 2MiB \
70+ set 1 bios_grub on \
71+ mkpart primary ext4 2MiB 1GiB \
72+ mkpart primary ext4 1GiB -2048s
73+ rootdev="$(losetup -Pf --show images/root.img)"
74+ mkfs.ext4 "${rootdev}p2"
75+ mkdir -p mnt
76+ mount "${rootdev}p2" mnt
77+ touch mnt/existing
78+ umount mnt
79+ losetup -d $rootdev
80+ chown $SUDO_USER images/root.img
81+' 1>&2
82+. $SCRIPT_DIR/base.sh
83+echo $CMD --disk-image $(pwd)/images/root.img
84
85=== added directory 'testsuites/reuse-existing-partitions-simple'
86=== added directory 'testsuites/reuse-existing-partitions-simple/test_reuse_existing_partitions_simple'
87=== added file 'testsuites/reuse-existing-partitions-simple/test_reuse_existing_partitions_simple/tc_control'
88--- testsuites/reuse-existing-partitions-simple/test_reuse_existing_partitions_simple/tc_control 1970-01-01 00:00:00 +0000
89+++ testsuites/reuse-existing-partitions-simple/test_reuse_existing_partitions_simple/tc_control 2019-07-18 04:22:28 +0000
90@@ -0,0 +1,10 @@
91+description: A test to check if we successfully mounted an existing partition
92+dependencies: n/a
93+action :
94+ 1. Check if there is a file at /srv/existing
95+expected_results :
96+ 1. There is a file at /srv/existing
97+type: userland
98+run_as: root
99+timeout: 200
100+command: python test.py
101
102=== added file 'testsuites/reuse-existing-partitions-simple/test_reuse_existing_partitions_simple/test.py'
103--- testsuites/reuse-existing-partitions-simple/test_reuse_existing_partitions_simple/test.py 1970-01-01 00:00:00 +0000
104+++ testsuites/reuse-existing-partitions-simple/test_reuse_existing_partitions_simple/test.py 2019-07-18 04:22:28 +0000
105@@ -0,0 +1,36 @@
106+#!/usr/bin/python
107+#
108+# Copyright (C) 2019, Canonical Ltd (http://www.canonical.com/)
109+#
110+# This file is part of ubuntu-server-iso-testing.
111+#
112+# ubuntu-server-iso-testing is free software: you can redistribute it
113+# and/or modify it under the terms of the GNU General Public License
114+# as published by the Free Software Foundation, either version 3 of
115+# the License, or (at your option) any later version.
116+#
117+# ubuntu-server-iso-testing is distributed in the hope that it will
118+# be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
119+# of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
120+# GNU General Public License for more details.
121+#
122+# You should have received a copy of the GNU General Public License
123+# along with ubuntu-server-iso-testing. If not, see
124+# <http://www.gnu.org/licenses/>.
125+#
126+
127+
128+import logging
129+import os
130+import unittest
131+
132+logging.basicConfig(level=logging.DEBUG)
133+
134+
135+class ReuseTest(unittest.TestCase):
136+ def testReuse(self):
137+ self.assertTrue(os.path.exists("/srv/existing"),
138+ "no file found at /srv/existing")
139+
140+if __name__ == "__main__":
141+ unittest.main()
142
143=== added file 'testsuites/reuse-existing-partitions-simple/ts_control'
144--- testsuites/reuse-existing-partitions-simple/ts_control 1970-01-01 00:00:00 +0000
145+++ testsuites/reuse-existing-partitions-simple/ts_control 2019-07-18 04:22:28 +0000
146@@ -0,0 +1,1 @@
147+timeout: 500
148
149=== added file 'testsuites/reuse-existing-partitions-simple/tslist.run'
150--- testsuites/reuse-existing-partitions-simple/tslist.run 1970-01-01 00:00:00 +0000
151+++ testsuites/reuse-existing-partitions-simple/tslist.run 2019-07-18 04:22:28 +0000
152@@ -0,0 +1,2 @@
153+- test: test_reuse_existing_partitions_simple
154+ run_as: root

Subscribers

People subscribed via source and target branches

to all changes: