Merge lp:~mwhudson/lava-dispatcher/kill-SerialIO-sio-madness into lp:lava-dispatcher

Proposed by Michael Hudson-Doyle
Status: Merged
Merged at revision: 534
Proposed branch: lp:~mwhudson/lava-dispatcher/kill-SerialIO-sio-madness
Merge into: lp:lava-dispatcher
Diff against target: 324 lines (+26/-78)
10 files modified
lava_dispatcher/client/base.py (+1/-23)
lava_dispatcher/context.py (+5/-1)
lava_dispatcher/default-config/lava-dispatcher/README (+0/-7)
lava_dispatcher/device/fastmodel.py (+3/-2)
lava_dispatcher/device/master.py (+6/-13)
lava_dispatcher/device/qemu.py (+4/-1)
lava_dispatcher/device/sdmux.py (+2/-2)
lava_dispatcher/device/target.py (+0/-25)
lava_dispatcher/job.py (+3/-2)
lava_dispatcher/utils.py (+2/-2)
To merge this branch: bzr merge lp:~mwhudson/lava-dispatcher/kill-SerialIO-sio-madness
Reviewer Review Type Date Requested Status
Antonio Terceiro Approve
Review via email: mp+143619@code.launchpad.net

Description of the change

The dispatcher has had the feature for a while of attempting to attach the serial output from the device as an attachment to the lava test run. I say "attempting" because during the device refactoring some code got duplicated and the serial output got collected into a different place than where the attachment was made from, so these attachments to the lava test run have been 0 bytes for months. And noone apparently noticed apart from me, so let's kill this feature and make space to reimplement something in this area more sensibly...

To post a comment you must log in.
Revision history for this message
Antonio Terceiro (terceiro) wrote :

  review approve

I really like deleting code :-)

--
Antonio Terceiro
Software Engineer - Linaro
http://www.linaro.org

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lava_dispatcher/client/base.py'
2--- lava_dispatcher/client/base.py 2013-01-14 16:29:38 +0000
3+++ lava_dispatcher/client/base.py 2013-01-16 23:47:22 +0000
4@@ -29,14 +29,11 @@
5
6 import lava_dispatcher.utils as utils
7
8-from cStringIO import StringIO
9-
10 from lava_dispatcher.errors import (
11 GeneralError,
12 NetworkError,
13 OperationFailed,
14 )
15-from lava_dispatcher.test_data import create_attachment
16
17
18 def wait_for_prompt(connection, prompt_pattern, timeout):
19@@ -334,7 +331,6 @@
20 self.context = context
21 self.config = config
22 self.hostname = config.hostname
23- self.sio = SerialIO(sys.stdout)
24 self.proc = None
25 # used for apt-get in lava-test.py
26 self.aptget_cmd = "apt-get"
27@@ -425,7 +421,7 @@
28
29 def get_test_data_attachments(self):
30 '''returns attachments to go in the "lava_results" test run'''
31- return [ create_attachment('serial.log', self.sio.getvalue()) ]
32+ return []
33
34 def retrieve_results(self, result_disk):
35 raise NotImplementedError(self.retrieve_results)
36@@ -498,21 +494,3 @@
37 session.run('echo 0>/sys/class/android_usb/android0/enable')
38
39
40-class SerialIO(file):
41- def __init__(self, logfile):
42- self.serialio = StringIO()
43- self.logfile = logfile
44-
45- def write(self, text):
46- self.serialio.write(text)
47- self.logfile.write(text)
48-
49- def close(self):
50- self.serialio.close()
51- self.logfile.close()
52-
53- def flush(self):
54- self.logfile.flush()
55-
56- def getvalue(self):
57- return self.serialio.getvalue()
58
59=== modified file 'lava_dispatcher/context.py'
60--- lava_dispatcher/context.py 2012-12-18 19:50:48 +0000
61+++ lava_dispatcher/context.py 2013-01-16 23:47:22 +0000
62@@ -20,7 +20,7 @@
63
64 import atexit
65 import os
66-import shutil
67+import sys
68 import tempfile
69
70 from lava_dispatcher.config import get_device_config
71@@ -33,6 +33,10 @@
72 def __init__(self, target, dispatcher_config, oob_file, job_data):
73 self.config = dispatcher_config
74 self.job_data = job_data
75+ # This is the file-like object to send serial output from the device
76+ # to. We just send it to stdout for now, but soon we'll do something
77+ # cleverer.
78+ self.logfile_read = sys.stdout
79 device_config = get_device_config(
80 target, dispatcher_config.config_dir)
81 self._client = TargetBasedClient(self, device_config)
82
83=== modified file 'lava_dispatcher/default-config/lava-dispatcher/README'
84--- lava_dispatcher/default-config/lava-dispatcher/README 2012-10-11 02:51:21 +0000
85+++ lava_dispatcher/default-config/lava-dispatcher/README 2013-01-16 23:47:22 +0000
86@@ -34,9 +34,6 @@
87 are already supported by lava-dispatcher, but if you are working on
88 supporting a new class of device, you will need to add a file here.
89
90- Note that the device-type name must match the --dev argument to
91- linaro-media-create.
92-
93 * devices/
94
95 This directory contains a file per device that can be targeted by
96@@ -44,7 +41,3 @@
97 a line "device_type = <device type>", although other settings can
98 be included here. You will definitely need to tell lava-dispatcher
99 about the devices you have!
100-
101-* logging.conf
102-
103- This file defines settings for Python logging
104
105=== modified file 'lava_dispatcher/device/fastmodel.py'
106--- lava_dispatcher/device/fastmodel.py 2012-11-22 02:14:51 +0000
107+++ lava_dispatcher/device/fastmodel.py 2013-01-16 23:47:22 +0000
108@@ -200,7 +200,7 @@
109 logging.info('launching fastmodel with command %r' % sim_cmd)
110 self._sim_proc = logging_spawn(
111 sim_cmd,
112- logfile=self.sio,
113+ logfile=self.client.context.logfile_read,
114 timeout=1200)
115 self._sim_proc.expect(self.PORT_PATTERN, timeout=300)
116 self._serial_port = self._sim_proc.match.groups()[0]
117@@ -216,7 +216,8 @@
118 logging.info('simulator is started connecting to serial port')
119 self.proc = logging_spawn(
120 'telnet localhost %s' % self._serial_port,
121- logfile=self._create_rtsm_ostream(self.sio),
122+ logfile=self._create_rtsm_ostream(
123+ self.client.context.logfile_read),
124 timeout=1200)
125 return self.proc
126
127
128=== modified file 'lava_dispatcher/device/master.py'
129--- lava_dispatcher/device/master.py 2012-12-29 03:50:52 +0000
130+++ lava_dispatcher/device/master.py 2013-01-16 23:47:22 +0000
131@@ -23,12 +23,11 @@
132 import logging
133 import os
134 import time
135-import traceback
136
137 import pexpect
138
139-import lava_dispatcher.device.boot_options as boot_options
140-import lava_dispatcher.tarballcache as tarballcache
141+from lava_dispatcher.device import boot_options
142+from lava_dispatcher import tarballcache
143
144 from lava_dispatcher.client.base import (
145 NetworkCommandRunner,
146@@ -85,7 +84,7 @@
147 if config.pre_connect_command:
148 logging_system(config.pre_connect_command)
149
150- self.proc = connect_to_serial(config, self.sio)
151+ self.proc = connect_to_serial(config, self.context.logfile_read)
152
153 def get_device_version(self):
154 return self.device_version
155@@ -164,9 +163,7 @@
156 _deploy_linaro_rootfs(master, root_url)
157 _deploy_linaro_bootfs(master, boot_url)
158 except:
159- logging.error("Deployment failed")
160- tb = traceback.format_exc()
161- self.sio.write(tb)
162+ logging.exception("Deployment failed")
163 raise CriticalError("Deployment failed")
164
165 def _format_testpartition(self, runner, fstype):
166@@ -185,9 +182,7 @@
167 _extract_partition(image_file, self.config.boot_part, boot_tgz)
168 _extract_partition(image_file, self.config.root_part, root_tgz)
169 except:
170- logging.error("Failed to generate tarballs")
171- tb = traceback.format_exc()
172- self.sio.write(tb)
173+ logging.exception("Failed to generate tarballs")
174 raise
175
176 # we need to associate the deployment data with these so that we
177@@ -452,9 +447,7 @@
178 try:
179 self.wait_network_up(timeout=20)
180 except NetworkError:
181- msg = "Unable to reach LAVA server"
182- logging.error(msg)
183- self._client.sio.write(traceback.format_exc())
184+ logging.exception("Unable to reach LAVA server")
185 raise
186
187 pattern1 = "<(\d?\d?\d?\.\d?\d?\d?\.\d?\d?\d?\.\d?\d?\d?)>"
188
189=== modified file 'lava_dispatcher/device/qemu.py'
190--- lava_dispatcher/device/qemu.py 2012-11-20 13:34:19 +0000
191+++ lava_dispatcher/device/qemu.py 2013-01-16 23:47:22 +0000
192@@ -79,7 +79,10 @@
193 self.config.qemu_drive_interface,
194 self._sd_image)
195 logging.info('launching qemu with command %r' % qemu_cmd)
196- proc = logging_spawn(qemu_cmd, logfile=self.sio, timeout=1200)
197+ proc = logging_spawn(
198+ qemu_cmd,
199+ logfile=self.context.logfile_read,
200+ timeout=1200)
201 return proc
202
203 def get_device_version(self):
204
205=== modified file 'lava_dispatcher/device/sdmux.py'
206--- lava_dispatcher/device/sdmux.py 2013-01-04 19:26:51 +0000
207+++ lava_dispatcher/device/sdmux.py 2013-01-16 23:47:22 +0000
208@@ -22,7 +22,6 @@
209 import logging
210 import os
211 import subprocess
212-import sys
213 import time
214
215 from lava_dispatcher.errors import (
216@@ -208,7 +207,8 @@
217 logging_system(self.config.power_off_cmd)
218
219 def power_on(self):
220- self.proc = connect_to_serial(self.config, self.sio)
221+ self.proc = connect_to_serial(
222+ self.config, self.context.logfile_read)
223
224 logging.info('powering on')
225 logging_system(self.config.power_on_cmd)
226
227=== modified file 'lava_dispatcher/device/target.py'
228--- lava_dispatcher/device/target.py 2012-11-15 21:23:20 +0000
229+++ lava_dispatcher/device/target.py 2013-01-16 23:47:22 +0000
230@@ -19,17 +19,13 @@
231 # with this program; if not, see <http://www.gnu.org/licenses>.
232
233 import contextlib
234-import logging
235 import os
236-import sys
237
238 from lava_dispatcher.client.lmc_utils import (
239 image_partition_mounted,
240 )
241 import lava_dispatcher.utils as utils
242
243-from cStringIO import StringIO
244-
245
246 def get_target(context, device_config):
247 ipath = 'lava_dispatcher.device.%s' % device_config.client_type
248@@ -67,7 +63,6 @@
249 self.context = context
250 self.config = device_config
251 self.deployment_data = None
252- self.sio = SerialIO(sys.stdout)
253
254 self.boot_options = []
255 self._scratch_dir = None
256@@ -175,23 +170,3 @@
257 # because we are doing pretty standard linux stuff, just
258 # just no upstart or dash assumptions
259 self._customize_oe(mnt)
260-
261-
262-class SerialIO(file):
263- def __init__(self, logfile):
264- self.serialio = StringIO()
265- self.logfile = logfile
266-
267- def write(self, text):
268- self.serialio.write(text)
269- self.logfile.write(text)
270-
271- def close(self):
272- self.serialio.close()
273- self.logfile.close()
274-
275- def flush(self):
276- self.logfile.flush()
277-
278- def getvalue(self):
279- return self.serialio.getvalue()
280
281=== modified file 'lava_dispatcher/job.py'
282--- lava_dispatcher/job.py 2012-12-07 19:59:19 +0000
283+++ lava_dispatcher/job.py 2013-01-16 23:47:22 +0000
284@@ -206,6 +206,8 @@
285 finally:
286 err_msg = ""
287 if status == 'fail':
288+ # XXX mwhudson, 2013-01-17: I have no idea what this
289+ # code is doing.
290 logging.warning(
291 "[ACTION-E] %s is finished with error (%s)." % (
292 cmd['command'], err))
293@@ -217,8 +219,7 @@
294 err_msg += "Lava failed on test: %s" % \
295 params.get('test_name', "Unknown")
296 err_msg = err_msg + traceback.format_exc()
297- # output to both serial log and logfile
298- self.context.client.sio.write(err_msg)
299+ print err_msg
300 else:
301 logging.info(
302 "[ACTION-E] %s is finished successfully." % (
303
304=== modified file 'lava_dispatcher/utils.py'
305--- lava_dispatcher/utils.py 2013-01-04 00:03:43 +0000
306+++ lava_dispatcher/utils.py 2013-01-16 23:47:22 +0000
307@@ -214,7 +214,7 @@
308 timeout=1, lava_no_logging=1)
309
310
311-def connect_to_serial(device_config, sio):
312+def connect_to_serial(device_config, logfile_read):
313 """
314 Attempts to connect to a serial console server like conmux or cyclades
315 """
316@@ -238,7 +238,7 @@
317
318 while retry_count < retry_limit:
319 proc = logging_spawn(device_config.connection_command, timeout=1200)
320- proc.logfile_read = sio
321+ proc.logfile_read = logfile_read
322 logging.info('Attempting to connect to device')
323 match = proc.expect(patterns, timeout=10)
324 result = results[match]

Subscribers

People subscribed via source and target branches