Distributed performance test method and device and computer-readable recording medium
Technical field
The present invention relates to testing field, more particularly to a kind of distributed performance test method and device are deposited with computer-readable
Storage media.
Background technology
Big concurrent test assignment (Virtual User is more than 60,000), single pressure source node are frequently encountered in performance test
It is difficult to support so high test scene;Business Performance testing tool price costly, and realizing by the testing tool increased income
There are certain deficiency, it is necessary to which manual modification test data, test script etc., bothersome laborious and easy during the business scenario of complexity
Error.
Testing tool Jmeter has a function of remotely running, can be from single Jmeter clients by this module
Multiple remote engines are controlled, so as to fulfill the relatively large load on emulating server.An example of Jmeter clients in theory
Any number of long-range Jmeter examples can be controlled, and therefrom collect all data.Long-range operation function is by set about
Duan Shixian:
Test script is stored in local machine;
Multiple Jmeter engines are managed from individual machine;
Client is responsible for the content (request) of script being sent to all servers;
All nodes all run identical test plan, and each node runs complete test plan;It is moreover, long-range
Operational mode can take more resources, not be the non-GUI tests of the identical quantity of independent operating, if the node instance mistake used
It is more, Jmeter client resources can be caused to overload.In addition, for the test scene of parametrization, since what each node was run is
Identical test plan, setup test data file under path that just must be identical on each server.This condition limitation
Under, a server can only just run a remote instance, increase the demand of test environment significantly.
In the remote operating mode of Jmeter, perform test before, it is necessary to first by the Jmeter examples of each node with
Jmeter server patterns start (manually performing);For quoting the test plan of test data, it is necessary to by hand by data file
Split, be then placed within the identical path of each remote server, and in such a scenario, can only on each server
Run a remote instance;If node is excessive, the resource overhead and network overhead of Jmeter clients can be greatly increased, is surveyed
Therefore test result is possible to by pollution to a certain degree.
When red packet performance test task is robbed in the Spring Festival, due to the scene of high concurrent to be simulated (more than 50,000), individual node without
Method meets testing requirement, and each account of business need can only be called once, can not reuse.The means taken at that time are
Test data is split into by hand multiple, be placed under the different paths of different server, then Jmeter is copied more parts, and point
Other renaming is placed under respective paths.Finally manual modification test script again, make multiple similar copies (test data
It is different to quote content), then it is manually switched to different servers, each self-starting Jmeter programs, the respective survey of independent operating
Training sheet.Whole process participates in manually manually, if test scene is changed, it is necessary to change multiple test scripts, and survey
Data are tried in the event of changing, also to be split again manually, under the different nodes for copying different servers to.One continues 20
The test scene of minute, will often do the preparation of or so half an hour, and time cost is very high, and each script will
By manually completing, it is particularly easy to malfunction, six or seven node, just in case one of error, test assignment will fail, it is necessary to from the beginning
Start, it is very high to the accuracy requirement of human-edited.
The content of the invention
In view of this, the present invention is intended to provide a kind of distributed performance test method, device and computer-readable storage medium
The problem of matter, avoids test program client under multiple remote node scenes, and overhead overloads, reduces test result quilt
The risk of pollution.
Specifically, a kind of distributed performance test method of the present invention, including:Information, solution are distributed according to the node to prestore
Analysis is obtained respectively from the configuration information of server, and the configuration information includes network address and respectively from the node of server-assignment
Number;Total test data is split respectively from the configuration information of server according to described, obtains the corresponding sub- test number of each node
According to, and the data referencing in test script is replaced with into the corresponding sub- test data of each node, establish the corresponding test of each node
Script;Test program, the corresponding sub- test data of each node and test script are pushed to each node from server;According to
Test assignment, respectively the corresponding command is sent to described from the node of server, and task and execution result back are performed by each node.
Further, described that total test data is split, the step of obtaining each node corresponding sub- test data, is also
Including:Corresponding node identification is configured to each sub- test data;Or/also, the data referencing by test script replaces
The step of being changed to each node corresponding sub- test data further includes:The corresponding section is configured to the corresponding test script of each node
Point identification.
Further, it is described by test program, the corresponding sub- test data of each node and test script be pushed to it is each from
The step of node of server, includes:It is described to copy test program to each node from server;Test to each node
Program configures the file of the corresponding node identification;The corresponding sub- test data of each node is corresponding with test script push
Node.
Further, the node uses the XML node of XML format, the distributed performance test side for test script
Method further includes:The XML node for all quoting test data file is searched for using xmlstarlet, by the test data file of reference
Name is stored in an array, obtains file array;File array is traveled through, and performs the data referencing by test script
The step of replacing with each node corresponding sub- test data.
Further, respectively it is stored in from the configuration information of server in a global array, each value of array represents one
A configuration information from server.
Further, the test program is Jmeter, and the distributed performance test method performs task in each node
And further included after execution result back:Feedback result is merged using shell scripts, calls the plug-in unit of Jmeter to tie feedback
Fruit carries out analytic statistics, and draws.
Further, the distributed performance test method is also wrapped after each node performs task and execution result back
Include:The summary data of test result is stored in a csv file, writes java script scripts, by the chart and system of drafting
It is loaded into html template and shows after csv file parsing after meter.
A kind of distributed performance test device of the present invention, including:Resolution unit, for distributing letter according to the node to prestore
Breath, parsing are obtained respectively from the configuration information of server, and the configuration information includes network address and respectively from server-assignment
Number of nodes;Dispensing unit, for being split according to described respectively from the configuration information of server to total test data, obtains each
The corresponding sub- test data of node, and the data referencing in test script is replaced with into the corresponding sub- test data of each node, build
Found the corresponding test script of each node;Test program, the corresponding sub- test data of each node and test script are pushed to each
From the node of server;Unit of testing and controlling, according to test assignment, respectively the corresponding command is sent to described from the node of server,
Task and execution result back are performed by each node.
Further, the node uses the XML node of XML format for test script;The dispensing unit, including
Xmlstarlet instruments, the XML node of test data file is all quoted for searching for, the test data file name of reference is protected
There are in an array, file array is obtained;File array is traveled through, and performs the data referencing by test script and replaces
The step of sub- test data corresponding for each node.
Further, distributed performance test device further includes:Data processing unit, for utilizing shell scripts anti-
Present result to merge, call the plug-in unit of Jmeter to carry out analytic statistics to feedback result, and draw.
Further, the distributed performance test device further includes:Display unit, the summary number for test result
According to being stored in a csv file, java script scripts are write, after the csv file parsing after the chart of drafting and statistics
It is loaded into html template and shows.
A kind of computer-readable recording medium of the present invention, is stored thereon with computer program, which is executed by processor
Distributed performance test method above-mentioned Shi Shixian.
One test assignment is split and is synchronously carried out in multiple nodes by various embodiments of the present invention automatically, meets large concurrent
Test scene demand;Cost of labor is reduced, reduces the limitation of the conditions such as working time place;Reduce in data cutting/scripting editing
Manual errors, reduce risk.
Brief description of the drawings
It is incorporated into specification and the attached drawing of a part for constitution instruction shows the embodiment of the present invention, and with
Description is used to explain the principle of the present invention together.In the drawings, similar reference numeral is used to represent similar key element.Under
Attached drawing in the description of face is some embodiments of the present invention, rather than whole embodiments.Come for those of ordinary skill in the art
Say, without creative efforts, other attached drawings can be obtained according to these attached drawings.
Fig. 1 is a kind of flow chart of distributed performance test method provided in an embodiment of the present invention;
Fig. 2 is the flow chart of another distributed performance test method provided in an embodiment of the present invention;
Fig. 3 is a kind of structure diagram of distributed performance test device provided in an embodiment of the present invention.
Embodiment
To make the purpose, technical scheme and advantage of the embodiment of the present invention clearer, below in conjunction with the embodiment of the present invention
In attached drawing, the technical solution in the embodiment of the present invention is clearly and completely described, it is clear that described embodiment is
Part of the embodiment of the present invention, instead of all the embodiments.Based on the embodiments of the present invention, those of ordinary skill in the art
All other embodiments obtained without making creative work, belong to the scope of protection of the invention.Need
Illustrate, in the case where there is no conflict, the feature in embodiment and embodiment in the application can be mutually combined.
Distributed performance test method, device and the computer that implementation that the invention will now be described in detail with reference to the accompanying drawings is related to
Readable storage medium storing program for executing.
Embodiment one:
It is shown in Figure 1, a kind of distributed performance test method, including:
First, information is distributed according to the node to prestore, parsing is obtained respectively from the configuration information of server, the configuration information
Including network address and respectively from the number of nodes of server-assignment;
Secondly, total test data is split respectively from the configuration information of server according to described, obtains each node and correspond to
Sub- test data, and the data referencing in test script is replaced with into the corresponding sub- test data of each node, establishes each node
Corresponding test script;Test program, the corresponding sub- test data of each node and test script are pushed to each from server
Node;
Wherein, it is described test program, the corresponding sub- test data of each node and test script are pushed to it is each from service
The step of node of device, can specifically include:
It is described to copy test program to each node from server;
The file of the corresponding node identification is configured to the test program of each node;
By the corresponding sub- test data of each node and the corresponding node of test script push.
Again, according to test assignment, the corresponding command respectively is sent from the node of server to described, task is performed by each node
And execution result back.
Specifically, described that total test data is split, the step of obtaining each node corresponding sub- test data, may be used also
With including:Corresponding node identification is configured to each sub- test data.The data referencing by test script replaces with each section
The step of point corresponding sub- test data, can also include:The corresponding node mark is configured to the corresponding test script of each node
Know.
In addition, can be respectively stored in a global array from the configuration information of server, each value of array represents one
A configuration information from server.
Through this embodiment, a test assignment can be split automatically and is synchronously carried out in multiple nodes, met big concurrent
The test scene demand of amount;Cost of labor is reduced, reduces the limitation of the conditions such as working time place;Data cutting/script is reduced to compile
Manual errors in volume, reduce risk.
Embodiment two:
It is shown in Figure 2, a kind of distributed performance test method, including:
Step 201:Split test data file;
Specifically:Node distribution information is stored in one file, and shell scripts read this file, are protected after parsing
There are in a global array.Each value of array represents the configuration information of a server, the node comprising IP and distribution
Number, while calculate how many a nodes altogether.Then we averagely split into test data more parts, and are adding one below respectively
A mark, this mark are represented to which node uses.
Step 203:Replacement test script;
Specifically:The XML node for all quoting test data file is searched for using xmlstarlet, by the test number of reference
It is stored according to filename in an array.File array is traveled through, corresponding data referencing is replaced in Jmeter test scripts, will
It is substituted for the test data file after being split in last step, saves as multiple test script copies respectively, and respectively rear
An additional mark (mark is corresponded with the test data file in last step), this mark is represented to which node makes
With.
Step 205:Dispose pressure node;
Specifically:Traverse node distributes the global array of information, is respectively copied local Jmeter programs using scp orders
Shellfish adds folder name one mark under the node of each server, this mark is torn open with above test data file
Divide, the mark in test script replacement corresponds.
Step 207:Push test script;
Specifically:Traverse node distributes the global array of information, using scp orders respectively by the test script pair after editor
Originally the test data file after, splitting is distributed to below each node
Step 209:Manage control node;
Specifically:When performing test assignment, the whole node arrays of script traversal, corresponding order is sent by ssh orders,
Each node is controlled respectively (startup/stopping);After program starts successfully, occur in each server thread corresponding
The information of Jmeter nodes, whether we can be inquired about and filtered by orders such as ps, grep succeeds to judge to start.Lead at the same time
Peculiar information in Jmeter threads is crossed, carrys out the state of oracle listener operation.These can pass through shell on main control server
Script is realized.
Step 211:Collect result, statistics is drawn;
Specifically:When each node performs test, the initial data of test result is stored in a mesh specified respectively
Under record.After the completion of whole node tests, recalled from main control server by these results.Then these are counted using shell scripts
According to merging, the plug-in unit of Jmeter is called to carry out analytic statistics to these data, and draw.The summary data of test is stored in one
In csv file, file and chart are maintained under a distinctive catalogue.
Step 213:Write test report;
Specifically:Java script scripts are write, are opened up being loaded into after the csv file parsing after statistics in html template
Show, while the chart of drafting also loaded and is presented to tester in a template and checks.
The present embodiment, will by the demand of script automatic identification test environment by self-defined setting test environment
Jmeter program distributions are to the server specified;Test data script is split automatically, the automatic search key of test script, and is replaced
Change the reference of data file;It is controllable in real time in test assignment implementation procedure, operating status is reported at any time;Test result is returned automatically
Fold simultaneously, then count test result, and export readable test report directly perceived.
Embodiment three:
It is shown in Figure 3, a kind of distributed performance test device, including:
Resolution unit, for distributing information according to the node to prestore, parsing is obtained respectively from the configuration information of server, described
Configuration information includes network address and respectively from the number of nodes of server-assignment;
Dispensing unit, for being split according to described respectively from the configuration information of server to total test data, obtains each
The corresponding sub- test data of node, and the data referencing in test script is replaced with into the corresponding sub- test data of each node, build
Found the corresponding test script of each node;Test program, the corresponding sub- test data of each node and test script are pushed to each
From the node of server;
Unit of testing and controlling, according to test assignment, respectively sends the corresponding command, by each node to described from the node of server
Execution task and execution result back.
During concrete operations, the node uses the XML node of XML format for test script;
The dispensing unit, including xmlstarlet instruments, the XML sections of test data file are all quoted for searching for
Point, the test data file name of reference is stored in an array, obtains file array;File array is traveled through, and performs institute
State the step of data referencing in test script is replaced with into each node corresponding sub- test data.
Preferably, the distributed performance test device further includes:Data processing unit, for utilizing shell scripts
Feedback result is merged, calls the plug-in unit of Jmeter to carry out analytic statistics to feedback result, and draw.
Preferably, the distributed performance test device further includes:Display unit, the summary data for test result
It is stored in a csv file, writes java script scripts, will adds after the csv file parsing after the chart of drafting and statistics
It is downloaded in html template and shows.
The principle and the course of work of above-mentioned distributed performance test device are summarized as follows:It uses the shell of Linux platform
Script is realized.Shell scripts are easy to use, are adapted to the object of processing file and catalogue etc, can be quick with simple mode
Handle some very complicated things.We utilize the flexibility of shell, carry out implementation with reference to the small tool under Linux platform
It is intended to.
First, in view of the test script of Jmeter is the file of XML format, we realize foot using xmlstarlet instruments
This editor.It is complete and the instrument such as the fractionation of data file, wc, head, tail that Linux platform carries can be combined flexibly
Into task.
Secondly, the task such as copy/distribution for file, Linux platform has opened SSH services, we can use
Scp realizes the deployment of test environment, and the distribution of test plan script and test data file.Control of the client to each node
Make (startup/stopping/monitoring), we still service by SSH, and related command is sent to each node, realize and Jmeter is saved
The management of point.
Finally, we complete writing for the collection of result and test report by the plug-in unit of Jmeter.This is a set of only
Stand on Apache Jmeter, there is provided the set of insert of self-definedization.It has outstanding drawing, and load mode, additionally provides more
Abundant function library.We combine shell scripts, quote the jar bags of plug-in unit, the result data being collected into is integrated, system
Count and draw, be finally again presented the file after statistics inside a Templated html file.
The present embodiment whole process no manual intervention, can reduce labor intensity, save artificial and time cost, avoid at the same time
The operating irregularity that manual editing introduces;Multiple Jmeter examples can be run on one server, substantially reduce test environment
Demand;Each Jmeter examples independent operating, no data is synchronous during test run, and each node flattening, avoids
Jmeter clients under multiple remote node scenes, overhead overload the problem of, reduce the contaminated wind of test result
Danger.
The present invention also provides a kind of computer-readable recording medium, computer program is stored thereon with, which is processed
Device distributed performance test method above-mentioned when performing.It has the corresponding technique effect of the test method, and details are not described herein.
It will appreciated by the skilled person that realize all or part of step/units/modules of above-described embodiment
It can be completed by the relevant hardware of programmed instruction, foregoing routine can be stored in computer read/write memory medium, should
Upon execution, perform includes step corresponding in above-described embodiment each unit to program;And foregoing storage medium includes:ROM、
RAM, magnetic disc or laser disc etc. are various can be with the medium of store program codes.
Particular embodiments described above, has carried out the purpose of the present invention, technical solution and beneficial effect further in detail
Describe in detail it is bright, it should be understood that the foregoing is merely the present invention specific embodiment, be not intended to limit the invention, it is all
Within the spirit and principles in the present invention, any modification, equivalent substitution, improvement and etc. done, should be included in the guarantor of the present invention
Within the scope of shield.