Results 1 to 10 of 10
  1. #1

    Executing Visual Basic Script from LR Script

    I am using LoadRunner 8.2. I have a requirement to test a load balancing script which will randomly spread out users to different web servers. This script is written in Visual Basic and will be residing on client PCs.
    When the user(s) will click on this VB Script icon, it will generate a random number and depending on that it will log the user to a selected web server.

    Can anyone please let me know how to execute this VB Script from LoadRunner script? Also, which protocols to use? For recording the main application, I am using Web and Oracle NCA.

  2. #2

    Re: Executing Visual Basic Script from LR Script

    First, please check the information below:



    Briefly, if the VB app is simple enough, just recode the logic into C into the LR script.
    Unless you are writing a compiler, strtok is NOT the answer.
    See: http://www.sqaforums.com/showflat.ph...=541641#542222

    QAF is still an exercise in self-sufficiency! (Thank JB!)

  3. #3

    Re: Executing Visual Basic Script from LR Script

    1. What version of LoadRunner or PerformanceCenter are you using? 8.1
    2. What is the protocol you are working with? Web/Oracle NCA
    3. Which LoadRunner/PerformanceCenter feature or service packs are you using? None
    4. What kind of LoadRunner license do you have - subscription, perpetual, Virtual User days, or evaluation? perpetual
    4.1 If subscription, is subscription current or expired?
    5. What platform(s) and Operating Systems? Include version and service packs. Windows
    6. If you have filed a service request with Mercury, what have they told you at this point with respect to your issue?
    No replies

    The VB script is a very basic script which generates random number. If the number returned is either 1 or 2, it will use the url to log into webserver1 or if it is 3 or 4, it will re-direct to webserver2. It is a very basic script to load balance. My AUT is basically Web based using Oracle. I am not sure if I should record the VB script at all in my VUGen script or record the application and then add this part of VB Script in the init section?

  4. #4

    Re: Executing Visual Basic Script from LR Script

    Sounds to me like the easiest way to do this would be to do the random selection of which webserver to use within the LR script and then just use whichever webserver was selected. I'd forget about linking to your VB code.

    You could have the two webserver URLS in a file that are read and stored as a random parameter on each iteration. That way it'll all be handled by the random parameter not program code.
    You're not paranoid if they really are out to get you.

  5. #5

    Re: Executing Visual Basic Script from LR Script

    Thanks GM. I also thought about it but the problem is that when we go live, the same VB script is going to get used from each client terminal. They will click the VB Script icon and it will determine which webserver it will connect the user to. So, I need to include this VB script to check whether it works or not (rather it can load balance or not). The objective of my test is that using this VB Script, I am going to run 1500 VUsers logging, maybe, in chunks of 200-300 at a time and see whether they are directed to webserver in a way that the load is balanced out.

  6. #6

    Re: Executing Visual Basic Script from LR Script

    <font class="small">Code:</font><hr /><pre>
    int hostswitcher = rand() % 4;

    switch( hostswitcher )
    case 0:
    case 1 :
    case 2 :
    case 3 :

    "Url=resources/images/example2.jpg", ENDITEM,
    </pre><hr />

    Don't confuse a performance test of your server with a functional test of your front end code, which is what you are doing here. If you need for your virtual user to round robin with an apprximately even distribution, then code it into your virtual user.

    The example above round robins for four items. You could use a simple if/then/else structure for a round robin of two items. Test your VB script another way. Use a sniffer and watch what comes out of the back end of your code.

    If you insist on glueing it into your virtual user, then get the algortithm and recode it in C and place it into your virtual user code. The alternative, taking a piece of code designed to be single threaded for a single user access and now having tens or hundreds attempt to access the same object possibly concurrently is fraught withe design problems. You may blame the app or LoadRunner for a failed test, but what really would have happened is you are now attempting to access code in such a way that it was never designed for.

    Think outside of the box. Random number, split evenly between two values. There are probably a dozen ways to implement this algorithm in LoadRunner independent of your single user access piece of VB code running on someone's desktop.

    Think process. By the time you get to performance testing, you already know that whatever process you are testing works always for one user. For if it does not work for one, it shall never work for more than one. Here you have a situation where you do not know if you algorithm yet works for one to provide an even round robin between the hosts. Process-wise you are not yet ready to load test.
    James Pulley

    Replace ineffective offshore contracts, LoadRunnerByTheHour. Starting @ $19.95/hr USD.

    Put us to the test, skilled expertise is less expensive than you might imagine.

    Twitter: @LoadRunnerBTH @PerfBytes

  7. #7
    SQA Knight
    Join Date
    Jan 2002
    Highlands Ranch, CO, USA

    Re: Executing Visual Basic Script from LR Script

    I don't see why you couldn't take the VBScript code from the .VBS file and just drop it into a VBScript protocol LR script. From there you can get it to do pretty much what you want and job up as many VU's to do the work. You could even combine this into a multi-protocol script.

    As an example I once wrote a VBScript protocol script to generate emails for a project. We needed to have a constant inflow of test emails to the application (workflow system for claims processing) so that we could work the claim down the line. This script was run in conjunction with the regular Web/HTML scripts in the controller.

    Just an idea.
    For all the general stuff to know about QA/Test go here http://www.softwareqatest.com/

  8. #8

    Re: Executing Visual Basic Script from LR Script

    Why make it so complex? Ok it's not that complex. Create actions for each server that sets the server variable. Use the "run logic" in the runtime settings to set up your random distribution to mimic your vbscript load balancing code. It's a little more flexible for people who can't code. Using the run logic can be very useful and is a good thing to learn. It will be more simple to adjust.

  9. #9

    Re: Executing Visual Basic Script from LR Script

    Thanks James for your suggestion on using code to randomise. I have used it in my scripts to mimic what happens in Production set-up.

    I have another query related to this. I am asking this under the same thread as I am not sure to open up another thread.

    The piece of code randomise and selects the webserver name (out of 2) which is passed to the login script. I am running such scripts with 1000 VUsers logging from the controller. When I analyse the results, is there any way to trap how many Vusers logged on either of the webservers? I will be using Apache monitors but not sure which measurement will provide me with this info.

    Any help will be much appreciated.


  10. #10

    Re: Executing Visual Basic Script from LR Script

    What you might want to do is fiddle with the transaction names. That should give you an idea of how many worked against server one and how many against two.

    For example: (C + pseudocode)

    <font class="small">Code:</font><hr /><pre>
    int servernum;
    char *serverlist[2] = {"www.server1.com", "www.server2.com"};

    servernum = random from 0 to 1;
    lr_save_string(serverlist[servernum], "USESERVER");

    lr_start_trans(servernum ? "Server2_Login" : "Server1_Login");


    </pre><hr />
    Unless you are writing a compiler, strtok is NOT the answer.
    See: http://www.sqaforums.com/showflat.ph...=541641#542222

    QAF is still an exercise in self-sufficiency! (Thank JB!)



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
BetaSoft Inc.
All times are GMT -8. The time now is 03:39 PM.

Copyright BetaSoft Inc.