First recognized LoadRunner

Source: Internet
Author: User

I. Socket script

Lrs_startup (257 );

Lrs_create_socket ("socket1", "TCP", "remotehost = 192.168.86.239: 9503", lrslastarg );

Lrs_set_recv_timeout (120, 0 );

Lrs_set_socket_options ("socket1", lrs_no_delay, "true ");

 

Lrs_send ("socket1", "buf1", lrslastarg );

Lrs_receive ("socket1", "rbuf1", lrslastarg );

 

Lrs_close_socket ("socket1 ");

Lrs_cleanup ();

 

Ii. LoadRunner Functions

1258 Functions

Http://files.cnblogs.com/qingxia/LoadRunner%E5%87%BD%E6%95%B0%E5%A4%A7%E5%85%A8%E4%B9%8B%E4%B8%AD%E6%96%87%E8%A7%A3%E9%87%8A.pdf

 

3. debug the optimization script

1. Set breakpoints

I believe everyone is familiar with this. lr can also set breakpoints. Press the F9 shortcut key before the breakpoint statement needs to be set. The breakpoint is set and will be paused after the program runs to the breakpoint statement, at this time, we can use F10 to debug the program in one step.

2. Open extended log

It is not enough to set breakpoints. We have to know what happened. log tells us everything. The default log is standard log, which is far from enough. Extended log. Open the path runtime settings --> log --> extended log. Check parameter substitution, data returned by server, and advanced trace as needed.

3. Comment out unnecessary statements

Many scripts with errors during playback are redundant statements. This is because many of the statements generated by LR during recording are not what we want. Don't trust LR too much. The statements generated by LR also have many bugs.

 

4. Where can I view the log file?

(1) In vgen, we must write the output information of the output function and use the function to output the information we want to know. There are mainly the output information of these functions: lr_output_message, lr_error_message, and lr_log_message. for more information about these functions, see help --> function reference.

Next, we need to set in vuser-> runtime settings-> log, check the always send messages file, lr_log_message will only input information to the mdrv. while lr_output_message is written into the above two files.

(2) In the controller, many friends will want to know whether the parameters are correctly imported for multiple iterations. We still check the log. After the execution, view the log folder in the result directory. If it is run by the load generator, it is in the tmp directory. However, we also want to remind our friends that we also need to set runtime settings in the controller, and the runtime settings for each user group can be set as follows: In the run tab of the controller, vusers... -> details... -> click the runtime Settings button and set it in the same way as in vgen.

 

V. network example-packet garbled

[Note:] after recording a script using the SOCKET protocol today, it is found that all packets are garbled. Finally, all garbled characters are formatted as hexadecimal. What impressed me most is that as long as I understand the character type length, I can really understand what the content of the packet sent by LoadRunner is. Then, you can flexibly control the data packet values and data packet operations.

1. Basic Knowledge:
(1) You need to know the package structure in the tested software.
(2) Know the binary stream;
(3) know Big endian and little endian
(4) know the length of the character type
(5) know: When two hosts communicate in different byte orders, both parties must convert the data in byte order before it can be transmitted.

2. instance description:

If a package contains two values, the definition is as follows:

Struct msghead
{
Int ID,
Char name
}

Assume that the package body we want to send includes these two fields. And Id = 81001, name =

The values in the LoadRunner data. ws file or custom data packets are as follows:

/*********************************
Send buf0 5

"\ X69 \ x3c \ x01 \ x00" // Description: decimal: 81001 hexadecimal: 13c69 storage by high/low bits: 69 3C 01 00

"\ X41" // Description: ASCII code A is 65 in decimal format, and 65 is converted to hexadecimal format 41.
*********************************/

3. Note

In the above example, No matter what garbled characters are displayed in the recorded data packets.

You can use the above method to parse the package according to the length defined in the package structure one by one.

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.