I have been doing LoadRunner tests for several weeks recently. I have some experiences and recorded them for future search.
LoadRunner tests the database by simulating a client to connect to the database server. Therefore, the Protocol (or driver support) is required ). LoadRunner itself directly supports Oracle and sqlserver databases. These two databases can directly select the corresponding protocol to record scripts. MySQL Databases can only use the ODBC protocol to record (write) scripts. Therefore, the MySQL ODBC driver and the query analyzer supporting ODBC are required ).
1. First install the ODBC driver of MySQL, myodbc 3.51.11 win.
2. Open "Data Source ODBC" from "Control Panel". If it is not found (it is not found on my computer ). Go to the desktop and create a shortcut. The destination location is % SystemRoot %/system32/odbcad32.exe.
3. Open the ODBC Management Program, add the "MySQL ODBC 3.51 driver" driver, and fill in some IP addresses, user names, passwords, and so on. Then, test it. (This step is not required. If you write a connection string, you do not need to use the DNS database name)
4. Install a query analyzer.The query analyzer must support ODBC(This is required, otherwise it cannot be recorded), which is not easy to find. I found one, which is not easy to use. It is called "common database query analyzer ". Http://www.onlinedown.net/soft/31366.htm.
5. Start LoadRunner, create scripts; application type: Win32 applications; program record: select the query analyzer location in step 1. Remember to select "ODBC" as the query analyzer before recording, check whether the operation is normal.
6. Run the load tests command to check whether the license is supported if it fails. Use the global-100 license.
The recorded script is terrible (smelly and long), so I tried to write a simple one by hand, with comments on each line. For more information, see the help documentation of LoadRunner.
# Include "LRD. H "<br/> action () <br/> {<br/> static lrd_init_info initinfo = {lrd_init_info_eyecat }; <br/> static lrd_default_db_version dbtypeversion [] = <br/>{< br/> {lrd_dbtype_odbc, feature },< br/> {lrd_dbtype_none, lrd_dbversion_none} <br/> }; <br/> static lrd_context far * ctx1; <br/> static lrd_connection far * con1; <br/> static lrd_cursor far * csr1; <br/> // The Code defined above, if the recording script is in VDF. H is defined, and there are some other files <br/> // If the script is handwritten, You need to manually add it, it mainly defines various variables <br/> // query the number of rows <br/> unsigned Long Count = 0; <br/> // initial <br/> lrd_init (& initinfo, dbtypeversion); <br/> // open the context <br/> lrd_open_context (& ctx1, lrd_dbtype_odbc, 0, 0, 0 ); <br/> // memory for applying for connection <br/> lrd_alloc_connection (& con1, lrd_dbtype_odbc, ctx1, 0/* unused */, 0 ); <br/> // open the connection. Note that the driver is the previously installed lrd_open_connection (& con1, lrd_dbtype_odbc ,"","","", "Driver = MySQL ODBC 3.51 driver; uid = root; Pwd = 123456; server = 192.168.1.99; database = testdb", ctx1, 1, 0 ); <br/> // open the cursor <br/> lrd_open_cursor (& csr1, con1, 0); <br/> // SQL statement. Note that 1 indicates that, immediately execute <br/> lrd_stmt (csr1, "select column1 from Table1 where colum1 = 1",-1, 1, 0/* none */, 0 ); <br/> // count the number of rows to the Count variable <br/> lrd_row_count (csr1, & count, 0 ); <br/> // print the message <br/> lr_message ("Count = % d", count ); <br/> // close the cursor first <br/> lrd_close_cursor (& csr1, 0); <br/> // close the connection again <br/> lrd_close_connection (& con1, 0, 0); <br/> // release the connection, which matches alloc; otherwise, memory leakage <br/> lrd_free_connection (& con1, 0/* unused */, 0); <br/> // disable the context <br/> lrd_close_context (& ctx1, 0, 0); <br/> // the process is completed, return 0 <br/> return 0; <br/>}
After writing, run the command to view the log as follows:
------------------------------------------------------------------------------
Starting iteration 1.
Starting action.
Action. C (8): lrd_open_connection: User = "", Server = ""
Action. C (11): lrd_stmt: Select column1 from Table1 where colum1 = 1;
Count = 1
Action. C (16): lrd_close_connection: User = "", Server = ""
Ending action.
------------------------------------------------------------------------------
Count = 1 indicates that the query is successful.
========================================================== ========================================
Performance-related articles:
LoadRunner uses ODBC to write MySQL scripts
Monitors the Linux resources of the server during stress testing of LoadRunner.
The stress test measures three CPU indicators: CPU utilization, load average, and context switch rate.
High-performance server architecture)
Conversion from PV to TPS and TPS fluctuation in website performance tests
Use gtmetrix to optimize your webpage (Integrating yslow and firebug functions)