Merge lp:~terceiro/lava-dispatcher/nexus into lp:lava-dispatcher

Proposed by Antonio Terceiro
Status: Superseded
Proposed branch: lp:~terceiro/lava-dispatcher/nexus
Merge into: lp:lava-dispatcher
Diff against target: 231 lines (+211/-0)
3 files modified
lava_dispatcher/config.py (+3/-0)
lava_dispatcher/default-config/lava-dispatcher/device-types/nexus.conf (+40/-0)
lava_dispatcher/device/nexus.py (+168/-0)
To merge this branch: bzr merge lp:~terceiro/lava-dispatcher/nexus
Reviewer Review Type Date Requested Status
Linaro Validation Team Pending
Review via email: mp+136807@code.launchpad.net

Description of the change

This is work in progress; you will note the number of FIXME's and TODO's in lava_dispatcher/device/nexus.py. ;-)

With the current state, I can already run a full boot test job, like the one in the commit message of rev 475:

http://bazaar.launchpad.net/~terceiro/lava-dispatcher/nexus/revision/475

It would be nice to receive comments about the changes that were needed to other files outside of the Nexus implementation itself.

To post a comment you must log in.
Revision history for this message
Michael Hudson-Doyle (mwhudson) wrote :
Download full text (5.2 KiB)

Antonio Terceiro <email address hidden> writes:

> Antonio Terceiro has proposed merging lp:~terceiro/lava-dispatcher/nexus into lp:lava-dispatcher.
>
> Requested reviews:
> Linaro Validation Team (linaro-validation)
>
> For more details, see:
> https://code.launchpad.net/~terceiro/lava-dispatcher/nexus/+merge/136807
>
> This is work in progress; you will note the number of FIXME's and TODO's in lava_dispatcher/device/nexus.py. ;-)

This looks pretty good on the whole!

> With the current state, I can already run a full boot test job, like the one in the commit message of rev 475:
>
> http://bazaar.launchpad.net/~terceiro/lava-dispatcher/nexus/revision/475
>
> It would be nice to receive comments about the changes that were needed to other files outside of the Nexus implementation itself.

I think they mostly seem reasonable. I'd be happy to see them merged
without the nexus bits if that would make your life easier.

> === added file 'lava_dispatcher/device/nexus.py'
> --- lava_dispatcher/device/nexus.py 1970-01-01 00:00:00 +0000
> +++ lava_dispatcher/device/nexus.py 2012-11-28 22:45:26 +0000
> @@ -0,0 +1,106 @@
> +# Copyright (C) 2012 Linaro Limited
> +#
> +# Author: Antonio Terceiro <email address hidden>
> +#
> +# This file is part of LAVA Dispatcher.
> +#
> +# LAVA Dispatcher is free software; you can redistribute it and/or modify
> +# it under the terms of the GNU General Public License as published by
> +# the Free Software Foundation; either version 2 of the License, or
> +# (at your option) any later version.
> +#
> +# LAVA Dispatcher is distributed in the hope that it will be useful,
> +# but WITHOUT ANY WARRANTY; without even the implied warranty of
> +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> +# GNU General Public License for more details.
> +#
> +# You should have received a copy of the GNU General Public License
> +# along
> +# with this program; if not, see <http://www.gnu.org/licenses>.
> +
> +import subprocess
> +import pexpect
> +from time import sleep
> +from lava_dispatcher.device.target import (
> + Target
> +)
> +from lava_dispatcher.downloader import (
> + download_image
> +)
> +from lava_dispatcher.utils import (
> + logging_spawn
> +)
> +
> +class NexusTarget(Target):
> +
> + def __init__(self, context, config):
> + super(NexusTarget, self).__init__(context, config)
> +
> + def deploy_android(self, boot, system, userdata):
> + sdir = self.scratch_dir
> +
> + # TODO it seems boot, system and userdata are usually .tar.gz files,
> + # and I am currently assuming they are .img and flashing them directly

Would be good to talk to the android team about what to do here I guess.

> + boot = download_image(boot, self.context, sdir, decompress=False)
> + # FIXME uncomment these two - skipping them makes testing faster
> + #system = download_image(system, self.context, sdir, decompress=False)
> + #userdata = download_image(userdata, self.context, sdir, decompress=False)
> +
> + self.reboot()
> + sleep(10)
> +
> + self.fastboot(['erase', 'boot'])
> + # FIXME uncomment these two - skipp...

Read more...

Revision history for this message
Antonio Terceiro (terceiro) wrote :
Download full text (4.0 KiB)

On Sun, Dec 02, 2012 at 10:16:20PM -0000, Michael Hudson-Doyle wrote:
> Antonio Terceiro <email address hidden> writes:
>
> > Antonio Terceiro has proposed merging lp:~terceiro/lava-dispatcher/nexus into lp:lava-dispatcher.
> >
> > Requested reviews:
> > Linaro Validation Team (linaro-validation)
> >
> > For more details, see:
> > https://code.launchpad.net/~terceiro/lava-dispatcher/nexus/+merge/136807
> >
> > This is work in progress; you will note the number of FIXME's and TODO's in lava_dispatcher/device/nexus.py. ;-)
>
> This looks pretty good on the whole!

Thanks! :)

> > With the current state, I can already run a full boot test job, like the one in the commit message of rev 475:
> >
> > http://bazaar.launchpad.net/~terceiro/lava-dispatcher/nexus/revision/475
> >
> > It would be nice to receive comments about the changes that were needed to other files outside of the Nexus implementation itself.
>
> I think they mostly seem reasonable. I'd be happy to see them merged
> without the nexus bits if that would make your life easier.

I will merge them, in that case. A cleaner diff will make my life a
little easier, for sure.

> > === added file 'lava_dispatcher/device/nexus.py'
> > --- lava_dispatcher/device/nexus.py 1970-01-01 00:00:00 +0000
> > +++ lava_dispatcher/device/nexus.py 2012-11-28 22:45:26 +0000
> > @@ -0,0 +1,106 @@
> > +# Copyright (C) 2012 Linaro Limited
> > +#
> > +# Author: Antonio Terceiro <email address hidden>
> > +#
> > +# This file is part of LAVA Dispatcher.
> > +#
> > +# LAVA Dispatcher is free software; you can redistribute it and/or modify
> > +# it under the terms of the GNU General Public License as published by
> > +# the Free Software Foundation; either version 2 of the License, or
> > +# (at your option) any later version.
> > +#
> > +# LAVA Dispatcher is distributed in the hope that it will be useful,
> > +# but WITHOUT ANY WARRANTY; without even the implied warranty of
> > +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> > +# GNU General Public License for more details.
> > +#
> > +# You should have received a copy of the GNU General Public License
> > +# along
> > +# with this program; if not, see <http://www.gnu.org/licenses>.
> > +
> > +import subprocess
> > +import pexpect
> > +from time import sleep
> > +from lava_dispatcher.device.target import (
> > + Target
> > +)
> > +from lava_dispatcher.downloader import (
> > + download_image
> > +)
> > +from lava_dispatcher.utils import (
> > + logging_spawn
> > +)
> > +
> > +class NexusTarget(Target):
> > +
> > + def __init__(self, context, config):
> > + super(NexusTarget, self).__init__(context, config)
> > +
> > + def deploy_android(self, boot, system, userdata):
> > + sdir = self.scratch_dir
> > +
> > + # TODO it seems boot, system and userdata are usually .tar.gz files,
> > + # and I am currently assuming they are .img and flashing them directly
>
> Would be good to talk to the android team about what to do here I guess.

OK, will do it.

> > + boot = download_image(boot, self.context, sdir, decompress=False)
> > + # FIXME uncomment these two - skipping t...

Read more...

lp:~terceiro/lava-dispatcher/nexus updated
479. By Antonio Terceiro

merge from trunk

480. By Antonio Terceiro

merge recent trunk updates

481. By Antonio Terceiro

recent trunk changes

482. By Antonio Terceiro

no need to erase partitions just before they are reflashed

483. By Antonio Terceiro

only accepts .img files. that's all the android team need.

484. By Antonio Terceiro

trunk updates

485. By Antonio Terceiro

trunk updates

486. By Antonio Terceiro

Implement get_device_version

487. By Antonio Terceiro

implement file_system() API

With this I got lava-test-shell pretty much working. I still need to do more
tests, though.

488. By Antonio Terceiro

oops - previously commented code had a syntax error

489. By Antonio Terceiro

oops, another embarassing bug

490. By Antonio Terceiro

missing import statement

491. By Antonio Terceiro

fix example config

492. By Antonio Terceiro

sanitize terminfo hack

493. By Antonio Terceiro

Fixes trying to make lava-test-shell work on the Nexus

exec > /dev/console in special does not really help because we only have `adb
shell` and not access to an actual console.

494. By Antonio Terceiro

Need to mark make_filesystem_readwrite as a context manager

495. By Antonio Terceiro

AOSP does not have `tee` :-/

496. By Antonio Terceiro

turn the device on if it's not already.

This makes it possible to use lava_test_shell the way it is supposed to (i.e. not requiring to explicitly run boot_linaro*_image before).

497. By Antonio Terceiro

Chenges to make lava-test-runner run on the nexus

498. By Antonio Terceiro

oops, forgot to actually echo the line to stdout

499. By Antonio Terceiro

trunk updates

500. By Antonio Terceiro

Also remove `sleep 15` from lava-test-runner-ubuntu

501. By Antonio Terceiro

mark pending work

502. By Antonio Terceiro

use shell builtin type instead of which

which is not present in AOSP

503. By Antonio Terceiro

Install custom-made mkfifo binary

504. By Antonio Terceiro

Fix lava_test_shell bin directory location

505. By Antonio Terceiro

Log commands run on host when in debug mode

506. By Antonio Terceiro

Do not send output to /dev/console

507. By Antonio Terceiro

file_system already implemented

508. By Antonio Terceiro

Remove `-t N` from read calls.

BTW I've just found out that `read -t N < FIFO` does not work at all.

509. By Antonio Terceiro

Do not expect that `read -t` will ever work

510. By Antonio Terceiro

trunk updates

511. By Antonio Terceiro

trunk updates

512. By Antonio Terceiro

Run lava-test-runner in the background; drop mkfifo binary

513. By Antonio Terceiro

sync with trunk

514. By Antonio Terceiro

remove /etc/ cleanup hack and do not ignore unexisting directory when pulling (create it before pulling instead)

515. By Antonio Terceiro

more lava-test-runner stdin usage fixes

516. By Antonio Terceiro

grrr - fix reference to undefined variable

517. By Antonio Terceiro

fix argument handling in lava-test-*-attach

518. By Antonio Terceiro

revert earlier change that broke things.

519. By Antonio Terceiro

finish fixes for running lava-test-runner in the foreground

520. By Antonio Terceiro

Extract method

521. By Antonio Terceiro

Allow overriding the image directory.

This is useful when running the dispatcher inside the VM, but can also support
the use case where the dispatcher is on a machine and the phone is physically
plugged to another.

522. By Antonio Terceiro

sync from trunk

523. By Antonio Terceiro

using `lava dispatch --target DEVICE` here

524. By Antonio Terceiro

Get version number from configured adb_command

525. By Antonio Terceiro

Use the working dir (renamed from image dir) also for pulling data out of the device

526. By Antonio Terceiro

oops - missed changes to default config

527. By Antonio Terceiro

merge changes required to make lava-android-test work

528. By Antonio Terceiro

sync from trunk

529. By Antonio Terceiro

merge latest lava-android-test changes

530. By Antonio Terceiro

sync from trunk

531. By Antonio Terceiro

I don't believe that extract_tarball and get_test_data_attachment will be useful

532. By Antonio Terceiro

sync from trunk

533. By Antonio Terceiro

Replay fix done in the lava-test-shell-nexus-aosp branch

534. By Antonio Terceiro

sync from better command line handling branch

535. By Antonio Terceiro

merge wait-for-prompt branch for testing

536. By Antonio Terceiro

sync from trunk

537. By Antonio Terceiro

power_off is not viable

538. By Antonio Terceiro

Extract Methods

539. By Antonio Terceiro

Missed reference to reboot method

540. By Antonio Terceiro

No crazy stuff, I guess

All of the required fixes were merged into trunk before

541. By Antonio Terceiro

Separate all required API methods from private implementation methods

private methods marked with _ and moved to below the public API

542. By Antonio Terceiro

Require deploy before power_on()

543. By Antonio Terceiro

sync from trunk

544. By Antonio Terceiro

remove spaces around = in keyword argument

545. By Antonio Terceiro

minor changes to doc

546. By Antonio Terceiro

Clarify intent of some methods

547. By Antonio Terceiro

address more review comments

- removed sudo from config file. I assume the user running the dispatcher has
  the proper permissions
- removed _make_filesystem_readwrite - not needed anymore
- implemented fastboot detection
- added timeout to all calls. Default: 10 minutes

548. By Antonio Terceiro

Name revealling intention: s/_powered_on/_booted/

549. By Antonio Terceiro

Add some debug logging

550. By Antonio Terceiro

Better explanation for nexus_working_directory

Unmerged revisions

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lava_dispatcher/config.py'
2--- lava_dispatcher/config.py 2013-01-10 21:37:58 +0000
3+++ lava_dispatcher/config.py 2013-01-15 18:36:22 +0000
4@@ -91,6 +91,9 @@
5 arm_probe_config = schema.StringOption(default='/usr/local/etc/arm-probe-config')
6 arm_probe_channels = schema.ListOption(default=['VDD_VCORE1'])
7
8+ adb_command = schema.StringOption()
9+ fastboot_command = schema.StringOption()
10+ nexus_working_directory = schema.StringOption(default = None)
11
12 class OptionDescriptor(object):
13 def __init__(self, name):
14
15=== added file 'lava_dispatcher/default-config/lava-dispatcher/device-types/nexus.conf'
16--- lava_dispatcher/default-config/lava-dispatcher/device-types/nexus.conf 1970-01-01 00:00:00 +0000
17+++ lava_dispatcher/default-config/lava-dispatcher/device-types/nexus.conf 2013-01-15 18:36:22 +0000
18@@ -0,0 +1,40 @@
19+client_type = nexus
20+
21+# The ADB command line.
22+#
23+# In the case where there are more than one android devices plugged into a
24+# single host, this connection command must be overriden on each device to
25+# include the serial number of the device, e.g.
26+#
27+# serial_number = XXXXXXXXXXXXXXXX
28+# adb_command = adb -s %(serial_number)s
29+adb_command = adb
30+
31+# The fastboot command.
32+#
33+# The same as above: if you have more than one device, you will want to
34+# override this in your device config to add a serial number, e.g.
35+#
36+# serial_number = XXXXXXXXXXXXXXXX
37+# fastboot_command = sudo fastboot -s %(serial_number)s
38+#
39+# Of course, in the case you override both adb_command *and* fastboot_command,
40+# you don't need to specify `serial_number` twice.
41+fastboot_command = sudo fastboot
42+
43+# Working directory for temporary. By default, the usual place for LAVA images
44+# will be used.
45+#
46+# This is useful when the lava dispatcher is controlling Nexus phones that are
47+# physically plugged to other machines. In this case, you should set
48+# nexus_work_directory to a shared directory between the machine running the
49+# dispatcher and the machine where the phone is plugged.
50+#
51+# OBS: this shared directory must have the same path in both machines.
52+nexus_working_directory =
53+
54+connection_command = %(adb_command)s shell
55+
56+enable_network_after_boot_android = false
57+android_adb_over_usb = true
58+android_adb_over_tcp = false
59
60=== added file 'lava_dispatcher/device/nexus.py'
61--- lava_dispatcher/device/nexus.py 1970-01-01 00:00:00 +0000
62+++ lava_dispatcher/device/nexus.py 2013-01-15 18:36:22 +0000
63@@ -0,0 +1,168 @@
64+# Copyright (C) 2012 Linaro Limited
65+#
66+# Author: Antonio Terceiro <antonio.terceiro@linaro.org>
67+#
68+# This file is part of LAVA Dispatcher.
69+#
70+# LAVA Dispatcher is free software; you can redistribute it and/or modify
71+# it under the terms of the GNU General Public License as published by
72+# the Free Software Foundation; either version 2 of the License, or
73+# (at your option) any later version.
74+#
75+# LAVA Dispatcher is distributed in the hope that it will be useful,
76+# but WITHOUT ANY WARRANTY; without even the implied warranty of
77+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
78+# GNU General Public License for more details.
79+#
80+# You should have received a copy of the GNU General Public License
81+# along
82+# with this program; if not, see <http://www.gnu.org/licenses>.
83+
84+import subprocess
85+import pexpect
86+from time import sleep
87+import logging
88+import contextlib
89+
90+from lava_dispatcher.device.target import (
91+ Target
92+)
93+from lava_dispatcher.downloader import (
94+ download_image
95+)
96+from lava_dispatcher.utils import (
97+ logging_spawn,
98+ mkdtemp
99+)
100+
101+class NexusTarget(Target):
102+
103+ def __init__(self, context, config):
104+ super(NexusTarget, self).__init__(context, config)
105+ self._powered_on = False
106+ self._working_dir = None
107+
108+ def deploy_android(self, boot, system, userdata):
109+
110+ boot = self._get_image(boot)
111+ system = self._get_image(system)
112+ userdata = self._get_image(userdata)
113+
114+ self.reboot_os()
115+
116+ self.fastboot('erase boot')
117+
118+ self.fastboot('flash system %s' % system)
119+ self.fastboot('flash userdata %s' % userdata)
120+
121+ self.deployment_data = Target.android_deployment_data
122+ self.deployment_data['boot_image'] = boot
123+
124+ def power_on(self):
125+ self.reboot_os()
126+ self.reboot_bootloader()
127+ self.boot_test_image()
128+
129+ self._powered_on = True
130+ proc = self.adb('shell', spawn = True)
131+ proc.sendline("") # required to put the adb shell in a reasonable state
132+ proc.sendline("export PS1='%s'" % self.deployment_data['TESTER_PS1'])
133+ self._runner = self._get_runner(proc)
134+
135+ return proc
136+
137+ def reboot_os(self):
138+ # tell android to reboot. A failure probably means that the device is not
139+ # booted on android, and we ignore that.
140+ self.adb('reboot', ignore_failure = True)
141+ sleep(10)
142+
143+ def reboot_bootloader(self):
144+ self.fastboot('reboot')
145+ sleep(10)
146+
147+ def boot_test_image(self):
148+ self.fastboot('boot %s' % self.deployment_data['boot_image'])
149+ self.adb('wait-for-device')
150+
151+ def power_off(self, proc):
152+ # there is no way to power off the Nexus while USB is plugged on; even
153+ # if you remove power, it will stay on.
154+ pass
155+
156+ @contextlib.contextmanager
157+ def file_system(self, partition, directory):
158+
159+ if not self._powered_on:
160+ self.power_on()
161+
162+ mount_point = self.get_partition_mount_point(partition)
163+
164+ with self.make_filesystem_readwrite(mount_point):
165+ host_dir = '%s/mnt/%s' % (self.working_dir, directory)
166+ target_dir = '%s/%s' % (mount_point, directory)
167+
168+ subprocess.check_call(['mkdir', '-p', host_dir])
169+ self.adb('pull %s %s' % (target_dir, host_dir), ignore_failure = True)
170+
171+ yield host_dir
172+
173+ self.adb('push %s %s' % (host_dir, target_dir))
174+
175+ def get_partition_mount_point(self, partition):
176+ lookup = {
177+ self.config.data_part_android_org: '/data',
178+ self.config.sys_part_android_org: '/system',
179+ }
180+ return lookup[partition]
181+
182+ @contextlib.contextmanager
183+ def make_filesystem_readwrite(self, mount_point):
184+ if mount_point == '/system':
185+ self._runner.run("mount -o remount,rw %s" % mount_point)
186+ yield
187+ if mount_point == '/system':
188+ self._runner.run("mount -o remount,ro %s" % mount_point)
189+
190+ def get_device_version(self):
191+ # this is tricky, because fastboot does not have a visible version
192+ # number. For now let's use just the adb version number.
193+ return subprocess.check_output(
194+ "%s version | sed 's/.* version //'" % self.config.adb_command,
195+ shell = True
196+ ).strip()
197+
198+ def adb(self, args, ignore_failure = False, spawn = False):
199+ cmd = self.config.adb_command + ' ' + args
200+ if spawn:
201+ return logging_spawn(cmd, timeout = 60)
202+ else:
203+ self._call(cmd, ignore_failure)
204+
205+ def fastboot(self, args, ignore_failure = False):
206+ self._call(self.config.fastboot_command + ' ' + args, ignore_failure)
207+
208+ def _call(self, cmd, ignore_failure):
209+ logging.debug("Running on the host: %s" % cmd)
210+ if ignore_failure:
211+ subprocess.call(cmd, shell = True)
212+ else:
213+ subprocess.check_call(cmd, shell = True)
214+
215+ def _get_image(self, url):
216+ sdir = self.working_dir
217+ image = download_image(url, self.context, sdir, decompress=False)
218+ return image
219+
220+ @property
221+ def working_dir(self):
222+ if (self.config.nexus_working_directory is None or
223+ self.config.nexus_working_directory.strip() == ''):
224+ return self.scratch_dir
225+
226+ if self._working_dir is None:
227+ self._working_dir = mkdtemp(self.config.nexus_working_directory)
228+ return self._working_dir
229+
230+
231+target_class = NexusTarget

Subscribers

People subscribed via source and target branches