In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/03 Report--
Github saw the AutoMagic automation platform open source, a moment of itching, tried to build a set of environment, now tell you the way of thinking.
AutoMagic is divided into two parts from its division of work:
1:Web-side management platform
The management platform is based on Python Django framework and Mysql development. It is mainly used to manage automated test cases and design automated test scenarios, store interface element identification, and manage it in the database through interface input. It is a purely automated original management platform based on Selenium keywords.
2: client execution script (seleniumkeyword)
The execution effect of AutoMagic is mainly reflected by it, and its execution is dependent on the use case and scenario data stored on the web platform. Seleniumkeyword does not need to be deployed on the server side, as long as it can connect to the server-side database, deployment can be executed on any platform. (facilitate distributed execution of test cases)
2.1: client installs the runtime environment
Server: running under python,mysql-python,django environment
Client: run under the environment of python, selenium and mysqldb, other dependent packages and plug-ins are installed according to the instructions.
2.2: client directory script description
The TestSuite.py test case execution script engine is that it can be executed in different ways through parameters.
-t [taskid] specifies the AutoMagic task to be executed
-u [userid] specifies the user who executes the script
-r [runid] executes the TestRailRunid to be synchronized by the test case script, which takes effect only when the-t parameter is executed.
-c [caseid] specifies the number of a single use case to be executed
-p [projectid] specifies the project id to be executed, which in turn executes all the modules in the project and all use cases where the use case status is enabled
-b [browser] specifies the browser to be used to execute the use case procedure, using the chrome browser by default, or it can be reset by the openbrowser keyword during case execution
Example:
Python TestSuite.py-t 1-u tsbc-b chrome
Zhufc users start the test task with id 1 under Google browser
Base.py is our keyword maintenance script, some methods of python selenium are redefined in class Action, and other parts are custom keywords.
AddCase.py synchronizes the use case to TestRail to the script and connects to the mysql database on the platform side
-t [taskid] specifies the AutoMagic task to perform synchronization
-u [userid] specifies the user who executes the script
-s [sctionid] executes the use case set that synchronizes case to TestRail (section_id represents the use case set to which it belongs)
Script file for HTMLTestRunner.py to generate report
RestApiUtil.py and RestApiUtil.py are the interfaces of sending MW simulating security events and sending pcap packets.
Interface API of testrail.py TestRail
The result directory is the report interface directory
Data directory when the upload attachment keyword is executed, the attachment is stored in the directory
Directory structure:
Generate test report results:
II: deployment solution 1 traditional deployment 1: server-side deployment
I am a ubuntu environment. If it is a centos environment, the command needs to be slightly adjusted and the apt-get command will be changed to yum.
1.1: install the mysql service
Apt-get install mysql-server
Apt-get install mysql-client
Sudo apt-get install libmysqlclient-dev
Netstat-tap | grep mysql checks whether the installation is successful
Mysql-uroot-pXXX performs login
1.1: generate the basic installation package
Create a new python folder under the usr directory:
Cd / usr
Mkdir python
Apt-get update
Apt-get install lrzsz
Execute the rz command to drag the local package to the python folder
Execute python setup.py sdist to generate the installation package in the home directory
Cd dist
Pip install automagic-0.1.tar.gz performs installation
1.2: install the django dependency package
Apt-get install python-dev python basic dependency package
Apt-get install python-pip install pip
Pip install-U setuptools upgrade setuptools
Pip install django==1.11.1 installs the base diango
Pip install MySQL-Python==1.2.3 install mysql-python
Pip install django-users2==0.2.1 dependency package
Pip install django-cors-headers==2.0.2 dependency package
Pip install djangorestframework==3.6.3 dependency package
Pip install python-jenkins==0.4.14 dependency package
1.3Install seleniumkeyword dependency packages
Pip install selenium dependency package
Pip install requests dependency package
Pip install paramiko==2.1.2 dependency package
Pip install scapy==2.3.3 dependency package
1.4: exception handling
If 404 occurs during the apt-get install process, execute apt-get update to upgrade the source
If E: Unable to lock the administration directory (/ var/lib/dpkg/) appears in the process, is another process using it? Then check the apt-get process and kill them all.
Ps-A | grep apt
Sudo kill-9 XXX
If it is reported that mysql-config and libmysqlclient.so.18 cannot be located in the process, configure the soft link
Ln-s / usr/local/mysql/bin/mysql_config / usr/local/bin/mysql_config
Ln-s/usr/local/mysql/lib/libmysqlclient.so.18/usr/lib/libmysqlclient.so.18
1:5: configure mysql connection
Cd / usr/python/automagic-dev/automated
Vi setting.py
Modify database configuration file
Ps: the NAME here is the name of the library and needs to exist in the database.
1.6:mysql user group ip assignment
/ usr/local/mysql/bin/mysql-uroot-pXXXXX
Grant all privileges on *. * to root@'%' identified by "XXXXX"
FLUSH PRIVILEGES
1.7: database initialization
Cd automagic-dev
Python manage.py makemigrations
Python manage.py migrate
1.8: create an administrator
Python manage.py createsuperuser
Follow the prompts to enter the user name, mailbox and password to be created (more than 8 digits, a combination of letters, characters and numbers)
1.9: start the service
Python manage.py runserver 0.0.0.0:8080
Virtual machine execution: native host:8080 access platform
2:pc deployment 2.1: install python2.72.2: install setuptooles2.3:pip install selenium2.4:pip install MySQL_python-1.2.5-cp27-none-win_amd64.whl 2.5:pip install mysql-python 2.6: configure mysqldb
Scenario 2 deployment of docker environment
I have containerized the Automagic platform, so I only need to install the docker tool locally to download the image deployment
1: install docker under the server
Sudo apt-get update
Sudo apt-get install docker
2: download the image (the image has not been made public yet, and you need to add the group to get it)
Registry.cn-hangzhou.aliyuncs.com/zhufc/automagic:django-automagic
3: build containers based on images
Docker run-d-- name automagic-p 4406 registry.cn-hangzhou.aliyuncs.com/zhufc/automagic:django-automagic 3306-p 808015 registry.cn-hangzhou.aliyuncs.com/zhufc/automagic:django-automagic
3306 database port mapped to 4406 position 8080 container port mapped to virtual machine 8080 for external access
4: enter the container
Docker ps-a View Container id
Docker exec-it d39c6648ebb0 bash enters the container
5: enter the automagic directory to start the automation platform
Cd / usr/python/automagic-dev
Python manage.py runserver 0.0.0.0 8080 start the service
The port is in use, indicating that the service has been self-started with the container. Go directly to the platform and use the virtual machine ip to access it.
Execute ctrl+p+q to exit without stopping the container
View virtual machine ipifconfig
6: the page executes localhost:8080 to start the service. 7: points for attention
I have deployed the mysql service under my docker container and configured to follow the container to self-start, so there is no need to restart mysql.
3: the basic use of the platform 1: create a product
2: click the product name to create a project
3: click the project name to create the module
4: click the associated product under user management to link the product with the user
5: add keywords under the functional test
The keyword source is under seleniumkeyword and can also be redefined.
6: add use cases, fill in keywords, locate elements, or enter text
7: fill in the location method and location logo
8: create a task and check the use case
Execute script commands in the 9:seleniumkeyword directory and pay attention to the task number
Python TestSuite.py-t 2-u zhufc-b chrome means to execute task number 2 in Google browser
10: view the running results
11: check the details under the use case to see the detailed running process and debug log
12: you can view detailed running reports and log files in the result directory
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.