Help Center> Cloud Phone Host> Best Practices> Using STF to Manage Cloud Phones in Batches

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 really use, debug, and test those devices on the cloud. This section describes how to deploy STF components on an ECS to quickly manage cloud phones in batches.

Restrictions and Limitations

  • According to the test, STF can manage about 160 cloud phones at the same time. For larger-scale access management, secondary development is required.
  • The smooth running of STF depends on a stable network. 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(40GB)

Procedure

Deploy components that STF depends on 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
    Figure 1 Successful installation of ADB with --version displayed in the command output
  2. Update the 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. If --version is displayed in the command output, the installation is successful.
    sudo apt-get install libprotobuf-dev protobuf-compiler
    protoc --version
    Figure 4 Successful installation of Protocol Buffers
  5. Install GraphicsMagick to read, write, and operate images.
    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 Node.js.
    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 the dependent library 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 Node.js 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 STF depends on 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 shown in Figure 11 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 Enter the default username and password of STF.
    Figure 13 Cloud phone
    Figure 14 Cloud phone Control screen