Merge lp:~mterry/phablet-tools/unlock into lp:phablet-tools

Proposed by Michael Terry
Status: Needs review
Proposed branch: lp:~mterry/phablet-tools/unlock
Merge into: lp:phablet-tools
Diff against target: 132 lines (+59/-3)
1 file modified
phablet-test-run (+59/-3)
To merge this branch: bzr merge lp:~mterry/phablet-tools/unlock
Reviewer Review Type Date Requested Status
PS Jenkins bot continuous-integration Approve
Ubuntu Phablet Team Pending
Review via email: mp+217620@code.launchpad.net

Commit message

Unlock as part of a test run ourselves (instead of relying on user or ubuntu-test-case scripts to do it)

Description of the change

Unlock as part of a test run ourselves (instead of relying on user or ubuntu-test-case scripts to do it).

This also means we grab the powerd lock ourselves (since we trigger a reboot).

I added a new option -l to turn off this reboot&unlock. I chose l because it felt like "lock" (vs unlock) but am open to a better option. Especially since it doesn't mean that the script locks the phone. But really, such one-letter options can get pretty arbitrary so I didn't stress.

This branch goes hand-in-hand with https://code.launchpad.net/~mterry/ubuntu-test-cases/touch-unlock-device/+merge/215911

To post a comment you must log in.
lp:~mterry/phablet-tools/unlock updated
270. By Michael Terry

Teardown even if killed

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Sergio Schvezov (sergiusens) wrote :

+ exec_with_adb sh -c "if ! dpkg -s unity8-autopilot >/dev/null 2>/dev/null; then echo 'Installing unity8-autopilot on device for unlock support'; DEBIAN_FRONTEND=noninteractive apt-get -y -q install unity8-autopilot; fi"

Ideally devices should be in read only state for app testing. What I do to get the autopilot modules in phablet-test-click-setup is to grab the installed unity8 versions of the package and grab it's source package (pull-lp-source). We should do something similar here.

Revision history for this message
Sergio Schvezov (sergiusens) wrote :

Seeding unity8-autopilot is fine as well. We are in definite need of a proper QA story here.

The rest looks fine btw! :-)

Revision history for this message
Michael Terry (mterry) wrote :

Sergio, I think seeding is best bet, since the unlock script uses some python methods installed by the package.

Which branch has the seed config that I need to change?

Revision history for this message
Sergio Schvezov (sergiusens) wrote :

On Tue, Apr 29, 2014 at 4:39 PM, Michael Terry
<email address hidden>wrote:

> Sergio, I think seeding is best bet, since the unlock script uses some
> python methods installed by the package.
>
> Which branch has the seed config that I need to change?
>

For seeding, that's just the regular seed branch:
lp:~ubuntu-core-dev/ubuntu-seeds/ubuntu-touch.utopic

What do you think of splitting the autopilot package into some smaller
bits?

I'm looping in rsalveti and ogra

Revision history for this message
Michael Terry (mterry) wrote :

Oh. I thought you meant some special seeding that the QA images use. No, I'm not a fan of seeding it on all the images...

We could change the unlock script to be more contained -- we could probably duplicate some of the necessary python code.

But doesn't the autopilot scripts do some magic around installing files to /home/phablet/autopilot?

lp:~mterry/phablet-tools/unlock updated
271. By Michael Terry

If we need to, download unity8-autopilot and unpack it manually

272. By Michael Terry

Only override PYTHONPATH if we need to

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Michael Terry (mterry) wrote :

OK... I've updated the branch to download a copy of unity8 and use its files (storing the python module in /home/phablet/autopilot). But A) this needs a change on the unity8 side to be able to specify a PYTHONPATH for the unlock-device script. And B) we need to grab the dependencies for unity8-autopilot (like ubuntu-ui-toolkit-autopilot).

I don't want to reinvent the wheel here. Is there already a function somewhere else that nicely puts modules and their dependencies in /home/phablet/autopilot?

As an aside, this is becoming complicated. How does unlocking work today on a readonly device? You'd need the unity8 python module there too. So this must be a solved problem. (And if it isn't, can we not block this change on that feature?)

Revision history for this message
Sergio Schvezov (sergiusens) wrote :

On Wed, Apr 30, 2014 at 5:19 PM, Michael Terry
<email address hidden>wrote:

> OK... I've updated the branch to download a copy of unity8 and use its
> files (storing the python module in /home/phablet/autopilot). But A) this
> needs a change on the unity8 side to be able to specify a PYTHONPATH for
> the unlock-device script. And B) we need to grab the dependencies for
> unity8-autopilot (like ubuntu-ui-toolkit-autopilot).
>
> I don't want to reinvent the wheel here. Is there already a function
> somewhere else that nicely puts modules and their dependencies in
> /home/phablet/autopilot?
>

phablet-click-test-setup does this; that's one of the reasons you can test
click packages on read only images.

>
> As an aside, this is becoming complicated. How does unlocking work today
> on a readonly device? You'd need the unity8 python module there too. So
> this must be a solved problem. (And if it isn't, can we not block this
> change on that feature?)
>

Read only devices don't have unlocking; if you add the TODO, it's fine; I
think it's kind of a failure that we can't have a testing story for a
consumer device though.

lp:~mterry/phablet-tools/unlock updated
273. By Michael Terry

Go back to just assuming readwrite image

274. By Michael Terry

Add TODO note about wanting to support readonly images

Revision history for this message
Michael Terry (mterry) wrote :

OK, I've reverted this branch to the assume-readwrite-image version. I'd really prefer not to bundle all these features together. This change is blocking landing the split greeter, so I'd like to make this as targeted as possible (this set of merges is already taking on another of your wish list items to move the logic out of ubuntu-test-cases into phablet-tools).

I've added a TODO about readonly support. Ready for review.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
lp:~mterry/phablet-tools/unlock updated
275. By Michael Terry

Merge in some changes from Andy Doan that add support for passing on the wait command to unlock-device

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)

Unmerged revisions

275. By Michael Terry

Merge in some changes from Andy Doan that add support for passing on the wait command to unlock-device

274. By Michael Terry

Add TODO note about wanting to support readonly images

273. By Michael Terry

Go back to just assuming readwrite image

272. By Michael Terry

Only override PYTHONPATH if we need to

271. By Michael Terry

If we need to, download unity8-autopilot and unpack it manually

270. By Michael Terry

Teardown even if killed

269. By Michael Terry

Add unlock support to phablet-test-run

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'phablet-test-run'
2--- phablet-test-run 2014-04-01 01:36:31 +0000
3+++ phablet-test-run 2014-05-01 19:30:14 +0000
4@@ -21,17 +21,20 @@
5 ARTIFACTS=""
6 APFORMAT="xml"
7 APEXTRA=""
8+LOCALTMP=""
9+PIDS=""
10
11 EXECUTE_COMMAND=0
12 USER=phablet
13 ADBOPTS=""
14+NOUNLOCK=0
15 NOSHELL=0
16 RETVAL=0
17 VERBOSE=""
18
19 print_usage() {
20 cat << EOF
21-usage: $0 [-s SERIAL] [-s] [-n] [-x] [-v] [-p PACKAGENAME] [-c PACKAGE] [-o DIR] [-a ARTIFACT] [-f xml|subunit|text] [-A args] testsuite
22+usage: $0 [-s SERIAL] [-s] [-n] [-x] [-v] [-p PACKAGENAME] [-c PACKAGE] [-o DIR] [-a ARTIFACT] [-f xml|subunit|text] [-W WAIT_COMMAND] [-A args] testsuite
23
24 Run the specified testsuite on the device
25
26@@ -47,13 +50,16 @@
27 -A Extra arguments to pass to autopilot.
28 -a ARTIFACT Artifact to fetch after the test, may be used multiple times
29 (requires -o)
30+ -l Don't unlock screen on device (and thus don't reboot)
31+ -W WAIT_COMMAND By default the unlock script will sleep for 20 seconds.
32+ This allows using a custom script to do something else.
33 -x Execute command line, will not use autopilot by default
34 -v Run autopilot with -v option for more verbose output
35 EOF
36 }
37
38 wait_for_device() {
39- adb $ADBOPTS wait-for-device
40+ adb $ADBOPTS "wait-for-device"
41 }
42
43 exec_with_adb() {
44@@ -70,6 +76,16 @@
45 exec_with_adb DEBIAN_FRONTEND=noninteractive apt-get -y -q install $TESTPACKAGES
46 fi
47
48+ if [ $NOUNLOCK -eq 0 ]; then
49+ # Need to install unity8-autopilot so we can grab its unlock script.
50+ # We don't want the version of the script that may be on our host, because
51+ # the user may have different unity8 on device. And we do this here before
52+ # we push local packages in case user is pushing a custom unity8-autopilot.
53+ # TODO: It would be nice to allow doing this in a readonly image, by
54+ # installing this and its dependencies into /home/phablet/autopilot.
55+ exec_with_adb sh -c "if ! dpkg -s unity8-autopilot >/dev/null 2>/dev/null; then echo 'Installing unity8-autopilot on device for unlock support'; DEBIAN_FRONTEND=noninteractive apt-get -y -q install unity8-autopilot; fi"
56+ fi
57+
58 if test -n "$LOCALPACKAGES"; then
59 exec_with_adb mkdir -p /tmp/phablet-run-test/
60 exec_with_adb rm -rf /tmp/phablet-run-test/*
61@@ -85,6 +101,34 @@
62 fi
63 }
64
65+setup_session() {
66+ LOCALTMP=$(mktemp -d)
67+
68+ if [ $NOUNLOCK -eq 0 ]; then
69+ echo "Rebooting and unlocking screen..."
70+ adb pull /usr/share/unity8/unlock-device "$LOCALTMP" 2>/dev/null
71+ chmod +x "$LOCALTMP/unlock-device"
72+ # will reboot device and leave us inside user session
73+ "$LOCALTMP/unlock-device" $WAIT_COMMAND
74+ fi
75+
76+ # Call these directly rather than through exec_with_adb because we want to
77+ # grab the adb PID, not the PID of a backgrounded bash function.
78+ adb $ADBOPTS shell /usr/bin/powerd-cli active >/dev/null &
79+ PIDS="$PIDS $!"
80+ adb $ADBOPTS shell /usr/bin/powerd-cli display on bright >/dev/null &
81+ PIDS="$PIDS $!"
82+}
83+
84+teardown_session() {
85+ if [ -n "$PIDS" ]; then
86+ kill $PIDS
87+ PIDS=""
88+ fi
89+
90+ rm -rf "$LOCALTMP"
91+}
92+
93 disable_shell() {
94 exec_with_adb_user initctl stop unity8
95 }
96@@ -168,7 +212,7 @@
97 fi
98 }
99
100-while getopts A:a:c:f:hnxo:p:s:v opt; do
101+while getopts A:a:c:f:hW:lnxo:p:s:v opt; do
102 case $opt in
103 A)
104 APEXTRA=$OPTARG
105@@ -186,6 +230,12 @@
106 print_usage
107 exit 0
108 ;;
109+ l)
110+ NOUNLOCK=1
111+ ;;
112+ W)
113+ WAIT_COMMAND="-w $OPTARG"
114+ ;;
115 n)
116 NOSHELL=1
117 ;;
118@@ -215,8 +265,14 @@
119 exit 0
120 fi
121
122+trap teardown_session TERM INT EXIT
123+
124 install_packages
125
126+# Must do this after install_packages, since we may end up using installed
127+# packages to set up the session.
128+setup_session
129+
130 if [ $NOSHELL -eq 1 ]; then
131 echo "Disabling shell"
132 disable_shell

Subscribers

People subscribed via source and target branches