The method for testing pressure of a kind of interface and test equipmentTechnical field
The present invention relates to technical field of data processing, be specifically related to method for testing pressure and the test equipment of a kind of interface.
Background technology
Application backstage is generally based on RPC (Remote Procedure Call Protocol remote procedure call at presentAgreement) etc. Development Framework develop;RPC framework can provide the communication protocol between applications client and application backstage, theseCommunication protocol is defined generally by descriptive language;And the communication protocol that RPC framework can define based on descriptive language,Compiling generates corresponding serializing and the interface of antitone sequence;When carrying out applying background test, these interfaces are carried out pressure surveyExamination just seems particularly significant;Docking port carries out stress test and refers to the situation of the actually used process of analog interface, is surveyed by pressureExamination logic carrys out the indexs such as the performance of test interface, reliability, stability.
At present when docking port carries out stress test, tester, it is to be appreciated that the function of interface, even reads interfaceExploitation code, then on the basis of understanding interface function, writes the test case of interface;The stress test mode of this interfaceNeed tester that the Development Framework (such as RPC framework etc.) of application is familiar with, and be required to understand used by Development FrameworkCommunication protocol, the requirement for tester is higher;The most how to provide the method for testing pressure of a kind of simplicity so that testPersonnel can be relatively simple the stress test carrying out interface, become those skilled in the art need consider problem.
Summary of the invention
In view of this, the embodiment of the present invention provides method for testing pressure and the test equipment of a kind of interface, to promote interfaceThe simplicity of stress test so that the stress test carrying out interface that tester can be relatively simple.
For achieving the above object, the following technical scheme of embodiment of the present invention offer:
A kind of method for testing pressure of interface, including:
Obtaining description text used during defining interface, the communication protocols that described description text is provided by Development Framework is discussed and decidedJustice;
Resolve described description text, be configured to set by the content corresponding with interface to be tested comprised in described description textThe data structure of the formula that fixes, described setting form is different from the form of the descriptive language that described communication protocol uses;
Data structure configuration testing content according to described setting form, obtains having in the test of described setting formHold;
Call stress test logic, according to the test content of described setting form, described interface to be tested is carried out pressure surveyExamination.
The embodiment of the present invention also provides for a kind of test equipment, including:
Describing text acquisition module, for obtaining description text used during defining interface, described description text is by developingThe communication protocol definition that framework provides;
Parsing module, is used for resolving described description text, corresponding to interface to be tested by comprise in described description textContent be configured to set the data structure of form, the lattice of the descriptive language that described setting form and described communication protocol useFormula is different;
Test content configuration module, for the data structure configuration testing content according to described setting form, is hadThe test content of described setting form;
Testing execution module, is used for calling stress test logic, treats described according to the test content of described setting formTest interface carries out stress test.
Based on technique scheme, definition, when treating test interface and carrying out stress test, can be connect by the embodiment of the present inventionContent corresponding with interface to be tested in description text used during mouth, is converted into the data structure setting form;And set latticeFormula is to be prone to carry out the form of data configuration, therefore user's data based on the described setting form being converted into knot relative to userStructure, the data structure according to described setting form that can be relatively simple carries out testing the configuration of content, obtains having described settingThe test content of form;And then call stress test logic, to be measured try to described according to the test content of described setting formMouth carries out stress test, it is achieved the stress test purpose of docking port.Owing to the embodiment of the present invention is by corresponding for interface to be testedContent, is converted to be prone to carry out the setting form of data configuration relative to user, then by the data setting form being converted intoStructure carries out test configurations, can make the stress test realizing interface that user is relatively simple, improve the simplicity of stress testProperty.
Accompanying drawing explanation
In order to be illustrated more clearly that the embodiment of the present invention or technical scheme of the prior art, below will be to embodiment or existingIn having technology to describe, the required accompanying drawing used is briefly described, it should be apparent that, the accompanying drawing in describing below is only thisInventive embodiment, for those of ordinary skill in the art, on the premise of not paying creative work, it is also possible to according toThe accompanying drawing provided obtains other accompanying drawing.
The flow chart of the method for testing pressure of the interface that Fig. 1 provides for the embodiment of the present invention;
Fig. 2 is the schematic flow sheet that docking port carries out stress test;
The method flow diagram resolving description text that Fig. 3 provides for the embodiment of the present invention;
Fig. 4 is the parsing schematic diagram describing text;
Fig. 5 is the execution flow chart of stress test logic;
Fig. 6 is the execution schematic diagram of stress test logic;
The structured flowchart of the test equipment that Fig. 7 provides for the embodiment of the present invention;
The structured flowchart of the parsing module that Fig. 8 provides for the embodiment of the present invention;
Another structured flowchart of the test equipment that Fig. 9 provides for the embodiment of the present invention;
The structured flowchart of the testing execution module that Figure 10 provides for the embodiment of the present invention;
The hardware block diagram of the test equipment that Figure 11 provides for the embodiment of the present invention.
Detailed description of the invention
Below in conjunction with the accompanying drawing in the embodiment of the present invention, the technical scheme in the embodiment of the present invention is carried out clear, completeDescribe, it is clear that described embodiment is only a part of embodiment of the present invention rather than whole embodiments wholely.Based onEmbodiment in the present invention, it is every other that those of ordinary skill in the art are obtained under not making creative work premiseEmbodiment, broadly falls into the scope of protection of the invention.
The flow chart of the method for testing pressure of the interface that Fig. 1 provides for the embodiment of the present invention, this method for testing pressure can be answeredFor testing equipment, test equipment can be the electronic equipment being mounted with stress test logic, the embodiment of the present invention can beRealizing the stress test of interface in client computer, accordingly, test equipment can be the client computer being mounted with stress test logic, thisInventive embodiments can also be to realize the stress test of interface on the server, and accordingly, test equipment can be to be mounted with pressureThe server of power test logic;
With reference to Fig. 1, the method for testing pressure of the interface that the embodiment of the present invention provides may include that
Description text used when step S100, acquisition defining interface, described description text is by leading to that Development Framework providesLetter protocol definition;
Carrying out application and development, during definition application Foreground and Background interface, Interface Definition Document can used, herein indicationDescription text used during defining interface can be this Interface Definition Document;The communication protocol that description text is used is by applyingDevelopment Framework (such as RPC framework) determine, therefore describe the communication protocol definition that text is typically provided by Development Framework, and be somebody's turn to doCommunication protocol is to be defined by the descriptive language used by Development Framework;
Prior art is when docking port carries out stress test, and tester is required to understand the communication that Development Framework providesDescriptive language used by agreement, the Interface Definition Document used when can understand defining interface (described description text),The mouth that achieves a butt joint carries out stress test, and the stress test mode of this interface is higher to the requirement of tester, and the present invention implementsExample then can solve the problem that this problem.
Step S110, resolve described description text, by described description text comprises corresponding with interface to be tested inHolding the data structure being configured to set form, the form of the descriptive language that described setting form uses with described communication protocol is notWith;
The embodiment of the present invention is after getting described description text, it may be determined that interface to be tested is phase in described description textThe content answered, thus corresponding for interface to be tested content is configured to set the data structure of form;Setting form can be to useWhat family (such as tester) was specified be prone to the carry out form of data configuration, and retouching of using of the communication protocol provided with Development FrameworkThe form stating language is different;
Optionally, the setting form of what user specified be prone to carry out data configuration can be such as the json (number of a kind of lightweightAccording to exchange language, based on word, and it being prone to allow people read) form, (Extensible Markup Language, can for xmlExtending mark language) form etc.;
In the embodiment of the present invention, the setting form being prone to carry out data configuration can be set, thus by resolving defining interfaceThe description text of Shi Suoyong, by describing the content corresponding with interface to be tested comprised in text, is configured to be prone to carry out dataThe data structure setting form of configuration;
User can be set the appointment of form according to the data form that oneself is familiar with, thus by by interface phase to be testedThe Content Transformation answered becomes to be prone to carry out the setting form of data configuration, can allow users to understand faster the content of interface,It is easy to the follow-up configuration carrying out testing content for interface to be tested;
Optionally, interface to be tested can be the either interface describing text definition, it is also possible to be to describe text definitionMultiple interfaces, even total interface.
Step S120, data structure configuration testing content according to described setting form, obtain having described setting formTest content;
Optionally, the embodiment of the present invention becomes the data of setting form to tie by describing the Content Transformation of interface to be tested in textAfter structure, user can be according to test needs, and according to the fill request of setting form, the data at the described setting form being converted into are tiedStructure is filled in the test content for interface to be tested, thus realizes joining of test content with the data structure of described setting formPut, obtain the test content of described setting form;
Owing to the data structure of described setting form is prone to carry out data configuration, what therefore user can be relatively simple is changingThe data structure of the described setting form become fills in test content, it is achieved easy test configurations;
Optionally, by be prone to configuration setting form be the form comprising key (key), value (value) as a example by, as xml,Json form etc.;Then user is when carrying out the configuration testing content, it is only necessary at the value of the data structure of described setting formValue is filled out in the inside, it is possible to realize the configuration of test content.
Step S130, call stress test logic, according to the test content of described setting form to described interface to be testedCarry out stress test.
Optionally, after obtaining having the test content of described setting form, the embodiment of the present invention can call stress testLogic, completes test configurations at least based on the test content of described setting form, and treats test interface and carry out stress test.
The method for testing pressure of the interface that the embodiment of the present invention provides includes: obtain description literary composition used during defining interfaceThis, the communication protocol definition that described description text is provided by Development Framework;Resolve described description text, by described description textThe content corresponding with interface to be tested comprised is configured to set the data structure of form, described setting form and described communication protocolsThe form of the descriptive language that view uses is different;Data structure configuration testing content according to described setting form, is hadThe test content of described setting form;Call stress test logic, according to the test content of described setting form to described to be measuredMouth of trying carries out stress test.
Visible, the embodiment of the present invention, can be by used retouching during defining interface when treating test interface and carrying out stress testState content corresponding with interface to be tested in text, be converted into the data structure setting form;And set form be relative toFamily is prone to carry out the form of data configuration, therefore user's data structure based on the described setting form being converted into, can more letterJust the data structure according to described setting form carries out testing the configuration of content, obtains having in the test of described setting formHold;And then call stress test logic, according to the test content of described setting form, described interface to be tested is carried out pressure surveyExamination, it is achieved the stress test purpose of docking port.Owing to the embodiment of the present invention is by corresponding for interface to be tested content, be converted to phaseUser is prone to carry out the setting form of data configuration, then the data structure of the setting form by being converted into carries out test and joinsPut, the stress test realizing interface that user is relatively simple can be made, improve the simplicity of stress test.
Optionally, when docking port carries out stress test, user can also configure stress test index;Stress test index refers toIt is shown with the index carrying out being used during stress test, indicates QPS (Query Per Second such as by stress test indexQuery rate per second), test process quantity, the index such as testing time;
Accordingly, the embodiment of the present invention also can obtain the stress test index of user's input;And then stress test can be calledLogic, carries out stress test according to described test content and described stress test index to described interface to be tested;
It is to be appreciated that, stress test logic refers to by reading user configured described test content and described stress testMark, then stress test logic can complete test configurations, and then the pressure survey of the mouth that can achieve a butt joint based on the test configurations completedExamination;
Accordingly, Fig. 2 shows that docking port carries out the schematic flow sheet of stress test, can refer to.
Optionally, Fig. 3 shows the method flow diagram resolving description text that the embodiment of the present invention provides, with reference to Fig. 3, and shouldMethod may include that
Step S200, resolve described description text, described description text is converted to the file of script data structure;
Describing text and can define multiple interfaces (all of interface is applied in even definition) of application, the embodiment of the present invention is led toCross description text and can get the background protocol interface describing text definition;
Optionally, the file of script data structure can be that (python is a kind of object-oriented, the electricity of literal translation formula to pythonBrain programming language) file of structure, the file etc. of nodejs (a Javascript running environment) structure;
Optionally, Development Framework, when by the communication protocol definition interface of descriptive language, can provide this is descriptiveLanguage conversion is the ability of program language (such as program languages such as c++, java, or python), and the embodiment of the present invention may utilizeThe ability that the descriptive language that communication protocol uses is converted to program language that Development Framework provides, obtains describing text conversionFor the file of script data structure;
Optionally, the ability that this descriptive language is converted to program language that Development Framework provides can be loaded in exploitationIn the resolver that framework provides, the embodiment of the present invention can be by calling the resolver that described Development Framework provides, by described descriptionText is converted into the file of corresponding script data structure.
Step S210, from the background protocol interface that described description text comprises, read interface to be tested, and based on describedThe file of script data structure obtains the dictionary file of described interface to be tested corresponding script data structure;
Describing text definition and have multiple background protocol interface, the embodiment of the present invention can read treating in this background protocol interfaceTest interface, and from the file of described script data structure, obtain the word of described interface to be tested corresponding script data structureAllusion quotation file;Dictionary file may be considered a kind of text, and correspondence needs the description information of test interface.
As a example by the file of the script data structure file for python structure, the embodiment of the present invention can be from python structureFile in get the python example of interface to be tested, thus obtain interface to be tested corresponding python dictionary structure literary compositionPart;Optionally, the embodiment of the present invention can obtain python example by methods such as dict.
Step S220, the content read in described dictionary file, become described setting form by the Content Transformation readData structure.
After the dictionary file obtaining interface to be tested corresponding script data structure, the embodiment of the present invention can read this wordContent in allusion quotation file, and the Content Transformation read is become the data structure of described setting form.
Optionally, as a example by the file of script data structure is for python file, Fig. 4 shows that the parsing describing text is shownIt is intended to, can refer to.
Optionally, obtaining the test content with described setting form, and getting user configured stress testAfter index, the embodiment of the present invention can carry out stress test by method shown in Fig. 5, and Fig. 5 shows the execution of stress test logicFlow chart, with reference to Fig. 5, this flow process may include that
Step S300, by test host process read test content and stress test index, complete test configurations;
Stress test logic can be divided into test host process and test subprocess, test host process and test subprocess to be fathersThe relation of subprocess;
After obtained described test content and described stress test index by flow process described previously, test host process is readableTake described test content and described stress test index, complete test configurations so that achievement of test readiness.
Step S310, set up at least one test subprocess;
Step S320, according to test configurations, treat test interface by each test subprocess respectively and carry out stress test;
If the test event that test configurations comprises has multinomial, then the embodiment of the present invention can by each test subprocess respectivelyPerforming corresponding test event, treat test interface and complete the test of corresponding test event, output test result data.
Step S330, from pipeline, obtain the test result data of each test subprocess by test host process.
Pipeline can be understood as a kind of mode of interprocess communication, and the test result data of test subprocess output can be led toThe interprocess communication modes such as piping, are transferred to test host process;
Optionally, test host process, after getting test result data, can print test report, in order to user checks surveyTest result.
Optionally, Fig. 6 shows the execution schematic diagram of stress test logic, can refer to, and what in Fig. 6, SIGALRM represented isOn the platform that POSIX is compatible, during timer ends, it is sent to the signal of process;In Fig. 6, the test of each test subprocessJourney can be: according to test configurations, and the sequencing method that calling the Development Framework such as RPC itself provides serializes, thus rightInterface to be tested is tested, and the general communication mode that then calling Development Framework itself provides outputs test result;SimultaneouslyThe embodiment of the present invention can also register a general call back function, the testing time in statistical test procedures, packet lossEtc. index.
The embodiment of the present invention, when docking port carries out stress test, can input the description text used by defining interface, and shouldThe communication protocol definition that text is provided by Development Framework is described;By text will be described be converted to be prone to the form that sets of configurationThe test contents such as data structure, is simultaneously based on the data structure setting form after conversion, docking port data file are filled with;And then can be based on the rate of giving out a contract for a project of configuration, testing time equal pressure test index, generate net by the sequencing method of Development FrameworkNetwork bag, carrys out docking port and carries out stress test.
Optionally, the method for testing pressure of the interface that the embodiment of the present invention provides can be integrated in Development Framework so that shouldThe Development Framework docking port that has the embodiment of the present invention concurrently and provide carry out the function of stress test.
The embodiment of the present invention can make the stress test realizing interface that user is relatively simple, improves the letter of stress testJust property.
Below to the embodiment of the present invention provide test equipment be introduced, test equipment described below can with retouch aboveThe method for testing pressure of the interface stated is mutually to should refer to.The structure of test equipment described below may be considered test equipmentFor realizing the functional module framework arranged needed for the stress test of interface, this functional module framework can be integrated in the exploitation frame of applicationIn frame.
The structured flowchart of the test equipment that Fig. 7 provides for the embodiment of the present invention, with reference to Fig. 7, this test equipment may include that
Describing text acquisition module 100, for obtaining description text used during defining interface, described description text is by openingSend out the communication protocol definition that framework provides;
Parsing module 200, is used for resolving described description text, by that comprise in described description text with interface phase to be testedThe content answered is configured to set the data structure of form, the descriptive language that described setting form uses with described communication protocolForm is different;
Test content configuration module 300, for the data structure configuration testing content according to described setting form, is hadThere is the test content of described setting form;
Testing execution module 400, is used for calling stress test logic, according to the test content of described setting form to describedInterface to be tested carries out stress test.
Optionally, Fig. 8 shows the optional structure of the parsing module 200 that the embodiment of the present invention provides, with reference to Fig. 8, this solutionAnalysis module 200 may include that
Script data structure converting unit 210, is used for resolving described description text, described description text is converted to scriptThe file of data structure;
Dictionary file obtains unit 220, to be tested for reading from the background protocol interface that described description text comprisesInterface, and file based on described script data structure obtain described interface to be tested corresponding script data structure dictionary literary compositionPart;
Format conversion unit 230, for reading the content in described dictionary file, becomes described by the Content Transformation readSet the data structure of form.
Optionally, script data structure elucidation obtains unit 210 and is particularly used in, and calls the solution that described Development Framework providesParser, is converted into the file of corresponding script data structure by described description text.
Optionally, the file of script data structure can be python file;
Accordingly, dictionary file obtains unit 220 and obtains described to be tested at file based on described script data structureDuring the dictionary file of interface corresponding script data structure, it is particularly used in, tries based on described python file acquisition is to be measuredThe python example of mouth, to obtain interface to be tested corresponding python dictionary structure file.
Optionally, described setting form may include that json form, or, xml form etc..
Optionally, test content configuration module 300 is particularly used in, and obtains the test content of user's input, by acquiredTest content insert in the data structure of described setting form, obtain the test content with described setting form.
Optionally, Fig. 9 shows another structured flowchart testing equipment that the embodiment of the present invention provides, in conjunction with Fig. 7 and Fig. 9Shown in, this test equipment can also include:
Test index acquisition module 500, for obtaining the stress test index of user's input.
Accordingly, testing execution module 400 is calling stress test logic, according to described test content to described to be testedWhen interface carries out stress test, it is particularly used in, calls stress test logic, according to described test content and described stress testIndex carries out stress test to described interface to be tested.
Optionally, Figure 10 shows the optional structure of the testing execution module 400 that the embodiment of the present invention provides, with reference to figure10, testing execution module 400 may include that
Test configurations unit 410, for reading described test content and described stress test index by test host process,Complete test configurations;
Subprocess sets up unit 420, is used for setting up at least one test subprocess;
Test cell 430, for according to test configurations, treats test interface by each test subprocess respectively and carries out pressureTest;
Test result data acquiring unit 440, for obtaining each test subprocess by test host process from pipelineTest result data.
The test equipment that the embodiment of the present invention provides can make the stress test realizing interface that user is relatively simple, promotesThe simplicity of stress test.
Optionally, Figure 11 shows the hardware block diagram testing equipment that the embodiment of the present invention provides, with reference to Figure 11, and shouldTest equipment may include that processor 1, communication interface 2, memorizer 3 and communication bus 4;
Wherein processor 1, communication interface 2, memorizer 3 complete mutual communication by communication bus 4;
Optionally, communication interface 2 can be the interface of communication module, such as the interface of gsm module;
Processor 1, is used for performing program;
Memorizer 3, is used for depositing program;
Program can include that program code, described program code include computer-managed instruction;
Processor 1 is probably a central processor CPU, or specific integrated circuit ASIC (ApplicationSpecific Integrated Circuit), or it is configured to implement the one or more integrated electricity of the embodiment of the present inventionRoad.
Memorizer 3 may comprise high-speed RAM memorizer, it is also possible to also includes nonvolatile memory (non-volatileMemory), for example, at least one disk memory.
Wherein, program can be specifically for:
Obtaining description text used during defining interface, the communication protocols that described description text is provided by Development Framework is discussed and decidedJustice;Resolve described description text, be configured to the content corresponding with interface to be tested comprised in described description text set latticeThe data structure of formula, described setting form is different from the form of the descriptive language that described communication protocol uses;Set according to describedThe data structure configuration testing content of the formula that fixes, obtains the test content with described setting form;Call stress test logic,Test content according to described setting form carries out stress test to described interface to be tested.
In this specification, each embodiment uses the mode gone forward one by one to describe, and what each embodiment stressed is and otherThe difference of embodiment, between each embodiment, identical similar portion sees mutually.For device disclosed in embodimentFor, owing to it corresponds to the method disclosed in Example, so describe is fairly simple, relevant part sees method part and saysBright.
Professional further appreciates that, in conjunction with the unit of each example that the embodiments described herein describesAnd algorithm steps, it is possible to electronic hardware, computer software or the two be implemented in combination in, in order to clearly demonstrate hardware andThe interchangeability of software, the most generally describes composition and the step of each example according to function.TheseFunction performs with hardware or software mode actually, depends on application-specific and the design constraint of technical scheme.SpecialtyTechnical staff specifically should can be used for using different methods to realize described function to each, but this realization should notThink beyond the scope of this invention.
The method described in conjunction with the embodiments described herein or the step of algorithm can direct hardware, processor be heldThe software module of row, or the combination of the two implements.Software module can be placed in random access memory (RAM), internal memory, read-only depositReservoir (ROM), electrically programmable ROM, electrically erasable ROM, depositor, hard disk, moveable magnetic disc, CD-ROM or technologyIn any other form of storage medium well known in field.
Described above to the disclosed embodiments, makes professional and technical personnel in the field be capable of or uses the present invention.Multiple amendment to these embodiments will be apparent from for those skilled in the art, as defined hereinGeneral Principle can realize without departing from the spirit or scope of the present invention in other embodiments.Therefore, the present inventionIt is not intended to be limited to the embodiments shown herein, and is to fit to and principles disclosed herein and features of novelty phase oneThe widest scope caused.