HPE Software is now Micro Focus
HPE Software is now Micro Focus
LoadRunner and Performance Center
cancel

How to share actions between scripts in VuGen

How to share actions between scripts in VuGen

hilale

This blog was written by Boris Kozorovitzky from PerfCore RnD team

boris.png 

 

 

 

 

 

For the vast majority of LoadRunner/Performance Center/StormRunner Load users, VuGen is the main IDE to develop performance test scripts. Many of these users have a directory with multiple VuGen solutions and even more scripts arranged to perform particular use cases on one or more applications under test. Some of these scripts perform similar actions and differ only slightly from each other. For example, multiple scripts may require you to run a login action before any other action within the script. The common practice today is to copy the shared action files from one script to another—resulting in a maintainability challenge. VuGen does not provide any out-of-the-box functionality to manage shared actions between the scripts of a solution. In this article, I explore a different approach to this problem by utilizing an existing operating system feature available since Window Vista – the symbolic links.

 

Setup

In an empty directory, I created two scripts “MyScript_1” and “MyScript_2” and saved them in a solution called “MySolution”. Note: the protocols of the scripts are not important for the scope of this article.setup1.png

 

 

 

setup2.png

 

 

 

Sharing actions

In the first use case I want to share an action called “login” between the scripts. The process is a little cumbersome but we might be able to improve it later, bear with me. The first thing I do is create the “login” action in both scripts. This can be done by right-clicking the “actions” node in the project explorer of each script and select the “Create New Action” menu item. The end result is something like this:

sharingActions.png

 

 

 

 

 

 

 

 

 

Next, I create a new directory named “Shared”, in the parent directory of the two scripts (through the Windows File Explorer). This directory will contain my shared resources and. In the “Shared” directory I create a directory called “Actions” that will soon contain the shared action file.

To create the shared action I copy login.c from one of the scripts into the “Actions” directory and delete the login.c file from both scripts through the file system. Don’t do it through VuGen or the scripts will lose track of the action!

The final result looks something like this:

sharingActions2.png

 

 

 

 

Now comes the tricky part when I create the symbolic links for the shared action. To create a symbolic link I open a new CMD window in administrator mode and “cd” into the main project directory (where I have the two script directories and my “Shared” directory) and run the following commands:

mklink  MyScript_1\login.c ..\Shared\Actions\login.c

mklink  MyScript_2\login.c ..\Shared\Actions\login.c

The above Windows commands will create two symbolic links, each in a different script folder, pointing to the shared “login.c” file

CAVEAT: If you try to edit the login actions through VuGen the symbolic link will be broken, perhaps in the future VuGen will prevent that but until then, be careful.

Now I can edit the login.c file from the shared directory and see how both actions are updated:lr_symlink_example.gif

 

 

 

 

After I created the shared action I want to make sure that the scripts still work with various VuGen functions.

  • Replay in VuGen:

replayVugen.png

  

  • Replay in Controller:                                                                                                                                                                           Script was properly copied to the remote LG

    replayControler.png

     

                   

  • Git integration fails to properly commit the file into Git. It looks like a Git problem and not a VuGen problem because it happens with other Git clients as well.
  • Export to zip added the file properly into zip but the symlink will be lost when extracting.
  • I expect uploading to ALM will work the same as with zipped scripts, but I did not test that particular use case.

 

 

VuGen extension

Not many are aware of the fact that VuGen can be extended with your own commands. I created two such commands as a VuGen addin (attached). Simply extract the content of the zip into the <LoadRunnerDir>\AddIns\VuGen\FrontEnd directory and start VuGen as an administrator (creating symbolic links requires administrator privileges, nothing we can do about it). The addin will help you automate some of the processes discussed in this article such as creating the shared action and linking an existing action to the shared one (especially useful if you edited the action in the script and need to re-link it to the shared one).

Now you have two new commands from the context menu of the project explorer:

  1. Right-clicking on the “Actions” reveals a new command “Create new shared action”. Clicking this menu item will create an action in the script but will then ask you to link it to a shared directory where a shared action file will be created.   Vugenext1.png

     

     

  2. Right-clicking on a specific action revels a new command “Link to shared action”. Clicking this menu item will ask     you to link the regular action to a shared action file with the same name. This is also useful if you accidently edit       the action file within the script and not the shared action. Vugenext2.png

     

     

Here is an example of an actual usage of the extension:

 

ezgif.com-optimize.gif

 

 

Conclusion

It is possible (yet very cumbersome) to share actions between scripts. Currently there is no official support for any kind of action sharing but with some careful manipulations on the file system we can achieve a working solution that is very efficient in many cases. If you found this method useful and used it in your projects please tell us in the comments section. If you would like to have official support for shared actions within VuGen don’t forget to hit that feedback button in VuGen (Help menu) and tell us about it.

 

 

Are you interested in more information about LoadRunner, Performance Center or StormRunner? Visit the LoadRunner, Performance Center or StormRunner forums to find information, submit questions and collaborate with peers.

Interested in more information about VuGen? Visit the VuGen Help Center.

  • Load Testing
About the Author

hilale

Attachments