Help Center/ Cloud Phone Host/ Best Practices/ Using STF to Manage Cloud Phones in Batches
Updated on 2023-12-25 GMT+08:00

Using STF to Manage Cloud Phones in Batches

Scenarios

Smartphone Test Farm (STF) is an open-source web-based application used for managing and controlling mobile devices. STF uses a browser to control and manage Android devices, enabling you to use, debug, and test those devices on the cloud. This section describes how to deploy STF components on an ECS to manage cloud phones in batches.

Restrictions and Limitations

  • STF can manage about 160 cloud phones at the same time. For larger-scale access management, secondary development is required.
  • STF needs a stable network to run smoothly. When the network status is poor, the operation latency of cloud phones increases significantly.

Prerequisites

  • A cloud phone server that has an EIP bound is available.
  • An ECS that has an EIP bound is available.
The following cloud phone server and ECS specifications are only examples.
  • Cloud phone server: physical.kg1.4xlarge.cp | kg1.cp.c60.d16SSD.e1v1
  • ECS: general computing | s6.large.2 | 2 vCPUs | 4 GiB | Ubuntu 18.04 server 64bit (40 GB)

Procedure

Deploy components on which STF depends on the ECS, use the ADB tool to connect to the cloud phone, and access the STF address through a browser to manage cloud phones in batches.

  1. Install ADB and check the installation result.
    sudo apt install android-tools-adb android-tools-fastboot
    adb --version

    If --version is displayed, the installation is successful.

    Figure 1 Successful installation of ADB
  2. Update the yum source and install RethinkDB to store STF data.
    source /etc/lsb-release && echo "deb https://download.rethinkdb.com/repository/ubuntu-$DISTRIB_CODENAME $DISTRIB_CODENAME main" | sudo tee /etc/apt/sources.list.d/rethinkdb.list
    wget -qO- https://download.rethinkdb.com/repository/raw/pubkey.gpg | sudo apt-key add -
    sudo apt-get update
    sudo apt-get install rethinkdb
    rethinkdb -v
    If -v is displayed, the installation is successful.
    Figure 2 Successful installation of RethinkDB

    RethinkDB provides official support for the x86 architecture while experimental support for the Arm architecture.

  3. Install ZeroMQ to transfer messages.
    sudo apt-get install libzmq3-dev
    Figure 3 Successful installation of ZeroMQ
  4. Install Protocol Buffers as the data format for message transfer.
    sudo apt-get install libprotobuf-dev protobuf-compiler
    protoc --version
    If --version is displayed, the installation is successful.
    Figure 4 Successful installation of Protocol Buffers
  5. Install GraphicsMagick to read, write, and operate pictures.
    sudo apt-get install graphicsmagick
    gm version
    If version is displayed, the installation is successful.
    Figure 5 Successful installation of GraphicsMagick
  6. Install pkg-config to compile the third-party library of Nodejs.
    sudo apt-get install pkg-config
    pkg-config --version
    If --version is displayed, the installation is successful.
    Figure 6 Successful installation of pkg-config
  7. Install yasm to compile dependent libraries of STF.
    sudo apt-get install yasm
    yasm --version
    If --version is displayed, the installation is successful.
    Figure 7 Successful installation of yasm
  8. Install Nodejs to deploy the STF runtime environment.
    ##STF supports only Node.js 8.x.
    curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash  - 
    sudo apt-get install -y nodejs
    node -v
    npm -v
    If -v is displayed, the installation is successful.
    Figure 8 Successful installation of node and npm
  9. Install STF.
    sudo npm install -g cnpm --registry=https://registry.npm.taobao.org
    sudo cnpm install -g stf
    stf -V
    If -V is displayed, the installation is successful.
    Figure 9 Successful installation of STF
  10. Check whether the environment on which STF depends is available.
    stf doctor
    If the version of each component is displayed in the command output, the environment is available.
    Figure 10 Checking the STF startup environment
  11. Use ADB to connect to the cloud phone. For details, see ADB (Internet).
  12. Start RethinkDB.
    rethinkdb
    If information similar to that in the following is displayed, RethinkDB is started successfully.
    Figure 11 Starting RethinkDB
  13. Start STF in local mode and access STF using a browser.
    ## Set EIP to the EIP bound to the ECS.
    stf local --public-ip {EIP} --allow-remote
    ## Access method
    http://{EIP}:7100/
    Figure 12 Entering the default username and password of STF
    Figure 13 Cloud phones
    Figure 14 Cloud phone Control screen