Merge ~canonical-kernel-team/+git/autotest-client-tests:ubuntu_stress_smoke_split_check_machine into ~canonical-kernel-team/+git/autotest-client-tests:master

Proposed by Paolo Pisati
Status: Merged
Merge reported by: Po-Hsu Lin
Merged at revision: 9a6184a4d19ddfe53ff16a616ac3fa7f24a41afa
Proposed branch: ~canonical-kernel-team/+git/autotest-client-tests:ubuntu_stress_smoke_split_check_machine
Merge into: ~canonical-kernel-team/+git/autotest-client-tests:master
Diff against target: 241 lines (+101/-89)
4 files modified
ubuntu_stress_smoke_test/control (+3/-3)
ubuntu_stress_smoke_test/ubuntu_stress_single_smoke_test.sh (+0/-86)
ubuntu_stress_smoke_test/ubuntu_stress_smoke_test.py (+9/-0)
ubuntu_stress_smoke_test/ubuntu_stress_smoke_test_checks.sh (+89/-0)
Reviewer Review Type Date Requested Status
Po-Hsu Lin Approve
Andrei Gherzan Approve
Review via email: mp+457444@code.launchpad.net

Commit message

Split check_machine() into its own separate script, and move it a the beginning of the call chain.

While here fix return code.

To post a comment you must log in.
Revision history for this message
Po-Hsu Lin (cypressyew) wrote :

Hi Paolo,

thanks for the enhancement, please find inline comments.

review: Needs Fixing
Revision history for this message
Andrei Gherzan (agherzan) wrote :

Looks good generally, but we could fix some small things with this refactoring.

review: Approve
Revision history for this message
Po-Hsu Lin (cypressyew) wrote :

Thanks!
I will take this updated version and make follow-ups to make sure tests can be skipped when the setup-check fails.

review: Approve
Revision history for this message
Po-Hsu Lin (cypressyew) wrote :

Applied and pushed.

Revision history for this message
Po-Hsu Lin (cypressyew) wrote :

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/ubuntu_stress_smoke_test/control b/ubuntu_stress_smoke_test/control
2index 394b9f9..319f4c1 100644
3--- a/ubuntu_stress_smoke_test/control
4+++ b/ubuntu_stress_smoke_test/control
5@@ -49,9 +49,9 @@ if flavour == 'kvm':
6 exclude.append('dnotify')
7
8
9-test_dir = os.path.join(job.bindir, 'tests', NAME)
10-cmd = '%s/ubuntu_stress_smoke_test_init.sh' % (test_dir)
11-utils.system_output(cmd, retain_output=True)
12+job.run_test_detail(NAME, test_name='setup-check' , tag='setup-check', timeout=35*60)
13+
14+job.run_test_detail(NAME, test_name='setup-init' , tag='setup-init', timeout=35*60)
15
16 result = job.run_test_detail(NAME, test_name='setup', tag='setup', timeout=60*60)
17 if result == 'GOOD':
18diff --git a/ubuntu_stress_smoke_test/ubuntu_stress_single_smoke_test.sh b/ubuntu_stress_smoke_test/ubuntu_stress_single_smoke_test.sh
19index 5ba3f9d..aa9b2d9 100755
20--- a/ubuntu_stress_smoke_test/ubuntu_stress_single_smoke_test.sh
21+++ b/ubuntu_stress_smoke_test/ubuntu_stress_single_smoke_test.sh
22@@ -3,12 +3,6 @@
23 [ $# -lt 1 ] && echo "$0 requires STRESSOR name to be run" && exit 1
24 STRESSOR=${1}
25
26-# Maximum machine age in years
27-MAX_AGE=5
28-# minimum required memory in MB
29-MIN_MEM=$((3 * 1024))
30-# minimum free disk required in GB
31-MIN_DISK=$((4))
32 # maximum bogo ops per stressor
33 MAX_BOGO_OPS=3000
34
35@@ -66,91 +60,11 @@ STRESS_OPTIONS="--ignite-cpu --syslog --verbose --verify --oomable"
36 rc=0
37 TMP_FILE=/tmp/stress-$$.log
38
39-check_message()
40-{
41- echo "NOTE: $1, skipping test"
42-}
43-
44-check_machine()
45-{
46- hostname=$(hostname)
47- processor=$(uname -p)
48- skip=0
49- case "$processor" in
50- i386 | i486 | i586 | i686 | x86_64)
51- datecheck=1
52-
53- manufacturer=$(dmidecode -s system-manufacturer)
54- if [ "$manufacturer" == "QEMU" ]; then
55- echo "QEMU instance, no firmware date checking"
56- datecheck=0
57- fi
58-
59- vendor=$(dmidecode -t 0x0000 | grep Vendor: | awk '{ print $2}')
60- if [ -z "$vendor" ]; then
61- vendor=$(dmidecode -t 0x000e | grep Vendor: | awk '{ print $2}')
62- fi
63-
64- case "$vendor" in
65- unknown | Unknown)
66- check_message "Unknown BIOS vendor, ignoring machine"
67- skip=1
68- datecheck=0
69- ;;
70- SeaBIOS)
71- echo "SeaBIOS BIOS, using a VM, no date checking"
72- datecheck=0
73- ;;
74- *)
75- ;;
76- esac
77-
78- if [ $datecheck -eq 1 ]; then
79- year=$(date +%Y)
80- year=$((year - $MAX_AGE))
81- date=$(dmidecode -t 0x0000 | grep "Release Date:" | cut -d'/' -f3)
82- if [ -z "$date" ]; then
83- date=$(dmidecode -t 0x000e | grep "Release Date:" | cut -d'/' -f3)
84- fi
85- if [ ! -z "$date" ]; then
86- if [ $date -lt $year ]; then
87- check_message "BIOS indicates machine is more then $MAX_AGE years old"
88- skip=1
89- fi
90- fi
91- fi
92- ;;
93- *)
94- echo "other"
95- ;;
96- esac
97-
98- mem=$(free | grep Mem: | awk '{print $2}')
99- mem=$((mem / 1024))
100- if [ $mem -lt $MIN_MEM ]; then
101- check_message "Machine has only $mem MB memory, requires at least $MIN_MEM MB"
102- skip=1
103- fi
104- disk=$(df . -B 1024 | awk '{print $4}' | tail -1)
105- disk=$((disk / 1048576))
106- if [ $disk -lt $MIN_DISK ]; then
107- check_message "Machine has only $disk GB free disk space, requires at least $MIN_DISK GB"
108- skip=1
109- fi
110-
111- if [ $skip -ne 0 ]; then
112- exit 0
113- fi
114-
115- echo "$hostname: $processor $mem MB memory, $disk GB disk"
116-}
117-
118 secs_now()
119 {
120 date "+%s"
121 }
122
123-check_machine
124
125 passed=""
126 failed=""
127diff --git a/ubuntu_stress_smoke_test/ubuntu_stress_smoke_test.py b/ubuntu_stress_smoke_test/ubuntu_stress_smoke_test.py
128index 2d78cf7..6fec4d2 100644
129--- a/ubuntu_stress_smoke_test/ubuntu_stress_smoke_test.py
130+++ b/ubuntu_stress_smoke_test/ubuntu_stress_smoke_test.py
131@@ -78,6 +78,15 @@ class ubuntu_stress_smoke_test(test.test):
132 def run_once(self, test_name):
133 if test_name == 'setup':
134 return
135+ elif test_name == 'setup-check':
136+ cmd = '%s/ubuntu_stress_smoke_test_checks.sh' % (self.bindir)
137+ utils.system_output(cmd, retain_output=True)
138+ return
139+ elif test_name == 'setup-init':
140+ cmd = '%s/ubuntu_stress_smoke_test_init.sh' % (self.bindir)
141+ utils.system_output(cmd, retain_output=True)
142+ return
143+
144
145 if os.uname()[1] == '202008-28164-ZCU106':
146 raise error.TestFail('Test marked as failed for ZCU106 as requested by portias, dev test hang (LP: #1998738)')
147diff --git a/ubuntu_stress_smoke_test/ubuntu_stress_smoke_test_checks.sh b/ubuntu_stress_smoke_test/ubuntu_stress_smoke_test_checks.sh
148new file mode 100755
149index 0000000..807ebfa
150--- /dev/null
151+++ b/ubuntu_stress_smoke_test/ubuntu_stress_smoke_test_checks.sh
152@@ -0,0 +1,89 @@
153+#!/bin/bash
154+
155+# Maximum machine age in years
156+MAX_AGE=5
157+# minimum required memory in MB
158+MIN_MEM=$((3 * 1024))
159+# minimum free disk required in GB
160+MIN_DISK=$((4))
161+
162+check_message()
163+{
164+ echo "NOTE: $1, skipping test"
165+}
166+
167+check_machine()
168+{
169+ hostname=$(hostname)
170+ processor=$(uname -p)
171+ skip=0
172+ case "$processor" in
173+ i386 | i486 | i586 | i686 | x86_64)
174+ datecheck=1
175+
176+ manufacturer=$(dmidecode -s system-manufacturer)
177+ if [ "$manufacturer" == "QEMU" ]; then
178+ echo "QEMU instance, no firmware date checking"
179+ datecheck=0
180+ fi
181+
182+ vendor=$(dmidecode -t 0x0000 | grep Vendor: | awk '{ print $2}')
183+ if [ -z "$vendor" ]; then
184+ vendor=$(dmidecode -t 0x000e | grep Vendor: | awk '{ print $2}')
185+ fi
186+
187+ case "$vendor" in
188+ unknown | Unknown)
189+ check_message "Unknown BIOS vendor, ignoring machine"
190+ skip=1
191+ datecheck=0
192+ ;;
193+ SeaBIOS)
194+ echo "SeaBIOS BIOS, using a VM, no date checking"
195+ datecheck=0
196+ ;;
197+ *)
198+ ;;
199+ esac
200+
201+ if [ $datecheck -eq 1 ]; then
202+ year=$(date +%Y)
203+ year=$((year - $MAX_AGE))
204+ date=$(dmidecode -t 0x0000 | grep "Release Date:" | cut -d'/' -f3)
205+ if [ -z "$date" ]; then
206+ date=$(dmidecode -t 0x000e | grep "Release Date:" | cut -d'/' -f3)
207+ fi
208+ if [ ! -z "$date" ]; then
209+ if [ $date -lt $year ]; then
210+ check_message "BIOS indicates machine is more then $MAX_AGE years old"
211+ skip=1
212+ fi
213+ fi
214+ fi
215+ ;;
216+ *)
217+ echo "other"
218+ ;;
219+ esac
220+
221+ mem=$(free | grep Mem: | awk '{print $2}')
222+ mem=$((mem / 1024))
223+ if [ $mem -lt $MIN_MEM ]; then
224+ check_message "Machine has only $mem MB memory, requires at least $MIN_MEM MB"
225+ skip=1
226+ fi
227+ disk=$(df . -B 1024 | awk '{print $4}' | tail -1)
228+ disk=$((disk / 1048576))
229+ if [ $disk -lt $MIN_DISK ]; then
230+ check_message "Machine has only $disk GB free disk space, requires at least $MIN_DISK GB"
231+ skip=1
232+ fi
233+
234+ if [ $skip -ne 0 ]; then
235+ exit 1
236+ fi
237+
238+ echo "$hostname: $processor $mem MB memory, $disk GB disk"
239+}
240+
241+check_machine

Subscribers

People subscribed via source and target branches

to all changes: