Merge ~rodsmith/plainbox-provider-checkbox:add-iso-boot-test into plainbox-provider-checkbox:master

Proposed by Rod Smith
Status: Needs review
Proposed branch: ~rodsmith/plainbox-provider-checkbox:add-iso-boot-test
Merge into: plainbox-provider-checkbox:master
Diff against target: 252 lines (+148/-76)
3 files modified
bin/install-method-check.sh (+139/-0)
dev/null (+0/-75)
units/miscellanea/jobs.pxu (+9/-1)
Reviewer Review Type Date Requested Status
Checkbox Developers Pending
Review via email: mp+419470@code.launchpad.net

Commit message

Add: Test that system was installed from Subiquity ISO image

Description of the change

Renames maas-version-check.sh to install-method-check.sh and expands that script to test either of two cases:

* That the server was installed via MAAS and the MAAS version is known
* That the server was installed via Subiquity/an ISO image

The same conditions can be used to test either case; it's just their outcomes that must differ.

For the first case, the results should be identical to the old maas-version-check.sh script. Here's a submission that demonstrates this:

* https://certification.canonical.com/hardware/201006-5798/submission/259147/
  * https://certification.canonical.com/hardware/201006-5798/submission/259147/test/58324/result/25018913/

For the second case, a new launcher is required (MR to be submitted shortly). Passing (installed via ISO image on USB flash drive) and failing (installed via MAAS) submissions are:

* https://certification.canonical.com/hardware/201508-19150/submission/259144/
  * https://certification.canonical.com/hardware/201508-19150/submission/259144/test/157430/result/25018664/

* https://certification.canonical.com/hardware/201006-5798/submission/259146/
  * https://certification.canonical.com/hardware/201006-5798/submission/259146/test/157430/result/25018901/

This MR should be merged BEFORE the companion MR to plainbox-provider-certification-server.

To post a comment you must log in.
Revision history for this message
Rod Smith (rodsmith) wrote :
Revision history for this message
Jeff Lane  (bladernr) wrote :

Just some nitpics and one slightly more important suggestion inline (that's still a nitpick about final output).

Revision history for this message
Rod Smith (rodsmith) wrote :

I'm afraid that git blew up in my face and the documentation I found online failed to help, so I've resubmitted this MR, with the changes noted inline below:

https://code.launchpad.net/~rodsmith/plainbox-provider-checkbox/+git/plainbox-provider-checkbox/+merge/419489

(I had several failures of various types along the way. I suspect that Launchpad is overloaded in the week leading up to 22.04's release.)

Unmerged commits

cb873e6... by Rod Smith

Add: Test that system was installed from Subiquity ISO image

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
diff --git a/bin/install-method-check.sh b/bin/install-method-check.sh
0new file mode 1007550new file mode 100755
index 0000000..cffe8a7
--- /dev/null
+++ b/bin/install-method-check.sh
@@ -0,0 +1,139 @@
1#!/bin/bash
2
3# Copyright (C) 2012-2022 Canonical Ltd.
4
5# Authors
6# Jeff Lane <jeff@ubuntu.com>
7# Rod Smith <rod.smith@canonical.com>
8
9# This program is free software: you can redistribute it and/or modify
10# it under the terms of the GNU General Public License version 3,
11# as published by the Free Software Foundation.
12
13# This program is distributed in the hope that it will be useful,
14# but WITHOUT ANY WARRANTY; without even the implied warranty of
15# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16# GNU General Public License for more details.
17
18# You should have received a copy of the GNU General Public License
19# along with this program. If not, see <http://www.gnu.org/licenses/>.
20
21MAAS_FILE="/etc/installed-by-maas"
22DATASOURCE_FILE="/var/lib/cloud/instance/datasource"
23INSTALL_DATASOURCE=""
24SUBIQUITY_LOG_FILE1="/var/log/installer/subiquity-info.log" # Observed on 20.04
25SUBIQUITY_LOG_FILE2="/var/log/installer/subiquity-server-info.log" # Observed on 22.04
26CONFIRM_INSTALL_TYPE="maas" # or "subiquity", maybe others in future
27RETVAL="0"
28
29get_params() {
30 # Default to equivalent of --verify-maas-install; the option is
31 # provided for clarity in calling script.
32 while [[ $# -gt 0 ]]; do
33 case $1 in
34 --verify-maas-install|-m)
35 CONFIRM_INSTALL_TYPE="maas" # should already be set
36 ;;
37 --verify-iso-install|-i)
38 CONFIRM_INSTALL_TYPE="subiquity"
39 ;;
40 *) echo "Usage: $0 [ -m, --verify-maas-install ] | [ -i, --verify-iso-install ]"
41 ;;
42 esac
43 shift
44 done
45 INSTALL_DATASOURCE_FOUND=0 # Should be found for both MAAS & subiquity
46 MAAS_IP_FOUND=0 # Should be found for MAAS but not subiquity
47 MAAS_VERSION_FOUND=0 # Should be found for MAAS but not subiquity
48 SUBIQUITY_LOG_FOUND=0 # Should be found for subiquity but not MAAS
49}
50
51# Context-sensitive echo() function; prints the message only if the program
52# is launched to confirm a MAAS installation
53conditional_print() {
54 if [[ "$CONFIRM_INSTALL_TYPE" == "$2" ]] ; then
55 echo "$1"
56 fi
57}
58
59# Find the installation data source, as recorded in cloud installer files.
60# This should be present for both MAAS and subiquity installs.
61get_install_datasource() {
62 # Is the file there?
63 if [ -s $DATASOURCE_FILE ]; then
64 INSTALL_DATASOURCE=$(cut -d "[" -f 2 $DATASOURCE_FILE | cut -d "]" -f 1)
65 echo "Installation data source is $INSTALL_DATASOURCE"
66 INSTALL_DATASOURCE_FOUND=1
67 else
68 echo "ERROR: The installation data source file ($DATASOURCE_FILE)"
69 echo "cannot be found."
70 fi
71}
72
73# Verify that the $INSTALL_DATASOURCE points to a valid IP address.
74# Note: Function assumes that $INSTALL_DATASOURCE is already set, as is
75# done by the get_install_datasource() function.
76verify_maas_ip() {
77 if [[ $INSTALL_DATASOURCE_FOUND == 1 ]]; then
78 MAAS_HOSTNAME=$(echo "$INSTALL_DATASOURCE" | cut -d "/" -f 3 | cut -d ":" -f 1)
79 HOST_OUTPUT=$(host "$MAAS_HOSTNAME" | grep "has address")
80 status=$?
81 if [[ $status -eq 0 ]]; then
82 MAAS_IP=$(echo "$HOST_OUTPUT" | cut -d " " -f 4)
83 conditional_print "MAAS server's IP address is $MAAS_IP" "maas"
84 conditional_print "ERROR: MAAS server's IP address is $MAAS_IP" "subiquity"
85 MAAS_IP_FOUND=1
86 else
87 conditional_print "ERROR: Unable to determine MAAS server's IP address" "maas"
88 fi
89 fi
90}
91
92# Pull the MAAS version information from a file left here by the
93# Server Certification pre-seed file
94get_maas_version() {
95 # Is the file there?
96 if [ -s $MAAS_FILE ]; then
97 maas_version=$(cat $MAAS_FILE)
98 conditional_print "MAAS version is $maas_version" "maas"
99 conditional_print "ERROR: Server Certification MAAS version file found; MAAS version is $maas_version" "subiquity"
100 MAAS_VERSION_FOUND=1
101 else
102 conditional_print "ERROR: The MAAS version cannot be determined" "maas"
103 fi
104}
105
106find_subiquity_log() {
107 if [[ -f "$SUBIQUITY_LOG_FILE1" || -f "$SUBIQUITY_LOG_FILE2" ]]; then
108 conditional_print "ERROR: Subiquity log file found" "maas"
109 conditional_print "subiquity log file found" "subiquity"
110 SUBIQUITY_LOG_FOUND=1
111 else
112 conditional_print "ERROR: Subiquity log file not found" "subiquity"
113 fi
114}
115
116#######################
117#
118# Main program begins here....
119#
120#######################
121
122get_params "$@"
123
124# Check for various installation signatures....
125get_install_datasource
126verify_maas_ip
127get_maas_version
128find_subiquity_log
129
130MAAS_FOUND=$((INSTALL_DATASOURCE_FOUND && MAAS_IP_FOUND && MAAS_VERSION_FOUND))
131SUBIQUITY_FOUND=$((INSTALL_DATASOURCE_FOUND && SUBIQUITY_LOG_FOUND))
132
133if [[ $CONFIRM_INSTALL_TYPE == "maas" ]] ; then
134 RETVAL=$((! MAAS_FOUND)) || SUBIQUITY_FOUND
135elif [[ $CONFIRM_INSTALL_TYPE == "subiquity" ]] ; then
136 RETVAL=$((! SUBIQUITY_FOUND)) || MAAS_FOUND
137fi
138
139exit $RETVAL
diff --git a/bin/maas-version-check.sh b/bin/maas-version-check.sh
0deleted file mode 100755140deleted file mode 100755
index 7d97f0b..0000000
--- a/bin/maas-version-check.sh
+++ /dev/null
@@ -1,75 +0,0 @@
1#!/bin/bash
2
3# Copyright (C) 2012-2022 Canonical Ltd.
4
5# Authors
6# Jeff Lane <jeff@ubuntu.com>
7# Rod Smith <rod.smith@canonical.com>
8
9# This program is free software: you can redistribute it and/or modify
10# it under the terms of the GNU General Public License version 3,
11# as published by the Free Software Foundation.
12
13# This program is distributed in the hope that it will be useful,
14# but WITHOUT ANY WARRANTY; without even the implied warranty of
15# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16# GNU General Public License for more details.
17
18# You should have received a copy of the GNU General Public License
19# along with this program. If not, see <http://www.gnu.org/licenses/>.
20
21MAAS_FILE="/etc/installed-by-maas"
22DATASOURCE_FILE="/var/lib/cloud/instance/datasource"
23MAAS_DATASOURCE=""
24RETVAL="0"
25
26# Find the MAAS data source, as recorded in cloud installer files
27get_maas_datasource() {
28 # Is the file there?
29 if [ -s $DATASOURCE_FILE ]; then
30 MAAS_DATASOURCE=$(cut -d "[" -f 2 $DATASOURCE_FILE | cut -d "]" -f 1)
31 echo "MAAS data source is $MAAS_DATASOURCE"
32 else
33 echo "ERROR: This system does not appear to have been installed by MAAS"
34 echo "ERROR: " "$(ls -l $DATASOURCE_FILE 2>&1)"
35 RETVAL="1"
36 fi
37}
38
39# Verify that the $MAAS_DATASOURCE points to a valid IP address.
40# Note: Function assumes that $MAAS_DATASOURCE is already set, as is
41# done by the get_maas_datasource() function.
42verify_maas_ip() {
43 if [[ $RETVAL == 0 ]]; then
44 MAAS_HOSTNAME=$(echo "$MAAS_DATASOURCE" | cut -d "/" -f 3 | cut -d ":" -f 1)
45 HOST_OUTPUT=$(host "$MAAS_HOSTNAME" | grep "has address")
46 status=$?
47 if [[ $status -eq 0 ]]; then
48 MAAS_IP=$(echo "$HOST_OUTPUT" | cut -d " " -f 4)
49 echo "MAAS server's IP address is $MAAS_IP"
50 else
51 echo "ERROR: Unable to determine MAAS server's IP address"
52 RETVAL=1
53 fi
54 fi
55}
56
57# Pull the MAAS version information from a file left here by the
58# Server Certification pre-seed file
59get_maas_version() {
60 # Is the file there?
61 if [ -s $MAAS_FILE ]; then
62 maas_version=$(cat $MAAS_FILE)
63 echo "MAAS version is $maas_version"
64 else
65 echo "ERROR: The MAAS version cannot be determined"
66 echo "ERROR: " "$(ls -l $MAAS_FILE 2>&1)"
67 RETVAL="1"
68 fi
69}
70
71get_maas_datasource
72verify_maas_ip
73get_maas_version
74
75exit $RETVAL
diff --git a/units/miscellanea/jobs.pxu b/units/miscellanea/jobs.pxu
index 785eebe..1168391 100644
--- a/units/miscellanea/jobs.pxu
+++ b/units/miscellanea/jobs.pxu
@@ -396,12 +396,20 @@ plugin: shell
396category_id: com.canonical.plainbox::miscellanea396category_id: com.canonical.plainbox::miscellanea
397estimated_duration: 0.1397estimated_duration: 0.1
398id: miscellanea/get_maas_version398id: miscellanea/get_maas_version
399command: maas-version-check.sh399command: install-method-check.sh --verify-maas-install
400_description: If system was installed via MAAS from a cert server, the MAAS version used should be contained in /etc/installed-by-maas400_description: If system was installed via MAAS from a cert server, the MAAS version used should be contained in /etc/installed-by-maas
401_summary: Verify MAAS version used to deploy the SUT401_summary: Verify MAAS version used to deploy the SUT
402402
403plugin: shell403plugin: shell
404category_id: com.canonical.plainbox::miscellanea404category_id: com.canonical.plainbox::miscellanea
405estimated_duration: 0.1
406id: miscellanea/test_iso_install
407command: install-method-check.sh --verify-iso-install
408_description: Test that the system was installed via a Subiquity ISO image
409_summary: Test that the system was installed via a Subiquity ISO image
410
411plugin: shell
412category_id: com.canonical.plainbox::miscellanea
405estimated_duration: 30.0413estimated_duration: 30.0
406id: miscellanea/get_make_and_model414id: miscellanea/get_make_and_model
407user: root415user: root

Subscribers

People subscribed via source and target branches