+1 404-214-5804
Enterprise Mobility Blog, Mobile App Development

Mobile DevOps Tips and Tricks: Reboot Multiple Mobile Devices with a Private Mobile Device Cloud

Automated mobile app testing requires automation at more levels than the app and the mobile device.  To support Mobile DevOps, device management functions need to be automated as well.  As an example of one such need, we at Mobile Labs run a lot of stress tests against deviceConnect, our private mobile device cloud.  Getting the test environment set up to run 48 concurrent automated tests requires scripting deviceConnect management functions like installing apps, retaining devices, and launching both apps and tests. One thing we do as a part of the automation setup is to reboot all devices before beginning a stress-test run. The deviceConnectCLI command-line program is just what we need to make this quick and easy.  In this application note, we show how to reboot a list of mobile devices in one or more deviceConnect appliances.

While we could have used any number of scripting frameworks, we chose to use UFT from HP and our Mobile Labs’ Trust add-in.

The main ingredients needed to automatically reboot the entire list of devices are the deviceConnectCLI program, which we downloaded from the Web User Interface of deviceConnect and installed in the C:\Windows\Program Files (x86) directory, and a data sheet in UFT that lists the IP address of deviceConnect and each device name.  This same list is used to drive concurrent automated testing on all of these devices and so the sheet contains some columns not needed for the reboot project.  Here’s a look at the UFT data sheet:

The UFT/Trust script reads the columns of this sheet one by one, constructs a reboot command, and then issues the command to deviceConnect.  The username is registered as a deviceConnect administrator.

Here is the entire script:

Dim i
Dim StrConnectParam
Dim devices
Dim totalrows

Reporter.Filter = rfDisableAll
print "**** " & Date & " " & Time & " REBOOTING ALL DEVICES ****"
totalrows = DataTable.GetSheet("CLI SetUP").GetRowCount

For i = 1 To totalrows Step 1
    'Get data values from data sheet
    Environment("strIP") = DataTable.GetSheet("CLI SetUP").GetParameter("dC_IP").ValueByRow(i)
    Environment("strUserName") = DataTable.GetSheet("CLI SetUP").GetParameter("UserName").ValueByRow(i)
    Environment("strPassword")= DataTable.GetSheet("CLI SetUP").GetParameter("Password").ValueByRow(i)
    Environment("strDeviceName") = Rtrim(Ltrim(DataTable.GetSheet("CLI SetUP").GetParameter("Device_Name").ValueByRow(i)))
    Environment("strCLIPath")= DataTable.GetSheet("CLI SetUP").GetParameter("CLI_Path").ValueByRow(i)

    'Assemble reboot command
    strConnectParam = Environment("strIP") & " " & Environment("strUserName") & " " & Environment("strPassword") & " " & "-d" & " " _
        & Chr(34) & Environment("strDeviceName") & Chr(34) & " " & "-reboot"

    'If a device name was given, then issue the reboot command
    If Environment("strDeviceName") <> "" Then
        print Time & " " & strConnectParam
        devices = devices + 1
        SystemUtil.Run "MobileLabs.DeviceConnect.Cli.exe", strConnectParam , Environment("strCLIPath")
    End If

print CStr(devices) & " devices were rebooted."

And here is typical output from the script:

**** 9/18/2014 10:44:18 AM REBOOTING ALL DEVICES ****
10:44:19 AM mike@ml.sys abcdef12 -d "LGE_04f4e770101ba2b6" -reboot
10:44:19 AM mike@ml.sys abcdef12 -d "32_MLiPhone4S-C39GLE" -reboot
10:44:19 AM mike@ml.sys abcdef12 -d "LGE_04bf9ca01c650239" -reboot
10:44:19 AM mike@ml.sys abcdef12 -d "Airstream_iPhone" -reboot
10:44:19 AM mike@ml.sys abcdef12 -d "deviceConnect_iPad" -reboot
10:44:20 AM mike@ml.sys abcdef12 -d "deviceConnect_iPhone" -reboot
10:44:28 AM mike@ml.sys abcdef12 -d "HTC_FA2BAX401283" -reboot
10:44:28 AM mike@ml.sys abcdef12 -d "LGE_01c979864a9839a5" -reboot
47 devices were rebooted.

Michael Ryan

Michael Ryan serves as Mobile Labs’ chief technology officer. In this role, Ryan provides the technological vision and drives Mobile Labs Trust’s product road map. Ryan has more than 35 years of experience in leading software development teams that design and build robust and market-leading solutions for large-scale enterprise customers among Fortune 1000 companies. Most recently, Ryan was with Fundamental Software where he worked on large-scale systems CPU emulation architecture, design, and implementation. Prior to Fundamental Software, Ryan was director of development, Sr. VP of R&D, and finally, Chief Technical Officer for CASE tool vendor KnowledgeWare, Inc. Ryan served as senior staff systems engineer, field manager, and regional technical support manager for mainframe manufacturer Amdahl Corporation.

More Posts - Website

Leave a Reply

You must be logged in to post a comment.

Why Mobile Labs?

Mobile Labs provides enterprise-grade, next generation mobile application testing tools. With a focus on security, agility and affordability, Mobile Labs delivers solutions to help you deliver quality mobile apps for Android, iOS and Windows platforms while also helping manage mobile devices in a private, secure cloud.

Contact Mobile Labs

3423 Piedmont Road NE
Suite 465
Atlanta, GA 30305
+1 404-214-5804
twitter  facebook linkedin google-plus SlideShare