Interface Automation test platform based on Httprunner Httprunnermanager (ii)

Source: Internet
Author: User
Tags rabbitmq

Https://github.com/HttpRunner/HttpRunnerManager

Httprunnermanagerdesign Philosophy

Httprunner-based interface Automation test Platform: HttpRunner , djcelery and Django _. Httprunner Manual: http://cn.httprunner.org/

Key Features
    • Project management: Add projects, list presentations, and related operations to support use case bulk uploads (standardized Httprunner JSON and YAML use case scripts)
    • Module Management: New modules for projects, use cases and configurations belong to Module,module and project support synchronous and asynchronous methods
    • Use Case management: divided into Add config and test sub-function, config definition of all variables and requests and other related information request can be public parameters and request headers, can also define all variables
    • Scene Management: Can dynamically load a reference use case, cross-project, cross-mold fast, rely on the use case list to support drag-and-drop sorting and deletion
    • How it works: Single test, single module, single project, multiple batch runs, support for custom test plans, flexible configuration and environment at runtime
    • Distributed execution: Single Use cases and batch execution results are displayed directly on the front end, and modules and project execution can be selected either synchronously or asynchronously,
    • Environment Management: Can add the running environment, can switch the environment with one click when running the use case
    • Report view: All asynchronous execution of use cases can be viewed online report, can be self-named, the empty default timestamp is saved,
    • Timed tasks: Can set the Scheduled tasks, follow the crontab expression, can be opened online, closed, after the completion of support mail notification
    • Continuous integration: Jenkins docking, developing ...
Make a record of Httprunnermanager's study .... Environment deployment can be viewed in GitHub. Record where there are changes in the deployment. Local Development environment Deployment
    • Install MySQL database server (recommended 5.7+), and set to UTF-8 encoding, create the corresponding Httprunner database, set the corresponding user name, password, start MySQL

Execute the command in the bin directory of the MySQL installation directory:
Mysqld--initialize--console
When execution is complete, the root user's initial default password is printed, such as:

2018-06-15t08:35:07.750836z 0 [System] [MY-013169] [Server] G:\Tools\mysql\mysql-8.0.11-winx64\mysql-8.0.11-winx64\ Bin\mysqld.exe (mysqld 8.0.11) initializing of server in progress as process 9716
2018-06-15t08:35:22.138130z 5 [Note] [MY-010454] [Server] A temporary password is generated for [email protected]: lf#hw/= JZ1G:
2018-06-15t08:35:30.402889z 0 [System] [MY-013170] [Server] G:\Tools\mysql\mysql-8.0.11-winx64\mysql-8.0.11-winx64\ Bin\mysqld.exe (mysqld 8.0.11) initializing of server has completed

Attention! There is a paragraph in the execution output: [Note] [MY-010454] [Server] A temporary password is generated for [email protected]: ri5rvf5x5g,e where [email PR Otected]: The following "Ri5rvf5x5g,e" is the initial password (excluding the first space). Before changing the password, you need to remember this password, subsequent logins need to use.
If your hands are cheap, close quickly, or don't remember, that's fine, delete the initialized DataDir directory, and then execute the initialization command again, and regenerate it. Of course, you can also use security tools, forced to change the password, with what method, their own discretion.

Execute the command in the bin directory of the MySQL installation directory:
mysqld--install [service name]
After the service name can not be written, the default name is MySQL. Of course, if you need to install more than one MySQL service on your computer, you can differentiate it with different names, such as MySQL5 and Mysql8.
After the installation is complete, you can start MySQL service from the command net start MySQL. Stop the service by using the command net stop MySQL. Uninstalling the MySQL service via the command SC delete mysql/mysqld-remove

Execute the command in the bin directory of the MySQL installation directory:
Mysql-u root-p
This time will prompt to enter the password, remember the above step 3.1 installation password, fill in can log in successfully, into the MySQL command mode

Execute the command in MySQL:
ALTER USER ' root ' @ ' localhost ' identified with Mysql_native_password by ' new password ';
Change the password, pay attention to the end of the command; must have, this is MySQL syntax

Here, the installation deployment is complete. Officials say the test speed is MySQL8 twice times faster than 5.


Mysql> select user,host,authentication_string from Mysql.user;
+------------------+-----------+-------------------------------------------+
| user | Host | authentication_string |
+------------------+-----------+-------------------------------------------+
| Mysql.infoschema | localhost | *thisisnotavalidpasswordthatcanbeusedhere |
| mysql.session | localhost | *thisisnotavalidpasswordthatcanbeusedhere |
| Mysql.sys | localhost | *thisisnotavalidpasswordthatcanbeusedhere |
| Root | localhost | *6bb4837eb74329105ee4568dda7dc67ed2ca2ad9 |
+------------------+-----------+-------------------------------------------+
4 rows in Set (0.00 sec)


The host of administrator root is localhost, which represents only localhost login access. If you want to allow other IP logins to be opened, you need to add a new host. If you want to allow all IP access, you can directly modify the "%"

To create a user:

CREATE USER ' lamw ' @ '% ' identified with Mysql_native_password by ' [Email protected]# ';

# (need to note: mysql8.0 encryption method Modified)
#检查用户

Select User, host, plugin, authentication_string from user\g;

Authorizing a remote database

#授权所有权限
GRANT all privileges on * * to ' xxh ' @ '% ';
#授权基本的查询修改权限, set on demand
GRANT select,insert,update,delete,create,drop,alter on *. * to ' xxh ' @ '% ';

View User Permissions
Show grants for ' xxh ' @ '% ';


For example: Create a new user

CREATE USER ' lamw ' @ '% ' identified with Mysql_native_password by ' 123456 ';

Log in when the IP address with localhost can log in with root, fill in the local IP cannot log in, do not know what the problem caused
Password 123456

    • Modified: httprunnermanager/httprunnermanager/settings.py databases dictionary and mail send account related configuration

      1.      DATABASES = {'         default ': {         ' ENGINE ': ' Django.db.backends.mysql ',         ' NAME ': ' Httprunner ',  # New database name         ' USER ': ' Root ',  # Database login         ' PASSWORD ': ' lcc123456 ',  # Database login password         ' HOST ': ' 127.0.0.1 ',  # Database location server IP address         ' port ': ' 3306 ',  # Listening port default 3306     }} email_send_username = ' [EMAIL protected] '  # Scheduled Task report send mailbox, support 163,qq,sina, Enterprise QQ mailbox, etc., note need to open SMTP service Email_send_password = ' PASSWORD '     # email password

    • Install RABBITMQ message Middleware, start the service, Access: http://host:15672/#/host for you to deploy RABBITMQ server IP address username:guest, password:guest, successful landing can
Service Rabbitmq-server start small part here to execute this sentence when the error, in fact, installed RABBITMQ directly can login

Before installing RABBITMQ, you need to install Erlang first
Http://www.erlang.org/downloads

1. Installing Erlang
So before installing RABBITMQ, you need to install Erlang first.
Small series use is otp_win64_20.3, need other version or 32-bit system, can go to the official website to download.
Click "Next" on all lines
Some choose other installation method, may need to add the system environment variable (also check under the normal installation):

(1): Download Erlang because the RABBITMQ server code is written using Erlang in the Concurrency language: http://www.erlang.org/downloads, Double-click the. exe file to install it, create an environment variable named Erlang_home after installation, its value points to the installation directory for ERLANG, add%erlang_home%\bin to path, and finally open the command line, enter Erl, If the version information of Erlang appears, the Erlang locale is installed successfully;
2. Installing RABBITMQ
Download run rabbitmq-server-3.7.6, need other version or 32-bit system, can go to the official website to download.
The installation can still be done without changing the default.
Note: The default installation of the RABBITMQ listening port is 5672

3. Configuration
Activating RabbitMQ ' s Management Plugin
With the RABBITMQ management plug-in, you can better visualize the status of your rabbit MQ server instances.
To open a command window:
Enter the command:
"G:\Tools\rabbitMQ\RabbitMQ Server\rabbitmq_server-3.7.6\sbin\rabbitmq-plugins.bat" Enable Rabbitmq_management
The command was executed with an error, and the Cmder was turned off again.

The account password is guest

    • Modified: httprunnermanager/httprunnermanager/settings.py Worker related configuration
Djcelery.setup_loader ()    CELERY_ENABLE_UTC = True    celery_timezone = ' Asia/shanghai '    broker_url = ' amqp:// Guest:guest[email protected]:5672//'  # 127.0.0.1 is the Rabbitmq-server server IP address    celerybeat_scheduler = ' Djcelery.schedulers.DatabaseScheduler '    celery_result_backend = ' djcelery.backends.database:DatabaseBackend '    celery_accept_content = [' Application/json ']    Celery_task_serializer = ' json '    celery_result_serializer = ' json '    celery_task_result_expires = 7200  # Celery the time-out of the task execution result, the number of    concurrent celeryd_concurrency =  # Celery Workers is also the number specified by the command line-C, based on the actual change to the server configuration default of the    Celeryd_ Max_tasks_per_child =  # # # # # # of how many tasks per worker will die, I suggest a larger number, default to                      #小编并未对这段代码做修改

    • Perform PIP Install-r requirements.txt the library file that the installation project relies on in the python36\scripts Directory command-line window

      (You need to copy Requirements.txt to G:\Tools\ in the G:\Tools\ Software installation package \httprunner\httprunnermanager-master\httprunnermanager-master directory.) Python\python36\scripts directory, PS: Here is to note that the beginning of a small series with 3.7, a variety of error, so the proposal is 3.6)

    • The command-line window switches to the Httprunnermanager directory to generate the database migration script and generate the table structure

  Python manage.py makemigrations apimanager #生成数据迁移脚本    python manage.py migrate  #应用到db生成数据表

If you encounter

Report: Django Migrate No changes Detected
Go to the database to see if the corresponding table is not generated, delete the __pycache__ folder of migrations/__pycache__
And then execute

Python manage.py Migrate

    • Create Superuser, user background Management database, and follow the prompts to enter the appropriate user name, password, mailbox. Skip this step if you don't need it
Python manage.py Createsuperuser

    • Start the service
  Python manage.py runserver 0.0.0.0:8000

    • Start worker, if you choose to synchronize execution and make sure that you do not use the scheduled task, this step ignores
Python manage.py celery-a httprunnermanager worker--loglevel=info  #启动worker    python manage.py celery beat-- Loglevel=info #启动定时任务监听器    Celery Flower #启动任务监控后台

    • Visit: Http://localhost:5555/dashboard to view task List and status

    • Browser input: http://127.0.0.1:8000/api/register/registered users, start to enjoy the platform bar

    • Browser input http://127.0.0.1:8000/admin/Enter the user name and password set by step 6, login to the background operation management system, can manage the data in the background

Not to be continued

Interface Automation test platform based on Httprunner Httprunnermanager (ii)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.