Skip to content

Deploy a test agent service

HydraXMan edited this page Jan 3, 2023 · 38 revisions

If you are a Microsoft FTE and want to onboard to the internal Hydra Lab testing service, please visit our SharePoint site to learn more about the internal service instance.

Set Up Your PC Environment

For Android Agent

You can try the installer-Android.ps1 script to set up a new Windows agent for Android if the PC is brand new or its environment is clean enough. installer.zip. We are leveraging the winsw to wrap and manage the Spring Boot agent Jar application as a Windows service.

For iOS-Windows agent, the following 2 tools need to be installed

  1. Install iTunes on Microsoft store (The iOS devices need to connected to iTunes and set as a trusted device).
  2. Install tidevice: pip3 install -U "tidevice[openssl]"
  3. We also provide a script named as installer-iOS.ps1 for iOS-Windows agent. installer.zip

iOS-Mac agent

  1. Install: You can run the installer.sh script in this zip Hydra - ios Mac agent installer.zip to setup the environment.
  2. Restart: Install: You can run the restartAgent.sh script in zip of first step.

You can also set up manually.

  1. Install Java sdk link (at least jdk 11)
  2. Install Python 3.7+ link
  3. Install Android sdk link
  4. Install Node.js link
  5. Install Appium execute npm install -g appium
  6. Install WinAppdriver 1.2.1
  7. Install FFmpeg: Download ffmpeg-release-essentials.7z from link, unzip and add bin folder into PATH
  8. Config Environment Variables - System variables (take this as a reference)
Type Variable Name Value
Java JAVA_HOME C:\Program Files\Java\jdk-11.0.14
Java CLASSPATH .;%JAVA_HOME%\lib\dt.jar;%JAVA_HOME%\lib\tools.jar;
Java Path %JAVA_HOME%\bin
Java Path %JAVA_HOME%\jre\bin
Python Path C:\Python38|
Python Path C:\Python38\Scripts|
Android ANDROID_HOME C:\Users\demo\AppData\Local\Android\Sdk
Android ANDROID_PLATFORM_TOOLS C:\Users\demo\AppData\Local\Android\Sdk\platform-tools
Android Path %ANDROID_HOME%
Android Path %ANDROID_PLATFORM_TOOLS%
Node NODE_PATH C:\Users\demo\AppData\Roaming\npm\node_modules
Node Path C:\Users\demo\AppData\Roaming\npm;C:\Program Files\nodejs
Appium APPIUM_BINARY_PATH C:\Users\demo\AppData\Roaming\npm\node_modules\appium\build\lib\main.js
FFmpeg Path C:\Program Files\ffmpeg-4.4.1-essentials_build\bin

Install & Setup Agent Service on Windows

  1. Register an agent in Hydra Lab Center WebSite. (Please contact hydra_lab_support@microsoft.com if you are Microsoft FTE and want to use the MS internal network)

image

  1. Create a new folder in you PC.
  2. Build the agent project as agent.jar and copy the file to the folder. To build the agent, run the following command in the project root dir:
gradlew :agent:bootJar
  1. Unzip Agent Install.zip to the folder, the folder shows like this picture.

image

  1. Modify application.yml or config/application.yml (a sample configuration is available here: sample YAML config)

    • app.registry.server
      • The hostname + port of the center server. For instance, if it's running on a machine with the hostname of testagent.hydralab.com and servicing on port 9886, then this value should be "testagent.hydralab.com:9886".
    • app.registry.id
    • app.registry.secret
    • app.registry.name
    • app.registry.agent-type (An int value to indicate the type of test devices for Testing)
      • Value 1 represents WINDOWS PC + n * ANDROID devices -> For Android test agent.
      • Value 2 represents WINDOWS PC + 1 * ANDROID device, support running Appium Test case on Windows -> For Windows-Android cross-platform agent.
      • Value 3 represents WINDOWS/MAC PC + n * iOS devices -> For iOS test agent.
    • management.metrics.export.prometheus.pushgateway.enabled (Optional; If true, will send metrics to our stability monitor. When an exception happens, we will receive emails.)

image

  1. Install it as a Windows Service: open cmd/powershell, execute command : .\AgentInstaller.exe install

image

Start/Stop a Windows Agent Service

  1. Open Windows Services and find a service named Hydra Lab Agent Service.

image

  1. You can start/stop the service.

image

  1. if it starts successfully, the agent will show up in HydraLab center portal. BTW, only the agent connected with devices will be displayed on the page.

image

Test Device Onboarding

Android Phone

To ensure your Android Test Phone can be stably connected to the agent/center service, please turn on the Android Debug mode on your phone and connect the phone to the PC with cable or ADB wireless mode (Another guideline for wireless setup).

After a successful test run, you will find that a new app is installed on the phone called "HydraLab Client", which chiefly helps record test run videos on the phone. You can add it to the battery save mode whitelist to secure the recording service running consistently. We have pragmatically enabled it with this relevant code and this, but on some phones with customized rom you may need to configure it manually in the Setting, e.g.: Settings > Battery > Battery Optimization.

iPhone

After connecting the iPhone and PC with a USB wire, you need to Choose "trust the computer" on the phone. And then you need to install the WebDriverAgent(WDA) on the phone, which is the same one used in Appium iOS testing

Clone this wiki locally