Homemade quick smoke test gadgets - python-based multi-threaded (1)

Foreword

In the course of the project tested and found these situations often have the following:

• After the new version upgrade, sometimes because the code configuration or deployment errors, a menu 404 or 500 reported similar errors;
• To avoid the above problems, the implementation of the deployment of personnel after the upgrade, you need to manually smoke through all menu pages;
• released the same day as well as modify the measure to mention, a chance to return again and again all manually;
• the project cycle is not long, it does not have time to automate business processes.

If all menus to smoke again manually, we assume that a menu page to 5 seconds, then if a menu item has 600 pages, then you need to 3000 seconds, a full hour ah, but each upgrade must to this once. So I thought, although no time made all the automated functions that can not be achieved automatically to visit again for all the menu page, then judgment is not based on the results of visit are normal, in order to make a quick run smoke test?

First, the analysis of implementation steps

With the idea, it would have to analyze how to achieve a. The biggest problem is that all the menu corresponding url to how gained through after various attempts, found that the project is in the framework of reasons, unable to get all the url directly by crawlers.

However, in the database, corresponding to the front and back are two tables, as eclp_A storing domain, eclp_B specific path of each menu page is there, you just need to take out two tables of data spliced ​​together become a complete of the url.

Specific steps:

(1) in the database client and back-end management (client is uc, backstage management side is eclp) domain name and path taken out spliced ​​into a new table, and add the corresponding assertion keywords;

(2) different projects database configuration is not the same, so the database configuration in a configuration file, and then get through the program;

(3) After obtaining the configuration database, connect to the database to obtain from the table all url;

After (4) to take all the url to traverse the request, but the need to log in to get cookie after cookie to be binding, users need to use the password to log into the configuration file is also needed;

(5) access to all traverse url, and record the access result, the number of successes and failures;

(6) during program execution to access the page, the success and failure logs are recorded, to facilitate follow-up to find the problem;

(7) may be more because url to access all pages will be very slow, so multi-process or multi-threaded approach;

(8) The results of all page views using the HTML report output;

Second, the preparation

1. In the database (here is the oracle) spliced ​​URL

1.1 Create a table to store the url

Check back storage domain name and path of the main table

select t.*,t.rowid from eclp_A t orderby id desc;
select t.*,t.rowid from eclp_B t orderby id desc;

Create a table to store the complete url

CREATETABLE eclp_uc_url (
ID NUMBER(20) DEFAULT0  NOTNULL ,
SUB_SYSTEM_ID  NUMBER(20) DEFAULT0  NOTNULL ,
SUB_SYSTEM_CODEVARCHAR2(100 BYTE) DEFAULT''  NULL ,
NAME  VARCHAR2(255 BYTE) DEFAULT''  NULL ,
DOMAINVARCHAR2(100 BYTE) DEFAULT''  NULL ,
PATH VARCHAR2(100 BYTE)DEFAULT''  NULL ,
URL  VARCHAR2(100 BYTE) DEFAULT''  NULL ,
ASSERT_WORD  VARCHAR2(255 BYTE) DEFAULT''  NULL
)

Create a primary key

ALTERTABLE eclp_uc_url ADDPRIMARYKEY (ID);

创建id自增序列
drop SEQUENCE SEQ_ECLP_UC_URL;
CREATE SEQUENCE SEQ_ECLP_UC_URL
INCREMENTBY1
START WITH1
MAXVALUE9999999999999
CYCLE
CACHE 20;

1.2 insert from both the domain and path tables are stored into new tables url

eclp insertion path path table

INSERTINTO eclp_uc_url(id,SUB_SYSTEM_ID,NAME,PATH) SELECTSEQ_ECLP_UC_URL.NEXTVAL,SUB_SYSTEM_ID,NAME,URL from eclp_A;

eclp domain name into the table domian

updateeclp_uc_url set DOMAIN = (select DOMAIN from eclp_B whereeclp_uc_url.SUB_SYSTEM_ID = eclp_B.id)
whereexists (select 1 from eclp_B where eclp_uc_url.SUB_SYSTEM_ID =eclp_sub_system.id);

The domain and path spliced ​​into url

MERGEINTO eclp_uc_url A
USING( select t.id, t.domain || '/' || t.path as urls from eclp_uc_url t) B ON (A.ID= B.ID)
WHENMATCHED THEN UPDATE SET A.URL = B.URLS;

2. front and back office database configuration and user profiles

Create a file DbUser.ini:
there database connection configuration, front and back office user information, select the browser (chrome, firefox, ie)

-----------------------------------------------------
注:我这有个学习基地,里面有很多学习资料,感兴趣的+Q群:895817687
-----------------------------------------------------
    [db]
    oracle_ip=127.0.0.1
    oracle_account=test_account
    oracle_password=test_password
    
    [eclp]
    center_url=http://127.0.0.1:8020/system/login.htm
    center_account=test01
    center_password=123456a
     
    [uc]
    uc_url=http://127.0.0.1:9001/login.htm
    uc_account=test02
    uc_password=123456a
    
    [driver]
    browser=chrome

3. Taiwan before and after login element positioning Profiles

It includes positioning azimuth user name, password, login button, UiObjectMap.ini

[eclp]
LoginAccount=id>account
LoginPassword=id>password
LoginButton=xpath>//input[@class='btn2']

[uc]
LoginAccount=id>account
LoginPassword=id>password
LoginButton=id>button

(To be continued: code implementation)

Guess you like

Origin blog.csdn.net/weixin_42625143/article/details/95055182