2 ways to prepare upload files for a load test!

Posted: April 21st, 2008 | Author: TnT Admin | Filed under: How-Tos | Tags: | No Comments »

There will be times that you maybe required to test a upload or download of files activity in a load test. Today, we will discuss about the various methods that you can employ to prepare the files for upload. The methods are as followed:

    1. Prepare all the files prior the load test using a bat command.
    2. Modify the script to create the files on-the-fly.

Let’s move on to the first method!

[1] Prepare all the files prior the load test using a bat command

Use the following command in the command prompt to generate the files. The example below creates 300 unique files in the directory C:\test_folder and are named as NewFile-1.txt through to NewFile-300.txt. The new files are copied based on OriginalFile.txt.

for /L %%i in (1,1,300) do
(

@copy C:\test_folder\OriginalFile.txt NewFile-”%%i”.txt

)

Alternatively, you can save it as a bat command (click here for a sample bat file), and run the bat command when required.

[2] Modify the script to create the files on-the-fly

There is another method of duplicating on the fly in the Vugen script. Below is the extracted script of the Action block.

Action()
{

char command[100];
sprintf(command, “copy C:\\source_dir\\srcFile.txt C:\\source_dir\\srcFile-%s.txt”, lr_eval_string (”{iteration_number}”));
system(command);

/*all other codes … */

sprintf(command, “del C:\\source_dir\\srcFile-%s.txt”, lr_eval_string (”{iteration_number}”));
system(command);

return 0;

}

An explanation of the codes:

The script will be running on the system API on LoadRunner. For more information of the system API, you can refer to the Function Reference available in Vugen.

What the code does is as followed:

    1. Declare a string to store the command for execution.
    2. Define the parameter “iteration_number” in the Parameters setting. (refer to Fig 1 below).
    3. Build the command string create the duplicate file before all other APIs are called.
    4. Execute the command string to create duplicate file.
    5. Proceed with the other APIs (either recorded or manually script) as per user requirement.
    6. Build the command string to delete the duplicated file.
    7. Execute the command string to delete the duplicated file.

Set the iterations as per norm to the number of files for the user requirements. An example of the script can be found here.

With this two methods, you will be better equipped when conducting uploading files performance test.

Related Posts



Leave a Reply