LoadRunner WebService interface Performance test Scripting optimization Summary

Source: Internet
Author: User

This paper mainly introduces the related script writing and optimization method summary when using LoadRunner to call WebService interface for performance testing.

1.Webservice Protocol Scripting Process

The following describes the common processes and methods for calling the WebService interface using LoadRunner 11

1.1 New script, select "Webservice" protocol

1.2 Select Manage Services->import, enter the URL (note that you need to add a. wsdl to the WebService address), and finally select Impoort

1.3 Click the script in the action script before return 0, then select Add Service Call

1.4 In the new Web Service call window that opens, select input parameter inputxml, tick include argument in, and in value you can fill in some characters (in the next script, we'll do someparameterized Settings)

1.5 Similarly, select the output parameter in Submitnlsmsrequestresult, then select Save returned value in Param, and finally select OK

This is called once the WebService interface is saved in the action script

1.6parameterization of
    • Replace "xxx" with "<mobileno>13312345678</mobileno><smscontent> fetion </smscontent>" (This interface input parameter example) in the script
    • Select "13312345678" and right-select Replace with a Parameter, enter parameter name and parameter type (Unique number)

1.7 Parameter settings
    • Select the P icon in the upper right corner of the script to enter the parameter list
    • Choose unique number "unique", choose Format%8d (②)
    • Select "Block size per VUser" for 1000000 (number of parameters assigned to each virtual user, ③)
    • At the same time, update value selects "Every iteration" when the out of values selects "Continue in a cyclic manner" (after each iteration, the parameters are updated, And each virtual user uses a parameter that exceeds the number of parameters assigned to 1000000, starting from scratch, so loop. ④)

Here we have completed the basic LoadRunner scripting, and here we begin the real focus: script optimization and practical walkthrough, including collection Point additions, transaction Additions, return result judgments and "Save 20000 sessions" scripting.

2.Webservice Script Optimization 2.1 Gather points add 2.1.1 What is a collection point?

Rendezvous points are used to synchronize virtual users to perform tasks exactly at the same time. A performance test plan may require that the system be able to withstand 1000 of people submitting data at the same time, by joining the collection point before the commit data operation in LoadRunner, when the virtual user runs to the collection point where the data is submitted,LoadRunner Will check how many users run to the collection point at the same time, if less than 1000 people,LoadRunner will command has been to the meeting point of the user waiting, when the meeting point waiting for the user reached 1000, loadrunner command 1000 people at the same time to submit data, In order to meet the requirements of the test plan.

2.1.2 How do I add a collection point?

When you need to add a collection point, such as before you start calling the interface, right-select insert->rendezvous and enter the name of the collection point. You can also add "lr_rendezvous" ("Step1") directly before the script you want to add, where Step1 is the collection point name and can be customized.

2.2Transaction Additions2.2.1 Add startTransactions

Due to the need for statistical response time critical parameter indicators, you need to manually add transactions in the script. Adding a transaction method is similar to a collection point. When you need to add a transaction, such as a collection point, right-select Insert->start Transaction and enter the transaction name. You can also add "lr_start_transaction (" Step1 ") directly in the script, where STEP1 is the transaction name and can be customized.

    • Add transaction differences before and after a collection point?

If you add a transaction before the collection point, the time at which the collection point waits is included when the transaction time is last counted, resulting in inaccurate (larger) response time data for the statistic. So here we choose to add a transaction after the collection point.

2.2.2 Adding an End transaction

Similarly, when you need to add an end transaction, typically after Web_service_call, right-click the Insert->end Transaction, and enter the name of the transaction that needs to end. You can also add "lr_end_transaction (" Step1 ", Lr_auto) directly in the script, where Step1 is the name of the transaction that needs to end.

    • What is Lr_auto?

The second parameter in Lr_end_transaction is the transaction end state, with Lr_pass (pass), Lr_fail (failed), Lr_auto (Automatic), and Lr_stop (paused). If the end thing state is not specified in Lr_end_transaction as Lr_auto, but is explicitly specified as Lr_pass, Lr_fail, and lr_stop, then the thing will end in the state that was last specified.

2.3 Return result Judgment 2.3.1 Single return result judgment

For example, when we call the WebService interface to enter the following parameters "<mobileno>13312345678</mobileno> <smscontent> fetion </smscontent > ", the interface correctly returns results including" Fetion is China Mobile business ". Here we need to judge the return result. The sample code is as follows:

    • lr_eval_string function Description

None of the C variables can be called directly by the LR function. So: the LR function calls the C variable, which has to be parsed by lr_eval_string, which is equivalent to the function of the bridge.

    • Strstr function Description

The function format is strstr (STR1,STR2), where str1: is searched for the target string expression to Search,str2: object to find the string expression to Find. The function returns the position of STR2 for the first time in str1, and returns null if it is not found.

    • Lr_error_message and Lr_output_message function descriptions

1) The Lr_error_message function sends error messages to the Output window and to the VUser log file.

2) lr_error_message Displays the red font in the playback log and displays the line number of the statement, and generates an error message if the script is run in Controllor.

3) The Lr_output_message function sends a message with the line number of the script part to the Output window and to the log file.

2.3. More than 2 returned results judged

Similar to a single result, in fact, is nested IF statements, here do not repeat, the sample code is as follows:

3. Practical Walkthrough – Save 20000 Session 3.1 Requirements Description

In real-world projects, you need to test whether a component can hold up to 20,000 sessions, and after you save 20,000 sessions, the user can send an upstream text message to end the 20000 session normally. In the stress test, we have added 50 virtual users, then a virtual user only needs to start saving 20000/50=400 sessions, then end these sessions.

3.3 Scripting

We can use a for loop to do this part of the work, the sample code is as follows:

3.3.1Lr_whoami Function Description

void Lr_whoami (int *vuser_id, char **sgroup, int *scid);

Return value: Returns the currently running VUser ID, the name of the group running the script, and the scene ID

Parameter description:

    • int *vuser_id need to register, save the ID of the running VUser, play back in Virtual User generator-1
    • Char **sgroup need to register, save the running VUser Group name (script name), playback in Virtual User generator return None
    • int *scid is required to register, save the ID of the running scenario and return 0 in virtual User generator
3.3.2lr_save_int Function Description

The Lr_save_int function means to save an integer as a parameter

ABS (ID) means to take the absolute value of the ID (because in Virtual User generator, the ID is returned as-1)

LoadRunner WebService interface Performance test Scripting optimization Summary

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.