~pwlars/ubuntu-test-cases/krillin-recovery

« back to all changes in this revision

Viewing changes to scripts/reboot-and-wait

  • Committer: Andy Doan
  • Date: 2013-10-21 02:19:35 UTC
  • mto: This revision was merged to the branch mainline in revision 75.
  • Revision ID: andy.doan@canonical.com-20131021021935-9v30ul1w0ff7yy30
fix bugs found in run-autopilot.sh

1: When unlock screen failed the whole script was ended. This makes sure
we just fail that single app test and continue trying other apps.

2: The reboot_wait logic isn't resiliant enough. Before we had "mega"
jobs (ie jenkins.sh) it was okay if a test occassionally failed to
get active networking. However, in this new script that failure can
cause all the remaining tests to not get run. The idea is to create
a reboot-and-wait script that will retry 3 times before giving up.

3: Update the system settle "classname" for junit. The issue I'm
seeing is that the junit results viewer in jenkins isn't correlating
the settle failures with the testsuite it happened in. This makes sure
the 2 are tied together.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/python
 
2
 
 
3
import argparse
 
4
import logging
 
5
 
 
6
from phabletutils.device import AndroidBridge
 
7
 
 
8
 
 
9
def _get_arg_parser():
 
10
    parser = argparse.ArgumentParser(
 
11
        description='Reboot device and waits for networking to become active.')
 
12
    parser.add_argument('-s', '--serial', help='Device serial')
 
13
    parser.add_argument('-n', '--num-tries', type=int, default=3,
 
14
                        help='''How many times to retry on failure.
 
15
                             default=%(default)d''')
 
16
    return parser
 
17
 
 
18
 
 
19
def main(args):
 
20
    device = AndroidBridge(args.serial)
 
21
    for i in range(args.num_tries):
 
22
        device.reboot()
 
23
        device.wait_for_device()
 
24
        try:
 
25
            device.wait_for_network()
 
26
            return 0
 
27
        except:
 
28
            pass  # try the loop again
 
29
    logging.error('device failed to start and activate networking')
 
30
    return 1
 
31
 
 
32
 
 
33
if __name__ == '__main__':
 
34
    logging.basicConfig(level=logging.INFO)
 
35
    logging.getLogger().name = 'reboot-and-wait'
 
36
    args = _get_arg_parser().parse_args()
 
37
    exit(main(args))