This is the 31st day of my participation in the August Text Challenge.More challenges in August

In our daily testing, we will encounter a variety of device management, so we can set up a device management cluster based on STF, let’s see how to set up this environment, in fact, on the MAC is very simple, directly use the command installation.

Install dependencies

Brew install rethinkdb Graphicsmagick zeromq protobuf yasm pkg-config STF depends on node v8.9.1 NPM 6.0.0 Since the Node version and NPM version do not match well, STF construction may encounter bugs, so make sure before installation, what I encountered is like this. The node NPM version may fail to be installed due to different versions. Therefore, determine the node NPM version during installation.

npm install stf

Installation complete, start

Start rethinkdb rethinkdb
STF local Starts the STF

After startup, visit http://localhost:7100/

Then you need to log in and authenticate. Enter your name and email.

Here I have linked to a local mobile phone, which is the device after logging in, so we can click this device to conduct operations

So we can link to our local mobile phone, and operate, and the actual operation is the same, so we can do some operations.

We need to connect the device remotely through the API, so let’s see how to do this remotely through the API.

First set up the module in STF and add a key.

And then you get the token that applies to the key and you can connect to it remotely.

curl -H "Authorization: Bearer 6056e152ca7f4d3e877f978d3adfbbf5bca3ffa6edbb41499171933b663d2751" http://localhost:7100/api/v1/devices

So we can return all the devices on our remote STF. We can check it on the terminal.

This will return all the information for all the devices. We get this information and can access the details of our device remotely.

curl -H "Authorization: Bearer baafca0e3f10412bb8d2d292ac0bcf1caa113f6310144a73a37xxxxxxxxxxxxb" http://localhost:7100/api/v1/devices/c70dacf1 
Copy the code

After obtaining the information of the device, we can obtain whether the device is in use according to the information of the device and apply for the use of the device remotely.

To apply for equipment

curl -X POST --header "Content-Type: application/json" --data '{"serial":"c70dacf1"}' -H "Authorization: Bearer baafca0e3f10412bb8d2d292ac0bcf1caa113f6310144a73xxxxxxxxxxxxx" http://localhost:7100/api/v1/user/devices
Copy the code

After the application, we can use it.

We can use to get the link address of the device.

curl -X POST -H "Authorization: Bearer baafca0e3f10412bb8d2d292ac0bcf1caa113f6310144a7xxxxxxxxxxxxxxxx" http://localhost:7100/api/v1/user/devices/c70dacf1/remoteConnect
Copy the code

So we can use the device remotely.

After using this device, the device can be returned remotely.

curl -X DELETE -H "Authorization: Bearer baafca0e3f10412bb8d2d292ac0bcf1caa113f6310144a7xxxxxxxxxxxx" http://localhost:7100/api/v1/user/devices/c70dacf1
Copy the code

In fact, in our work, we will use appium, so we may encounter such a problem, how do we link remote devices, I use

adb connect localhost:7401
Copy the code

We can use it

Adb Devices view device links.Copy the code

Finally, we can test the device by doing this. Return the equipment after testing. The process should be:

Get STF device list -- -- > application equipment remote link -- -- > > organize test cases -- -- -- -- > > execute test cases generated test report -- -- > to return equipment.Copy the code

For example, the user name authentication of STF is separate now, and it should be made internal later to get through the authentication mechanism of other users.

In the actual use of the follow-up, will continue to share experience.