PerfLink

Citrix protocol is one of the complex protocol in LoadRunner protocol category. But scripting can be made simple if you remember some important tips which I have mentioned in this post. Now a day, performance testing of Citrix based system is required to ease the burden of administration, save bandwidth, and improve the user experience for response times; more and more companies are leveraging the Citrix technology platform. When moving applications to a thin environment, one of the difficulties is, determining how the application will perform when multiple users are accessing it. Micro Focus LoadRunner addresses this by providing the Citrix recording
protocol.

How does Citrix work?
Citrix works as both thick-client as well as a thin-client application for desktops. It allows users to run applications using the resources of the Citrix server, instead of using the resources of the user’s computer. When a session is connected to a Citrix server from a local machine then the Citrix client creates a bitmap image for the local machine users. The user inputs are sent in the form of x and y coordinate and then the server sends updated bitmap images to the user’s computer.

How does LoadRunner Citrix Protocol work?
Citrix Vuser scripts simulate the Citrix ICA (Independent Computing Architecture) protocol communication between a Citrix client and the server. As mentioned above bitmap images are sent by the Citrix server in the form of a two-dimensional array. This two-dimensional array having pixel information which helps to create an image on the user's system. VuGen uses this pixel information and prepares the hash value using its inbuilt algorithm and generate a script. When VuGen script replay then the validation of bitmap images (in form of hash value) is done. If recorded and replay hash value matches then it is considered that the bitmap images are same and the script is passed. VuGen uses dedicated functions for the user's keyboard and mouse input.

Important points for Citrix Script Recording: You need to keep some important points in your mind while Citrix script recording though VuGen:

a. Save the display setting of the (VuGen) machine where you are recording the script. This display setting will be required at the time of test execution. You need to keep the same display settings on Load Generator while executing the test.

b. Avoid connecting another remote desktop connection at the time of script recording to prevent the changes in the display setting.

c. Use Keyboard input instead of mouse input.
d. N avigate the application using the tab key or shortcut keys.

e. In tree-like structures, while recording, expand each child item to display sub-item in order to emulate the playback effectively.

f. Use ICA file for connection.

g. Record the connection process into the vuser_init section, and the closing process into the vuser_end section.

h. When recording a session, make sure to perform the complete business process, starting with the connection and ending with the cleanup. Do not leave any client or application windows open.

i. Try to avoid resizing the window during recording.
j. Avoid using LoadRunner basic inbuilt function directly.
k. Enable "Generate snapshot on error" under Runtime setting for script debugging purpose.
Runtime setting -> Miscellaneous -> Error Handling -> Generate snapshot on error

l. Use the think time because Citrix transactions, Citrix windows and bitmap functions in LoadRunner take time to stabilize.

m. Do not use "Ignore think time" option while replaying the script.

n. If you find frequent crashes happening and scripts are not getting captured properly then raise a ticket to concerned admin team to restart the application server hosted in the citrix environment.

o. In case of further issue, uninstall/re-install the Citrix receiver and agent in the windows server machine & application server/Citrix server (consider as a last option).

Important points for Citrix Script Execution: You need to remember below points while executing the Citrix script though Controller/Performance Center:

a. Set-up the display setting of as same as the VuGen machine. it is because, if the settings are different then sync_on_bitmap functions will fail in the script.

b. Avoid connecting another remote desktop connection from the same controller or load generator machine at the time of script execution.

c. Do not forget to place ICA file on an appropriate path in the controller or load generator.

d. The Citrix VUser’s memory footprint is two to three times a Web VUser’s memory footprint, so use appropriate Load Generator. You can calculate required no. of LG from LG calculator.

How to generate ICA file?
Since XenApp 7.x version onward, Citrix does not support to generate ICA file using any third party tool. For this purpose, Citrix has provided "Citrix Quick Launch 4.0" utility. You can download this utility from the given link (version and link may change in future):

https://support.citrix.com/article/CTX219718

Some important Citrix functions: It is recommended to use below given functions for a smooth running of the script:

web_set_sockets_option("IGNORE_PREMATURE_SHUTDOWN", "1");
web_set_sockets_option("SHUTDOWN_MODE","ABRUPT");
web_set_socket_option("CLOSE_KEEPALIVE_CONNECTIONS","TRUE");
web_set_socket_option("MAX_CONNECTIONS_PER_HOST","1");
web_set_sockets_option("SSL_VERSION","TLS");

Why keyboard input is preferred than mouse click in Citrix protocol in LoadRunner script?
This makes scripting more reliable along with less scripting and debugging issues. The LR functions recorded with keyboard input and mouse clicks are:

Keyboard Input:

ctrx_key(“RIGHT_ARROW_KEY”, 0);
Mouse Click:
ctrx_mouse_click(398, 99, RIGHT_BUTTON, 0, ‘Submit’);