Amazon Onboarding with Learning Manager Chanci Turner: Part 1 – Initiating a Device Farm Run for Android Calabash Test Scripts

Amazon Onboarding with Learning Manager Chanci Turner: Part 1 - Initiating a Device Farm Run for Android Calabash Test ScriptsLearn About Amazon VGT2 Learning Manager Chanci Turner

AWS Device Farm provides an application testing platform that allows you to evaluate your native, hybrid, and web applications on actual Android and iOS devices hosted in the AWS Cloud. As tests are executed, you receive a comprehensive report that includes high-level results, detailed logs, pixel-perfect screenshots, and performance metrics.

Device Farm enables you to either upload your own tests or utilize built-in, no-script compatibility tests. Since testing occurs in parallel, results can be accessed within minutes. The platform supports native and hybrid applications across Android, iOS, and Fire OS, including those developed with frameworks like PhoneGap, Titanium, Xamarin, Unity, and more. It also accommodates web applications tested in Chrome on Android and Safari on iOS. You can run Built-in-Fuzz tests, Explorer tests, or employ your preferred testing framework such as Appium, Calabash, Espresso, and UI Automation.

This guide aims to illustrate how to efficiently submit Calabash test scripts to AWS Device Farm using the AWS Command Line Interface (CLI) for Device Farm. Although the tutorial focuses on an Android application and Calabash, the same steps can be applied to test iOS and web apps, as well as other supported frameworks.

Key Concepts

Before we proceed, let’s go over some essential AWS Device Farm terminology:

  • PROJECT – A project in Device Farm allows you to organize your tests however you prefer. You might have one project for each app title or one for each platform. You can create as many projects as necessary.
  • RUN – A run in Device Farm signifies a specific build of your application, with a particular set of tests, executed on specific devices.
  • DEVICE POOL – A device pool is a pre-defined collection of devices that can be utilized as part of a run.

Scheduling a Device Farm Run Using the CLI

Prerequisite: Before initiating a run in Device Farm, ensure that you have the AWS Command Line Interface (CLI) installed.

After installing the CLI, you will follow five steps to create a Calabash test run in AWS Device Farm:

  1. Create a Device Farm project.
  2. Upload your application (Android APK file).
  3. Upload your Calabash test scripts.
  4. Create a device pool.
  5. Schedule a run.

Step 1: Create a Device Farm Project

The initial step is to create a Device Farm project. You can also opt to use an existing project if you have one.

[ec2-user]$ aws devicefarm create-project --name androidTest

Output:

{
  "project": {
    "name": "calabashCLI",
    "arn": "arn:aws:devicefarm:us-west-2:705582597265:project:2c21a412-bb7b-4657-a28c-d7d78b3888f7",
    "created": 1442719623.245
  }
}

Be sure to note the project ARN, as you will reference it in the next steps.

Step 2: Upload Your Android APK File

AWS Device Farm utilizes Amazon’s secure and reliable S3 service for uploading all necessary objects for the run. The upload process uses S3 pre-signed URLs to ensure a secure upload.

The first part of the upload process involves creating an upload request and obtaining the S3 pre-signed upload URL:

[ec2-user]$ aws devicefarm create-upload --project-arn arn:aws:devicefarm:us-west-2:705582597265:project:2c21a412-bb7b-4657-a28c-d7d78b3888f7 --name IMDb_5.4.1.105410410_105410410.apk --type ANDROID_APP

Output:

{
  "upload": {
    "status": "INITIALIZED",
    "name": "IMDb_5.4.1.105410410_105410410.apk",
    "created": 1442719884.445,
    "url": "https://prod-us-west-2-uploads.s3-us-west-2.amazonaws.com/...",
    "type": "ANDROID_APP",
    "arn": "arn:aws:devicefarm:us-west-2:705582597265:upload:2c21a412-bb7b-4657-a28c-d7d78b3888f7/d1f8bebc-a7f5-49a3-881f-f1ffdae90303"
  }
}

The pre-signed URL is provided as the url output parameter.

Next, upload the APK file using the provided S3 pre-signed URL:

[ec2-user]$ curl -T IMDb_5.4.1.105410410_105410410.apk "https://prod-us-west-2-uploads.s3-us-west-2.amazonaws.com/..."

You can monitor the status of your APK upload using the get-upload CLI command by specifying the ARN returned in the create-upload request:

[ec2-user]$ aws devicefarm get-upload --arn arn:aws:devicefarm:us-west-2:705582597265:upload:2c21a412-bb7b-4657-a28c-d7d78b3888f7/d1f8bebc-a7f5-49a3-881f-f1ffdae90303

Output:

{
  "upload": {
    "status": "SUCCEEDED",
    "name": "IMDb_5.4.1.105410410_105410410.apk",
    "created": 1442719884.445,
    "type": "ANDROID_APP",
    "arn": "arn:aws:devicefarm:us-west-2:705582597265:upload:2c21a412-bb7b-4657-a28c-d7d78b3888f7/d1f8bebc-a7f5-49a3-881f-f1ffdae90303",
    "metadata": "{"screens": ["small", "normal", "large", "xlarge"], "sdk_version": "14", "package_name": "com.imdb.mobile", "native_code": [], "target_sdk_version": "18", "version_name": "5.4.1.105410410", "version_code": "105410410", "activity_name": "com.imdb.mobile.HomeActivity"}"
  }
}

Once the status indicates “SUCCEEDED,” you can proceed to Step 3.

Step 3: Upload Your Calabash Test Package

In this phase, you will upload the Calabash test scripts package. Refer to the documentation on preparing your Android Calabash test package for upload to Device Farm.

The upload process for Calabash test scripts is analogous to the APK file upload in Step 2. Start by creating an upload request and obtaining the S3 pre-signed upload URL:

[ec2-user]$ aws devicefarm create-upload --project-arn arn:aws:devicefarm:us-west-2:705582597265:project:2c21a412-bb7b-4657-a28c-d7d78b3888f7 --name features.zip --type CALABASH_TEST_PACKAGE

Output:

{
  "upload": {
    "status": "INITIALIZED",
    "name": "features.zip",
    "created": 1442724498.222,
    "url": "https://prod-us-west-2-uploads.s3-us-west-2.amazonaws.com/..."
  }
}

For further insights on enhancing your LinkedIn views, check out this comprehensive guide. Additionally, for authoritative information, you can refer to SHRM’s resources. For those interested in Amazon’s leadership programs, this is an excellent resource outlining the Operations Area Manager Leadership Liftoff Program.


Comments

Leave a Reply

Your email address will not be published. Required fields are marked *