Last updated: Apr 23, 2020 18:56
Why maintenance is important
Devices that form part of the individual clouds are real devices and as such not built for 24/7 usage under full load. Maintenance of these devices should therefore contain a reboot, among other checks, and be either run by a schedule (for example daily or weekly) or triggered by an action (for example before each main regression suite). The frequency depends on the amount of tests run and the model of devices. Generally, the more tests we execute against a specific device, and the older (or less reliable) the device is, the more often we should reboot the device.
A maintenance script or suite, which would consist of a number of maintenance actions to be performed, can be set up to run in parallel on specified devices.
Actions could include rebooting the device, recovering, resetting WiFi (switching off-on), verifying internet connectivity, verifying if the mobile network or WiFi is connected, installing and uninstalling required apps, and so on.
You can implement maintenance scripts in Appium/Selenium with a programming language of your choice, by using pure REST API calls, or by using PerfectoActions. Previously, it was also possible to use the Perfecto IDE, but with Flash being end-of-life (EOL) by the end of 2020, it is essential to adapt a different solution.
We recommend the following configuration settings:
- At least 8 GB RAM
- At least 2.20 GHz multicore processors
Using PerfectoActions for your maintenance script requires that you:
- Install Python version 3+ and set it as default.
- Install pip. If you experience proxy issues when installing pip, see Configure an experimental proxy.
Run the following command from a command-line window:
Following is a list of usage examples.
|Area||Example||Syntax to use|
|Device operations||List all available devices|
|List all available devices with an optional feature to provide custom logo using the following syntax: |
|List all available devices using your Perfecto username and password|
|List all devices irrespective of device status|
|Reboot, clean up, and get network settings for all devices, in parallel|
Get Devices List parameters and regular expressions using the following syntax:
|Get network settings (such as airplane mode, WiFi, and data) for available Samsung Galaxy devices only, in parallel|
|Repository cleanup||Display older repository items using the following syntax: |
The following example automatically displays repository media items older than 15 days.
|Automatically delete older repository items using the following syntax:|
The following example automatically deletes and displays repository media items older than 15 days.
|User list limitation||Limit or filter the user list using the following syntax: |
|General||Re-run the same execution with a specified sleep time|
|Skip output in HTML format (for faster results in a command-line window)|
Configure an experimental proxy
To configure an experimental proxy:
Configure proxies by setting the following environment variables:
To use HTTPS basic authentication with your proxy on Mac, try this: https://user:password@host:port
Set up scheduling
This section walks you through the steps for setting up the automatic scheduler on Windows, on Mac, or in Jenkins. Expand the steps that apply to you.
- Open Task Scheduler.
Create a new task and enter a descriptive name.Click to view image
- On the Triggers tab, click New.
In the New Trigger dialog box, set the trigger as preferred. For example, select Daily to run the task daily.Click to view image
- On the Actions tab, click New.
- Browse to the
actions.batfile. A sample
.batfile is available here: https://github.com/PerfectoMobileSA/Device_actions_reporter/blob/master/samples/actions.bat
actions.batfile to supply your preferred arguments to
perfectoactionson line 2.
perfectoactionsare triggered based on the trigger configuration.Click to view image
Results will be displayed as shown in the following image, provided
-ois not set to
perfectoactionsarguments.Click to view image
To get the physical path of
perfectoactions, in a terminal window, type
which perfectoactions.Click to view image
- Download a sample shell file from here: https://github.com/PerfectoMobileSA/Device_actions_reporter/blob/master/samples/actions.sh
- Edit the downloaded
.shfile by setting the physical path of
perfectoactionsand applicable arguments.
In a terminal window, navigate to the location to which you downloaded the sample shell file (
actions.sh) and run the following command:
cronfull disk access, in System Preferences > Security & Privacy, on the Privacy tab, drag
/usr/sbin/croninto the Full Disk Access area.Click to view image
In a terminal window, run the following command:
iand enter the following:
30 2 * * * /Users/genesisthomas/Downloads/actions.sh >/tmp/stdout.log 2>/tmp/stderr.log
:wq!to save the file and click on OK in the confirmation form that opens.Click to view image
To see whether the
cronjob is enabled, run the following command:
Verify the results.Click to view image
- On Windows only: Start the Jenkins service logged on with a local user account.
- Log in to Jenkins.
- Go to Manage Jenkins > Manage Plugins and install the HTML Publisher plugin.
- Back on the Manage Jenkins page, navigate to the Script Console.
In the Script Console, paste the following and click Run:Click to view image
- Clear the browser history and cache, restart the browser, and log in to Jenkins.
- In Jenkins, create a new freestyle job.
- In the Build triggers section, enable the Build periodically option.
- In the Schedule section, enter your preferred
cronschedule. For example,
30 2 * * *will run the job at 2:30 am every day.
- In the Build Environment section, enable the Delete workspace before build starts option.
Add a build step, as follows.
On Windows, execute a Windows batch command with the following commands included:Click to view image
On Mac, execute a shell with the following commands included:Click to view image
- Add the following post-build actions:
- Archive artifacts with files in the
results.htmlarchive (see image above)
- Publish HTML reports with index page: result.html (see image above)
- Archive artifacts with files in the
To find the
results.htmlbeing published as an HTML report, run the job.Click to view image