Y-lib
Loadrunner libraries
|
Code for supporting (more) realistic browser emulation. More...
Go to the source code of this file.
Data Structures | |
struct | y_browser |
Internal browser structure, describing a browser as an entity. More... | |
Macros | |
#define | MAX_BROWSER_LIST_LENGTH 1000 |
Limit the browser list to 1000 browsers, as a failsafe in case of wrong parameter settings (which may cause endless loops otherwise) More... | |
Functions | |
void | y_log_browser (const y_browser *browser) |
Log the content of a browser object. More... | |
void | y_save_browser_to_parameters (const y_browser *browser) |
Save the contents of a browser struct as a series of "browser_*" loadrunner parameters. More... | |
int | y_setup_browser_emulation_from_parameters (const char *browser_name_param, const char *browser_chance_param, const char *browser_max_connections_per_host_param, const char *browser_max_connections_param, const char *browser_user_agent_string_param) |
Initialize the browser list based on a set of prepared parameters. More... | |
int | y_setup_browser_emulation () |
Initialize the browser list, using the default values for the parameter names: More... | |
int | y_setup_browser_emulation_from_file (char *filename) |
Initialize the browser list based on a tab-seperated CSV file. More... | |
y_browser * | y_choose_browser_from_list (y_browser *browser_list_head, int browser_list_chance_total) |
Choose a browser profile from a browser list at random using the defined weights in that list. More... | |
y_browser * | y_choose_browser () |
Choose a browser profile from the browser list at random using the defined weights. More... | |
int | y_emulate_browser (y_browser *new_browser) |
Emulate a specific browser. More... | |
Variables | |
y_browser * | y_browser_list_head = NULL |
The first element in the browser list. More... | |
int | y_browser_list_chance_total = 0 |
The total of all the browser weights added together. More... | |
Code for supporting (more) realistic browser emulation.
Basic concept: The tester defines a list of browsers that contains:
This list is read in during vuser_init() to construct a list of browsers, which can then be used during the loadtest to dynamically choose a browser from the list.
Usage:
Call y_setup_browser_emulation() (or one of the alternative variants) in vuser_init()
Example:
Call y_choose_browser() and y_emulate_browser() at the start of each iteration.
Example:
Definition in file y_browseremulation.c.
#define MAX_BROWSER_LIST_LENGTH 1000 |
Limit the browser list to 1000 browsers, as a failsafe in case of wrong parameter settings (which may cause endless loops otherwise)
Definition at line 104 of file y_browseremulation.c.
y_browser* y_choose_browser | ( | ) |
Choose a browser profile from the browser list at random using the defined weights.
This wrapper around y_choose_browser_from_list() uses the list pointed to by y_browser_list_head to choose from.
Example:
Definition at line 558 of file y_browseremulation.c.
y_browser* y_choose_browser_from_list | ( | y_browser * | browser_list_head, |
int | browser_list_chance_total | ||
) |
Choose a browser profile from a browser list at random using the defined weights in that list.
[in] | browser_list_head | The first entry of a previously constructed single-linked browser list. |
[in] | browser_list_chance_total | The total of the browser weights in the list. |
Example:
Definition at line 484 of file y_browseremulation.c.
int y_emulate_browser | ( | y_browser * | new_browser | ) |
Emulate a specific browser.
This will set up the MAX_TOTAL_CONNECTIONS, MAX_CONNECTIONS_PER_HOST socket options and user_agent_string settings for the browser listed.
Example:
[in] | new_browser | Pointer to a browser struct for the browser to be emulated. |
Definition at line 583 of file y_browseremulation.c.
void y_log_browser | ( | const y_browser * | browser | ) |
Log the content of a browser object.
Given a pointer to a browser struct, log what said browser struct contains. This is useful for debugging.
[in] | browser | A pointer to the browser struct to log. |
Definition at line 122 of file y_browseremulation.c.
void y_save_browser_to_parameters | ( | const y_browser * | browser | ) |
Save the contents of a browser struct as a series of "browser_*" loadrunner parameters.
This will create the following set of parameters from the browser object:
[in] | browser | A pointer to the browser to create parameters for. |
Definition at line 154 of file y_browseremulation.c.
int y_setup_browser_emulation | ( | ) |
Initialize the browser list, using the default values for the parameter names:
Example:
Definition at line 328 of file y_browseremulation.c.
int y_setup_browser_emulation_from_file | ( | char * | filename | ) |
Initialize the browser list based on a tab-seperated CSV file.
This will initialize the single-linked list of browsers, using a text file containing on each line one browser with the following fields, seperated by tabs:
The order of the fields is important; They should be listed on each line in the above order.
Example:
Call this during vuser_init().
[in] | filename | The name of the file to read. |
Definition at line 371 of file y_browseremulation.c.
int y_setup_browser_emulation_from_parameters | ( | const char * | browser_name_param, |
const char * | browser_chance_param, | ||
const char * | browser_max_connections_per_host_param, | ||
const char * | browser_max_connections_param, | ||
const char * | browser_user_agent_string_param | ||
) |
Initialize the browser list based on a set of prepared parameters.
This will initialize the single-linked list of browsers, using the given set of parameters. The 'browser_name' parameter named here is expected to be set to "Select Next Row: Sequential", and "Update value on: Each iteration". The -last- browser name in the list has to contain the value "END" to mark the end of the list. All other parameters should be set to "Select Next Row: Same line as {browser_name_param}".
Call this during vuser_init().
[in] | browser_name_param | Browser name. Set this parameter to "Select Next Row: Sequential", and "Update value on: Each iteration". The last browser name should be "END". |
[in] | browser_chance_param | Browser weight. Can be any number as long as the total of chances does not exceed Y_RAND_MAX. Set this parameter to "Select Next Row: Same line as {browser_name_param}". |
[in] | browser_max_connections_per_host_param | Maximum number of connections this browser allows per host. See www.browserscope.org for possible values. Set this parameter to "Select Next Row: Same line as {browser_name_param}". |
[in] | browser_max_connections_param | Maximum number of connections this browser allows. See www.browserscope.org for possible values. Set this parameter to "Select Next Row: Same line as {browser_name_param}". |
[in] | browser_user_agent_string_param | The user agent string this browser reports to the server. See your production HTTP access logs for examples. Set this parameter to "Select Next Row: Same line as {browser_name_param}". |
Example:
Definition at line 210 of file y_browseremulation.c.
int y_browser_list_chance_total = 0 |
The total of all the browser weights added together.
Definition at line 110 of file y_browseremulation.c.
y_browser* y_browser_list_head = NULL |
The first element in the browser list.
Definition at line 107 of file y_browseremulation.c.