A kind of database communication network test simulation method and device
[technical field]
The present invention relates to software testing technology field, a kind of database communication network test simulation method and dress are provided
It sets.
[background technique]
Database is the important component of information system, has very high requirement to the reliability of system, it would be desirable to be able to
After various faults occur, detects automatically and realize failure tolerant.For guarantee database High Availabitity characteristic, in data base administration system
Unite the design of software, exploitation, in test process, it is necessary to simulation test is carried out to various faults, to verify design and implementation
Correctness.
The source of the system failure is varied, and network communication failure is very common one kind, such as network interruption, network
The failures such as flash, Network Packet Loss, network delay, bandwidth shakiness.Current failure simulation method is usually in source equipment or purpose
It is carried out in end equipment, strongly limits the failure mode that can be simulated, simulation means are single, and low efficiency: certainly such as operating system
The tc tool of band, can not analog network interrupt, situations such as bandwidth is unstable;Traditional iptable service for another example, can not simulate
The failures such as packet loss.Meanwhile the computer operating system of traditional this failure simulation method and source or destination is closely related,
It is unfavorable for the development of test automation work.
In consideration of it, overcoming defect present in the above-mentioned prior art is the art urgent problem to be solved.
[summary of the invention]
The technical problem to be solved in the invention is:
In the simulation of network communication failure, traditional analog means are single and low efficiency, are typically only capable to simulation specific type
Network failure, can not simulate a plurality of types of network failures and complexity network failure combine analog, it is difficult to meet data
The simulation of network failure needed for library test requires.
The present invention reaches above-mentioned purpose by following technical solution:
In a first aspect, the present invention provides a kind of database communication network test simulation methods, comprising:
Work out expected test simulation plan, the test simulation specify in the works the various faults type wishing to simulate with
And the corresponding simulation order of each fault type, the scheduling frequency and one or more in the duration;
The test simulation plan is read and parsed by test simulator, and specified according to the test simulation plan
Simulation order, the scheduling frequency and duration, successively switching carries out the simulation of each fault type;
Wherein, the various faults type includes that network delay, Network Packet Loss, low bandwidth, bandwidth be unstable, network interruption
With it is one or more in network flash.
Preferably, the test simulation also specified load testing to server-side in the works, then the method also includes:
According to the test simulation plan, the test simulator sends access request to server-side;Wherein, the visit
Ask that request includes first kind access and the access of the second class;
After server-side responds first kind access and the access of the second class, server-side calculates itself resource occupation at this time
Rate, and the resources occupation rate is fed back into the test simulator;
The test simulator according to the resources occupation rate of acquisition, adjust next access request quantity and its
In two classes access pro rate, so as to continue to server-side send carry out load testing;
Wherein n times resources occupation rate reaches corresponding n times access request when preset threshold to statistics, and is asked according to each access
The pro rate that two classes access in asking obtains the proportion matched curve of two classes access;Wherein, N is the natural number greater than 3.
Preferably, when the test simulator sends access request to server-side every time, the access request is with single
Concurrent fashion is sent to server-side, or the concurrent mode of substep is sent to server-side in history for simulation;Wherein, when using substep
When concurrent mode, the resources occupation rate is that server-side responds each resources occupation rate being calculated after each access request
Peak value and/or average value.
Preferably, after server-side makes a response access request, the test simulator receives response and to service
Make feedback in end;If the access request is sent to server-side in the concurrent mode of substep, every is visited for server-side
Ask the response of request, the test simulator is made certain time-delay after receipt of a response and fed back again;
Wherein, the corresponding time parameter of the delay is the history with value obtains in history delay section at random
Delay section is determined according to the respective access request delay time of two classes of historical statistics access respectively.
Preferably, the load testing process carries out on line or under line, when carrying out on line, according to different negative on line
The timing node where characteristic is carried, different testing time points is set;The test simulator is according to demand in corresponding survey
Try time point progress load testing.
Preferably, the test simulator includes A cache module and B cache module, and the test simulator passes through
The A cache module and tested client, which are realized, to be connected to the network, and is realized by the B cache module and tested server-side
Network connection;
When the fault type is network delay, and transmits data to server-side from client, the method for fault simulation
Specifically: by the data in the A cache module, as unit of client transmissions data packet length, with specified delay time t into
Row waits operation;After waiting operation to reach t, this data packet is transferred to the B cache module, then mould is cached by the B
Block is forwarded to server-side;
When the fault type is Network Packet Loss, and transmits data to server-side from client, the method for fault simulation
Specifically: it is required, the data in the A cache module is intercepted, and extremely by the data conversion storage intercepted out according to packet loss
The B cache module, then forwarded from the B cache module to server-side.
Preferably, when the fault type is low bandwidth, and transmits data to server-side from client, fault simulation
Method specifically: using the preset ratio of nominated bandwidth value as single transmission size, respectively by the data packet of single transmission size from
The A cache module copies to the B cache module, then is forwarded from the B cache module to server-side;Wherein, in each list
Between secondary data packet replication operation, it is inserted into the dormancy time of preset duration, carries out next single data cladding after the completion of suspend mode again
System operation;
When the fault type is unstable for bandwidth, and transmits data to server-side from client, the side of fault simulation
Method specifically: as unit of single client data packet, according to being each number clients within the scope of specified bandwidth upper lower limit value
Respective transmission bandwidth is provided according to packet, each data packet is copied into the B cache module from the A cache module respectively, then
It is forwarded from the B cache module to server-side.
Preferably, when the fault type is network interruption, the method for fault simulation specifically: according to network interruption mould
Pseudoinstruction A closes the web socket of the test simulator and server-side foundation;Alternatively, being referred to according to network interruption simulation
B is enabled, any data unconditional that the A cache module and the B cache module are received abandons;Wherein, A pairs of dummy instruction
The network interruption answered can be perceived in server-side, and the corresponding network interruption of dummy instruction B can not be perceived in server-side;
When the fault type is network flash, the method for fault simulation specifically: frequency is occurred according to the flash of offer
Rate executes closing and opening operation to the operating system network interface of the test simulator with given frequency.
Second aspect, the present invention also provides a kind of database communication network test simulators, for completing above-mentioned
Database communication network test simulation method described in one side, tested between database service end and tested client
It is inserted into test simulator, the test simulator includes main control module 1, execution module 2, A cache module 3 and B caching mould
Block 4, the main control module 1 are connect with the execution module 2, and the execution module 2 passes through the A cache module 3 and client
Realize network connection, the execution module 2 is realized with server-side by the B cache module 4 and is connected to the network;
The main control module 1 is used to read and parse the test simulation plan of input, and issues event to the execution module 2
Barrier simulation request;The execution module 2 according to fault simulation for requesting, and successively switching carries out the simulation of various faults type;
Wherein, the specified various faults type for wishing to simulate of the test simulation plan and the corresponding mould of each fault type
Quasi- sequence, the scheduling frequency and one or more in the duration, the various faults type include that network delay, network are lost
Packet, low bandwidth, bandwidth be unstable, one or more in network interruption and network flash.
Preferably, the A cache module 3 includes that A receives cache module 31 and A transmission cache module 32, and the B caches mould
Block 4 includes that B receives cache module 41 and B transmission cache module 42;Number in the A cache module 3 and the B cache module 4
According to being operated by the execution module 2;
Wherein, the data that client is sent to server-side are received the reception of cache module 31 by the A and are kept in, and hold to described
The processing of row module 2;The data that server-side is sent to client are received the reception of cache module 41 by the B and are kept in, and hold to described
The processing of row module 2;
The execution module 2 writes direct the data of the A cache module 3, sends cache module 32 by the A and keeps in,
And to the execution module 2 processing;The execution module 2 writes direct the data of the B cache module 4, is sent by the B slow
Storing module 42 is temporary, and to the execution module 2 processing.
Compared with prior art, the beneficial effects of the present invention are: the present invention can the event of the network according to needed for data library test
Barrier simulation requires, and customized test simulation plan is neatly worked out, at tested database service end and tested client
Between be inserted into test simulator, and then test simulator can be made to realize automation, a variety of nets according to test simulation plan
The combine analog of network failure being capable of more efficient, accurately analog network failure without operating hardware device.Meanwhile test simulation
Device can also complete the load testing to server-side according to test simulation plan, thus there is the resource of server when being practical application
Effect distributes and using foundation is provided, improves the resource utilization of server.
[Detailed description of the invention]
In order to illustrate the technical solution of the embodiments of the present invention more clearly, will make below to required in the embodiment of the present invention
Attached drawing is briefly described.It should be evident that drawings described below is only some embodiments of the present invention, for
For those of ordinary skill in the art, without creative efforts, it can also be obtained according to these attached drawings other
Attached drawing.
Fig. 1 is a kind of architecture diagram of database communication network test simulator provided in an embodiment of the present invention;
Fig. 2 is a kind of flow chart of database communication network failure simulation method provided in an embodiment of the present invention;
Fig. 3 is a kind of flow chart of database communication network load test approach provided in an embodiment of the present invention.
[specific embodiment]
In order to make the objectives, technical solutions, and advantages of the present invention clearer, with reference to the accompanying drawings and embodiments, right
The present invention is further elaborated.It should be appreciated that the specific embodiments described herein are merely illustrative of the present invention, and
It is not used in the restriction present invention.
In various embodiments of the present invention, symbol "/" indicate simultaneously tool there are two types of function meaning, and for symbol " A with/
Or B " then shows that the combination between the front and back object connected by the symbol includes " A ", " B ", " A and B " three kinds of situations.
In addition, as long as technical characteristic involved in the various embodiments of the present invention described below is each other not
Constituting conflict can be combined with each other.Just with reference to drawings and examples, in conjunction with coming, the present invention will be described in detail below.
Embodiment 1:
The embodiment of the invention provides a kind of database communication network test simulators, as shown in Figure 1, the test mould
Quasi- device is connected between tested database service end and tested client, and then can be realized between client and server-side
The simulation of various faults type that may be present.The test simulator includes main control module 1, execution module 2, A caching mould
Block 3 and B cache module 4, the main control module 1 are connect with the execution module 2, and the execution module 2 caches mould by the A
Block 3 and client, which are realized, to be connected to the network, and the execution module 2 is realized with server-side by the B cache module 4 and is connected to the network.
When using the test simulator, tester is in advance with descriptive scripting language (such as XML, JSON) volume
Make expected test simulation plan, and the input as the test simulator;The test simulation plan is specified to wish mould
Quasi- various faults type and the corresponding simulation order of each fault type, the scheduling frequency and one or more in the duration
?.The main control module 1 is used to read and parse the test simulation plan of input, and according to the specified of the test simulation plan
Content issues fault simulation request to the execution module 2;The execution module 2 is successively cut for being requested according to fault simulation
The simulation of swap-in row various faults type.Wherein, the various faults type can be network delay, Network Packet Loss, low bandwidth,
The network failures such as bandwidth is unstable, network interruption and network flash.When carrying out fault simulation, client is as source, service
It holds as a purpose at end;And/or server-side, as source, client is held as a purpose;Therefore, the test simulator
Unidirectional network failure is simulated, also analog bilateral network failure.
Wherein, the execution module 2 before carrying out fault simulation, need to first confirm visitor after getting fault simulation request
Network connection between family end and server-side: network connection of the client to server-side is taken over via A cache module 3, server-side
Network connection to client is taken over via B cache module 4, is only succeeded by the survey when client and server-side are bi-directionally connected
After trying simulator adapter tube, just has the precondition of fault simulation.
It continues to refer to figure 1, the A cache module 3 includes that A receives cache module 31 and A transmission cache module 32, the B
Cache module 4 includes that B receives cache module 41 and B transmission cache module 42.When carrying out fault simulation, it is all from client to
The data that server-side is sent are received the reception of cache module 31 by the A and are kept in, to the execution module 2 processing;Similarly,
All data sent from server-side to client are received the reception of cache module 41 by the B and are kept in, to the execution module
2 processing.Meanwhile all data that the A cache module 3 is write direct by the execution module 2, it is sent and is cached by the A
Module 32 is temporary, and to the execution module 2 processing;It is all that the B cache module 4 is write direct by the execution module 2
Data should all send cache module 42 by the B and keep in, and to the execution module 2 processing.It should be noted that in the A
The data kept in cache module 3 and the B cache module 4, can only be operated, for example realize by the execution module 2
The operations such as forwarding, modification, duplication, discarding, remaining module or component cannot operate the data in two cache modules.
It is inserted into test simulator between database service end and tested client tested in the embodiment of the present invention,
Two cache modules are arranged in test device can intercept respectively and keep in the data that client and server-side are sent, according to establishment
Test simulation plan, execution module carries out corresponding operating to the data in cache module again, and then can realize multiple network failure
Simulation or combine analog, can more efficient, accurately analog network failure.
In conjunction with the embodiment of the present invention, there is also a kind of preferred implementations, also refer in the works in the test simulation of establishment
The fixed load testing content to server-side, then the test simulator can also be used to survey the load requirement of server
Examination.Wherein, the execution module 2, which is used to send access request after server-side responds access request to server-side, can calculate itself
Resources occupation rate and feed back to the main control module 1, the main control module 1 is used for according to the resource occupation of server-side
Rate adjusts the quantity and the wherein pro rate of different type access of next access request, so as to make the execution module 2 by
According to adjusted as a result, continuing to send access request progress load testing to server-side, until making the resource occupation of server-side
Rate reaches preset threshold.By n times access request corresponding when counting that wherein n times resources occupation rate reaches preset threshold, can obtain
The proportion matched curve accessed to different type;Wherein, N is the natural number greater than 3.Detailed process can refer to embodiment 3, herein
It repeats no more.
In above-mentioned preferred embodiment, by the also achievable load testing to server-side of test simulator, actually to answer
It is effectively distributed with the resource of server in environment and using foundation is provided, further improves the resource utilization of server.
Embodiment 2:
On the basis of above-described embodiment 1, the embodiment of the invention also provides a kind of database communication network test simulations
Method can be used the test simulator in embodiment 1 to realize, may deposit for realizing between client and server-side
Various faults type simulation.As shown in Fig. 2, specifically includes the following steps:
Step 201, the expected test simulation plan of establishment, the test simulation specify a variety of events for wishing to simulate in the works
Hinder type and the corresponding simulation order of each fault type, the scheduling frequency and one or more in the duration.
Wherein, the test simulation plan can neatly be configured according to different demands, by tester to describe
Property scripting language (such as XML, JSON) customized establishment, and the input as the test simulator;The class of the failure
Type can be unstable network delay, Network Packet Loss, low bandwidth, bandwidth, network interruption and network flash etc..For example, the survey
Examination simulation game specifically may specify that fault simulation is as follows: the first step, generates a network interruption, continues to restore after five minutes;Second
Step, interval generated the network delay for continuing 10 minutes after 25 minutes, and specifying delay time is 1000 milliseconds;Third step generates
1000 network interruptions interrupt continue 1 minute every time;4th step, generation Network Packet Loss failure, the duration 10 minutes, during which
Packet loss 30% ....It follows that the test simulation in the works, not only may specify various faults type, also to a variety of
Fault type has carried out any combination, and the complicated multiplicity of situation can more accurately simulate the complex network in actual motion environment
Fault condition.
Step 202, it is read by test simulator and parses the test simulation plan, and according to the test simulation
The specified simulation order of plan, the scheduling frequency and duration, successively switching carries out the simulation of each fault type.
Firstly, the main control module 1 reads and parses the test simulation plan of input, and according to the test simulation
The specified various faults type of plan and the corresponding simulation order of each fault type, the scheduling frequency and duration, to described
Execution module 2 issues fault simulation request;Then, the execution module 2 obtains fault simulation request, and is asked according to fault simulation
Successively switching is asked to carry out the simulation of various faults type.
For example, according to the example of the test simulation plan provided in the step 201, it is assumed that start to carry out this in 9:00
Fault simulation, then after the execution module 2 obtains fault simulation request, simulation process specifically: 9:00 starts simulation and generates one
A network interruption failure, interruption continue to restore after five minutes;During 9:30 assigns to 9:40, simulation generates network delay failure, delay
Reach 1000 milliseconds;Hereafter generation network interruption failure 1000 times is simulated again, interrupts continue 1 minute every time;It simulates and holds again later
Row Network Packet Loss failure, the duration 10 minutes, during which packet loss 30% ....According to the test simulation wanting in the works
It asks, the test simulator can be switched over neatly between different types of fault simulation, until completing entire test
Simulation game.
Wherein, the execution module 2 before practical progress fault simulation, needs first true after getting fault simulation request
Recognize the network connection between client and server-side: network connection of the client to server-side is taken over via A cache module 3, clothes
Network connection of the business end to client is taken over via B cache module 4, is only succeeded by institute when client and server-side are bi-directionally connected
After stating test simulator adapter tube, just has the precondition of fault simulation.
It, can be according to needed for data library test in database communication network test simulation method provided in an embodiment of the present invention
Network failure simulation requires, and neatly customized establishment test simulation plan, test simulator can be according to test simulation plans
Combine analog that realize automation, multiple network failure being capable of more efficient, accurate simulation net without operating hardware device
Network failure.
Wherein, for various types of network failure, the execution module 2 can realize event according to following logic respectively
Barrier simulation:
A. network delay
When the fault type is network delay, and transmits data to server-side from client, the method for fault simulation
Specifically: the data in the A cache module 3 (specially A receives cache module 31), the execution are temporarily stored in for client
Module 2 carries out waiting operation as unit of client transmissions data packet length, with specified delay time t;Operation is waited to reach t
Afterwards, this data packet is transferred in the B cache module 4 (specially B sends cache module 42) by the execution module 2,
It is forwarded again from the B cache module 4 to server-side;After the completion of forwarding, the execution module 2 is respectively from 3 He of A cache module
Corresponding network packet is deleted in the B cache module 4, to complete cleaning work.
Wherein, delay time t can be determined by way of generating between the random number in specified range, such as specified
Range is between delay 1 second to 3 seconds, then t can be selected as 2 seconds at random.
The above method is network delay fault simulation when transmitting data to server-side from client, and bilateral network is prolonged
Slow failure, the execution module 2 are being handled server-side to when the transmission of the data of client, it is slow that B are handled using identical logic
Data in storing module 4 (specially B receives cache module 41), details are not described herein again.
B. Network Packet Loss
When the fault type is Network Packet Loss, and transmits data to server-side from client, the method for fault simulation
Specifically: the data in the A cache module 3 (specially A receives cache module 31), the execution are temporarily stored in for client
Module 2 requires to carry out data cutout according to specified packet loss, and only by the data conversion storage intercepted out to the B cache module 4
In (specially B send cache module 42), then forwarded from the B cache module 4 to server-side;After the completion of forwarding, the execution
Module 2 deletes corresponding network packet from the A cache module 3 and the B cache module 4 respectively, to complete fettler
Make.
Wherein, it when data intercept, as unit of network protocol packet size, is cut in the data packet of client transmissions
It takes;For example tcp agreement, the packet size that can be handled can be obtained by the software-hardware configuration information (such as MTU size) in running environment,
If the size of the data packet of client transmissions is less than the size of protocol package, the plan that intercepted length halves several times can be taken
Slightly, until interception size is less than the size of the data packet of client transmissions.
For packet loss index, user can provide in the works packet loss requirement in the test simulation, by the master control mould
Block 1 calculates the product of total packet number and packet loss in the A cache module 3, obtains absolute packet loss number, and according to the number to institute
State the Network Packet Loss fault simulation request that execution module 2 issues same number.
The above method is Network Packet Loss fault simulation when transmitting data to server-side from client, and bilateral network is lost
Packet, the execution module 2 are being handled server-side to when the transmission of the data of client, B caching mould are handled using identical logic
Data in block 4 (specially B receives cache module 41), details are not described herein again.
C. network low bandwidth
When the fault type is low bandwidth, and transmits data to server-side from client, the method tool of fault simulation
Body are as follows: nominated bandwidth value of the main control module 1 by the test simulation in the works is passed with the instruction of low bandwidth fault simulation
Pass the execution module 2;The execution module 2 is using the preset ratio of nominated bandwidth value as single transmission size, by the master
The data packet of single transmission size is copied to the B cache module 4 from the A cache module 3 respectively by control module 1, then by institute
It states execution module 2 and forwards the data in the B cache module 4 to server-side.Wherein, speed control is to rely on data from institute
Duplication of the A cache module 3 to the B cache module 4 is stated, therefore reaches low bandwidth for control, is needed in each single data packet
It is inserted into the dormancy time of preset duration between duplication operation, carries out next single data packet replication operation after the completion of suspend mode again.
For example, specified bandwidth value is 1000KB/S, the preset ratio takes 1/10, and the preset duration of the suspend mode is
90ms, then with the 1/10 of nominated bandwidth value 1000 for single transmission size when simulating, i.e., the data packet transmitted every time is 100KB,
After every time copying to corresponding 100KB data packet in the B cache module 4 from the A cache module 3, after suspend mode 90ms
The execution module 2 again forwards the data in the B cache module 4 to server-side, and then carries out next single data packet again
Duplication operation.
The above method is low bandwidth fault simulation when transmitting data to server-side from client, for two-way low bandwidth,
The execution module 2 is handling server-side to when the transmission of the data of client, and B cache module 4 is handled using identical logic
In data, details are not described herein again.
D. network bandwidth is unstable
When the fault type is unstable for bandwidth, and transmits data to server-side from client, the side of fault simulation
Method specifically: bandwidth upper lower limit value of the main control module 1 by the test simulation in the works is simulated with bandwidth jitterbug
Instruction passes to the execution module 2 together;The execution module 2 is as unit of single client data packet, in specified band
Respective transmission bandwidth is provided for each client data packet within the scope of wide upper lower limit value, it respectively will be every by the main control module 1
A data packet copies to the B cache module 4 from the A cache module 3, then by the execution module 2 by the B cache module
Data in 4 are forwarded to server-side.
Unstable for two-way bandwidth, the execution module 2 is handling server-side to when the transmission of the data of client, uses
Identical logic handles the data in B cache module 4, and details are not described herein again.
E. network interruption
When the fault type is network interruption, the method for fault simulation specifically: net is issued by the main control module 1
Network break simulation instructs A to the execution module 2, and the execution module closes what the test simulator was established with server-side
Web socket;Wherein, the network interruption of the corresponding simulation of dummy instruction A can be perceived in server-side.
It is often that server end can not perceive immediately there are also a large amount of network interruptions, such as in real system operational process
Situations such as intermediary switch is offline.The network interface electric appliance feature of server end itself does not change at this time, only data without
Method sends or receives, therefore to the method for such network break simulation specifically: issues network interruption mould by the main control module 1
After pseudoinstruction B gives the execution module 2, the execution module 2 to receive network interruption dummy instruction B, by the A cache module 3
It is abandoned with any data unconditional that the B cache module 4 receives, and then completes the simulation of the type network interruption.Wherein,
The network interruption of the corresponding simulation of dummy instruction B can not be perceived immediately in server-side.
F. network flash
When the fault type is network flash, the method for fault simulation specifically: the main control module 1 issues simulation
The instruction of network flash provides flash occurrence frequency to the execution module 2 simultaneously;According to the flash occurrence frequency of offer,
The execution module 2 is executed with given frequency to the operating system network interface of the test simulator and closes and open behaviour
Make.
It is above the specific implementation procedure of several different types of fault simulations provided in an embodiment of the present invention, master control mould
Block can parse the various instructions of the test simulation in the works, and be transmitted to execution module, execution module so that can according to schedule in
Instruction requirement, complete the combine analog of various fault types.
Embodiment 3:
On the basis of above-described embodiment 1 and embodiment 2, the embodiment of the invention also provides a kind of database communication networks
The test simulator in embodiment 1 can be used still to realize in test simulation method, and the test simulation also refers in the works
The fixed load testing to server-side, the method for the embodiment of the present invention are the load testing for realizing server-side access request.
As shown in figure 3, specifically includes the following steps:
Step 301, according to the test simulation plan, the test simulator sends access request to server-side.
Wherein, the access request includes first kind access and the access of the second class, for example, first kind access can be web page class
Access, i.e., request access to webpage to server-side;The access of second class can be payment class access, i.e., carry out payment purchase to server-side request
The access bought.It, can be according to history after the main control module 1 obtains and parses the load testing instruction of the test simulation in the works
The data of access are arranged or automatically configure initial access request total quantity and the wherein pro rate of two classes access, and transmit
To the execution module 2, the access request of corresponding number and proportion is sent from the execution module 2 to server-side.For example, initial
It is 10000 that access request total quantity, which is arranged, and it is 1:1 that two classes, which access pro rate, then the execution module 2 is sent to server-side
5000 web page class access requests and 5000 payment class access requests.
Step 302, after server-side responds first kind access and the access of the second class, server-side calculates itself money at this time
Source occupancy, and the resources occupation rate is fed back into the test simulator.For example, server-side can calculate in step 301
10000 access requests sent and then feed back to the main control module 1 in the resources occupation rate of server-side.
Step 303, the test simulator adjusts the number of next access request according to the resources occupation rate of acquisition
Amount and the wherein pro rate of two classes access carry out load testing to continue to send to server-side.
The main control module 1 receives the resources occupation rate that server-side is fed back to, for example takes when 10000 access requests of transmission
The resources occupation rate at business end is 50%, then the quantity that the main control module 1 adjusts next access request accordingly, which can suitably increase, is
15000, wherein the pro rate of two classes access also adjusts accordingly simultaneously;The main control module 1 will access after adjustment
The information of request passes to the execution module 2, is continued to send access request, constantly weight to server-side from the execution module 2
Multiple circulation step 301- step 303, i.e., constantly repeat the process of " transmission-is adjusted-retransmited ", until making the resource of server-side
Occupancy reaches preset threshold, then it is assumed that access request at this time more fully occupies the space resources of server-side.
In actual working environment, server-side can realize operation at full load, but preferably be reserved with certain space, then preset threshold herein
It can be set as 80%-100%.
Step 304, wherein n times resources occupation rate reaches corresponding n times access request when preset threshold to statistics, and according to every
The pro rate that two classes access in secondary access request obtains the proportion matched curve of two classes access.
During above-mentioned constantly " transmission-is adjusted-retransmited ", can exist and repeatedly server-side resources occupation rate be reached
To the combined situation of preset threshold, for example, sending 10000 web page class accesses+5000 access of payment class, 8000 web page class
When+6000 payment class access of access and 11000 web page class access+3500 payment class access etc., having can
Resources occupation rate can be made to reach preset threshold, the main control module 1 asks two classes access corresponding when reaching preset threshold every time
The pro rate asked is recorded.It is to be recorded reach n times after, the main control module 1 can be according in wherein each access request
The pro rate of two classes access obtains the proportion matched curve of two classes access, and N is the natural number greater than 3 herein.Wherein, the number of N
Amount is bigger, and the reference point of selection is more, and obtained matched curve is also more accurate, and application value is also bigger.
For example, to pay class access request as ordinate, obtaining the access of two classes using web page class access request as abscissa and asking
The matched curve asked.It will be apparent that in the available space resource of same server-side, the quantity of the web page class access request responded
More, the quantity for paying class access request is also fewer, therefore the slope of obtained matched curve is negative.For under cloud environment
Multiple server-sides carry out load testing respectively, then each server-side is corresponding with a matched curve.When the proportion of two classes access is
When 1:1, slope is -1;When web page class access request is more than payment class access request, slope is greater than -1, and slope is bigger, curve
More " flat ", the corresponding server-side of such curve are more suitable for responding web page class access request;When payment class access request is more than net
When page class access request, slope is less than -1, and slope is smaller, and curve gets over " steep ", and the corresponding server-side of such curve is more suitable for responding
Pay class access request.
It is corresponding according to each server-side when in actual environment in view of the above-mentioned load test results to each server-side
Matched curve, two class access request task of reasonable distribution, to improve the resource utilization of each server.Wherein, work as reality
When web page class access request is more than payment class access request in access request, corresponding clothes of the matched curve slope greater than -1 may be selected
Business end accesses;Conversely, corresponding with service end of the matched curve slope less than -1 is then selected to access.Meanwhile it also needing to consider
The current space available resource of the server-side of selection need to select multiple server-sides, then if current space available resource is smaller
The reasonable distribution of actual access request is carried out between multiple server-sides;Alternatively, a server-side can also first be selected to access, to
After the server-side space resources is all occupied, it is further continued for that next suitable server-side is selected to access.
In database communication network test simulation method provided in an embodiment of the present invention, also when working out test simulation plan
The load testing content to server-side is added, then test simulator can also be completed according to test simulation plan to multiple server-sides
Load testing, obtain matched curve corresponding with each server-side, be practical application when server resource effectively distribute with
Using foundation is provided, to improve the resource utilization of each server.
Wherein, in the step 301, when the execution module 2 sends access request to server-side every time, the access
Request is sent to server-side with single concurrent fashion, or the concurrent mode of substep is sent to server-side in history for simulation.For example,
The execution module 2 receives the instruction of " sending 10000 access requests ", can be disposable by all 10000 access requests
It is sent to server-side, i.e. single is concurrent;Several steps can also be divided gradually to send 10000, for example, with 500 for " step ", often
500 are sent every 1s, i.e., substep is concurrent.
For each access request, after server-side makes a response access request, the test simulator
It receives and responds and make feedback to server-side, it was demonstrated that test lead receives response, i.e. every access request has " execution module hair
Send-server-side response-test lead feed back " three steps.Wherein, after test lead feeds back this road step, server-side can be released
Put space resources corresponding with the access request.When therefore, by the way of concurrent using substep, asked to subsequent 500 access
It asks when being sent to server-side, the part access request of front may have been tested end and feed back, and release the part of server-side
Space resources, therefore the resources occupation rate that is calculated and when concurrent single, are different after being finally sent completely;At this point, the resource
Occupancy can choose the peak value and/or average value that server-side responds each resources occupation rate being calculated after every access request.
In conjunction with the embodiment of the present invention, there is also a kind of preferred implementations, if the access request is concurrent with substep
Mode be sent to server-side, then be directed to response of the server-side to every access request, the test simulator receiving
Make certain time-delay after response to feed back again.This is because in actual motion environment, for every access request, " server-side response "
And after test lead receives response, " test lead feedback " would generally postpone to carry out after a certain period of time, then in order to improve access request
Actual environment analog feature, and then the accuracy of finally obtained matched curve is improved, also to " test lead is anti-in the present embodiment
This road step of feedback " carries out certain delay.It wherein, the delay corresponding time, can be by random in history delay section
Middle value obtains, history delay section respectively according to the respective access request delay time of two classes of historical statistics access come
It determines.
For example, for web page class access request, after user first sends web-page requests, server-side response in actual motion
It returns to webpage and has been received by webpage to server-side feedback again to user, user, then can be received according to the multiple of historical statistics from user
Webpage makes the time between feedback to user, obtains a corresponding history delay section;Payment class access request is come
It says, user first sends payment request in actual motion, server-side is paid bank, bank and received again to server-side feedback after responding
To payment, then the time for paying to bank and making feedback can be received from bank according to the multiple of historical statistics, obtain one
Corresponding history delay section.By increasing delay setting, the simulated environment of load testing is closer with actual environment, improves
The analog feature of access request, the final accuracy for improving matched curve.
In embodiments of the present invention, the load testing process lower online can carry out, i.e., test in advance under offline environment;
It can also carry out, i.e., be tested in advance under the online real network environment of server on line.In conjunction with the embodiment of the present invention, there is also
A kind of preferred implementation, when carrying out on line, according to the timing node where different loads characteristic on line, setting is different
Testing time point;Load testing is carried out in corresponding testing time point according to demand.For example, the different moments in one day,
Access request quantity be it is continually changing at any time, the load characteristic of server-side is also different: user may be compared with when or so morning
Few, access is less, and the load of server-side is also smaller;And the morning or afternoon, user may be more, accesses more, the load of server-side
Also larger.Therefore, load testing can be carried out at the time of selecting corresponding, so as to mention according to the timing node demand of actual use
The actual environment analog feature of high access request, further increases the accuracy of final matched curve.
The foregoing is merely illustrative of the preferred embodiments of the present invention, is not intended to limit the invention, all in essence of the invention
Made any modifications, equivalent replacements, and improvements etc., should all be included in the protection scope of the present invention within mind and principle.