Under Linux interface test platform to build HttpRunnerManager

Foreword

Before learning HttpRunner, we all use cases written in YAML/JSONthe maintenance, use is also very convenient. In fact, there are a lot of big brothers like to develop automated test platforms, such as we have today to build HttpRunnerManager, which is developed based on HttpRunner good interface developed automated testing platform.

Github Address: https://github.com/HttpRunner/HttpRunnerManager

Although HttpRunnerManager author has stopped maintenance of the platform, but we can still learn more by building HttpRunnerManager, after the platform to build complete, we can write directly on the interface test automation platform.

Need to prepare in advance on Linux environment (The following is the environment when I set up):
1, Python 3.6.8 (refer to the article: Linux installation A Python 3 )
2, MySQL 5.7 (refer to article: install MySQL 5.7 Linux under )

Download Source HttpRunnerManager

First, we directly to Githubthe download HttpRunnerManager, download it to a local, or directly by the clone git. Here, I was a direct download archive.

Download HttpRunnerManager

The download is complete, unzip reached on a Linux server, or to spread through the Linux unzipcommand to extract, finally, we get the following:

Unzip

In the dependencies installed requirements.txt

Because the python3 and pip3 already installed on Linux, so there can be installed directly by pip3.

Installation command: PIP3 install -r requirements.txt

After entering the command to install, wait for the installation to complete. I encountered the following error when installing:

Installation error mysqlclient

The above is an error in the installation mysqlclientif a fault occurs, check in online, the reason is found to depend on the package when first installed Linux system installed mysql relevant packages mysql-devel, so we need to install mysql-develthe following command:

yum install mysql-devel

After the installation, re-installation requirements.txtin dependencies, the error will not.

Creating the MySQL database HttpRunner

Next, we need to create the appropriate HttpRunner on MySQL database, set the appropriate user name, password, and start MySQL. Here is my pass under Windows Navicatdatabase connection MySQL created the name hrun.

HttpRunner database

Created, you can not leave it behind will synchronize the database, and then get the data table structure.

Modify the configuration file

Modify HttpRunnerManager/settings.pythe configuration file DATABASES dictionary, we need to modify the place ( about settings.py in around line 120 ):

settings.py before the amendment

The only we modify the database configuration-related content, you can vim modify command, after amended as follows ( modify according to their actual situation ):

settings.py modified

Database synchronization

Above, we just created a name for the hrundatabase, but there is no data under the database table, now we will get the data synchronization database table. HttpRunnerManager need to return to the root directory, which is here in our HttpRunnerManager-masterdirectory.

生成数据迁移脚本:python3 manage.py makemigrations ApiManager
应用到db生成数据表:python3 manage.py migrate

Database synchronization

同步数据库完成之后,我们再到 MySQL 中查看,可以发现 hrun 数据库下新增了很多数据表。

New data table

创建后台管理员用户

到这里,我们基本的搭建工作已差不多完成。现在,我们创建一个超级用户,并按提示输入相应用户名,密码,邮箱。该用户可用于管理后台数据。

创建后台用户:python3 manage.py createsuperuser

Create a background user

启动Django服务

我们还需要启动Django服务,Django默认端口一般是8000,启动服务的命令如下:

python3 manage.py runserver 0.0.0.0:8000

使用上面的命令,有一个不足的地方,那就是不能在后台运行,因此我们最好通过后台运行的方式来启动Django服务,命令如下:

nohup python3 manage.py runserver 0.0.0.0:8000 >hrun.log 2>&1 &

HttpRunnerManager在后台运行的日志,将输出到 hrun.log 下。

登录HttpRunnerManager

在Linux下启动服务之后,我们将在Windows下进行访问并登录HttpRunnerManager,我们需要检查一下 8000 等端口是否已开放,特别如果是在云服务器上搭建的环境,需要添加安全组规则,否则可能访问不到。

后台管理:http://ip地址:8000/admin/
注册界面:http://ip地址:8000/api/register/

Background operation and maintenance management login interface is as follows:

Admin Login

Enter the steps to create a background for background user can log on screen after login as follows:

Admin interface

HttpRunnerManager user registration interface is as follows:

User Registration

After you create a normal user, switch to the login screen, as follows:

User login

The main interface after the user logs on success:

Main interface

Note: In the above main interface, we found the interface style seems to be something wrong, it is because we download the source code from Github some problems, here you need to manually change it up.

You need to modify the file

We need to modify the place

The above templates/base.htmldocument, line 23, you need to change it, will be http://cdn.amazeui.org/amazeui/2.7.2/css/amazeui.min.cssreplaced http://cdn.bootcss.com/amazeui/2.7.2/css/amazeui.min.css, then replace, refresh the page again, the interface style to normal, the last display interface effects are as follows:

HttpRunnerManager main interface

HttpRunnerManager, the asynchronous execution, scheduled tasks, task monitoring and other functions, need to build RabbitMQ messaging middleware, which we further study in the follow-up of it.

OK, now we HttpRunnerManager interface test platform has been basically set up success, in addition to the asynchronous execution, scheduled tasks, task monitoring, other functions can be used.

Guess you like

Origin www.cnblogs.com/wintest/p/12078867.html