Skip to content

Deploy a test agent service

OliverShen edited this page Jun 8, 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.

We are deprecating this wiki and revamp it in Test-agent-setup

Set Up Your PC Environment

You can set it up manually.

1. Install dev kits:

The following are fundamental:

  1. Install JDK/JRE (at least JDK 11)
  2. Install Android SDK
  3. Install FFmpeg: Download ffmpeg-release-essentials.7z, unzip and add bin folder into PATH
  4. Install the command line tool by xcode-select --install

The following are required for the Appium test runner:

  1. Install Node.js
  2. Install Appium execute npm install -g appium
  3. Install WinAppdriver 1.2.1

And the below is for smart test runner: Required for smart test: Install Python 3.7+ link

2. Config Environment Variables - System variables

Below is a table of configuration samples:

Type Variable Name Value
Java JAVA_HOME C:\Program Files\Java\jdk-11.0.14
Java Path %JAVA_HOME%\bin
Python Path C:\Python38|
Python Path C:\Python38\Scripts|
FFmpeg Path C:\Program Files\ffmpeg-4.4.1-essentials_build\bin
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%\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

Setup Hydra Lab Agent on Windows(X86/X64)

  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. Download the latest agent.jar or build the agent project as agent.jar. Then, copy the file to the folder. To build the agent, run the following command in the project root dir:
gradlew :agent:bootJar
  1. Unzip HydraLab_Agent_Installer_Windows.zip to the folder, the folder shows like this picture.

image

  1. Download application.yml from portal (a sample configuration is available here: sample YAML config)

image

  • 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.device.monitor (Indicate the type of test devices for Testing)
    • windows.enabled: Default value is false.
    • android.enabled: Default value is true
    • ios.enabled: Default value is false.
  • management.metrics.export.prometheus.pushgateway.enabled (Optional; If true, will send metrics to our stability monitor. When an exception happens, we will receive emails.)

Start/Stop Hydra Lab Agent

1. Android or iOS agent

  1. Setup log file location: modify AgentService.xml and replace {LOG_FILE_LOCATION}

  2. Install it as a Windows Service: open cmd/powershell (admin), execute command : .\AgentService.exe install

image

  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

2. Cross-platform agent (Windows + Android)

PS. The WinAppDriver can't work normally if started by Windows Service.Issue link

  1. Update restartAgent.bat: comment line18,31 and uncomment line 20,29.

image

  1. Start agent directly: open cmd/powershell (admin); cd to the install folder; execute restartAgent.bat script

If you want to keep your Windows test agent awake without locking itself over time, so as to run UI tests for Windows apps, consider leveraging the PowerToy toolset - awake feature | Awake Utility to keep the Windows device active.

Test Device Onboarding

Android Phone

To ensure your Android Test Phone can be stably connected to the agent/center service, please follow the below 2 steps as onboarding guides:

  1. 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).
  2. Set the phone lock mode as 'None' in the Phone lock screen setting page: Settings > Security > Screen Lock, and if prompted, enter your current lock screen code > None > Delete.

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. For some phones with customized rom (e.g.: Xiaomi), you may need to manually allow the HydarLab Client app display over other apps:

image

You can also add the app 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. We offer internal support for this integration within Microsoft. Please contact Nathan or Millard to get the internal integration wiki.

Performance Testing

For battery testing on Windows, the following 2 prerequisites are required

  1. Requires a Windows device with a battery, such as a laptop.
  2. Need to disable UAC popup manually since the elevated privileges is required which would blocking the performance testing.
    image
Clone this wiki locally