Our legacy site: www.webwob.com   

VUgen scripting methods (page 1)

This page will cover more LoadRunner scripting methods, following on from the legacy site pages.

     LoadRunner CI/CD      *_LR_CI_*      LR_CI_+      Email_out      Email_in      Cookies 1      TUTORIAL      sprintf      debug      VUgen      Kill -9      disk space      AWS S3      dig (DNS++)      substitute      curl with timings      LR_Jenkins_graphs     

Move a cookie across domains. Thus was used when our Perf env didn't have the login app but Stage did

VuGen code snippet for adjusting cookies

    #include "time.h"
    time_t timer;
    char buffer[26];
    struct tm* tm_info;
    tm_info = localtime(&timer);
    lr_message("timer: %ld",timer);
    //16–Nov–2016 23:12:40 GMT;
    //strftime(buffer, 26, "%Y-%m-%d %H:%M:%S", tm_info);
    strftime(buffer, 26, "%d-%b-%Y %H:%M:%S GMT", tm_info);
    timer = timer + 86400; //add 24 hours
    tm_info = localtime(&timer);
    lr_message("timer: %ld",timer);
    //16–Nov–2016 23:12:40 GMT;
    //strftime(buffer, 26, "%Y-%m-%d %H:%M:%S", tm_info);
    strftime(buffer, 26, "%d-%b-%Y %H:%M:%S GMT", tm_info);
        sprintf(strtemp1,"CS_Identity=%s; path=/; expires=Wednesday, %s; domain=perf.server.com",lr_eval_string("{CS_Identity}"),buffer);
        lr_output_message("%s", strtemp1);
        sprintf(strtemp2,"CS_Identity=%s; path=/; expires=Wednesday, %s; domain=stage.server.com",lr_eval_string("{CS_Identity}"),buffer);
        lr_output_message("%s", strtemp2);
        //These cookie details were first seen in full in a Fiddler trace response from one of our
calls, inside a 'Set-Cookie:' statement:

        //web_add_cookie ("CS_Identity=eyJkaXNwbGF5TmFtZSI6Ik1hcmsiLCJn ZW5kZXIixxxxxxxFIiwiYWdlIjoiMzQiLCJ1c2VySWQiOiI2ZWE4MT UwNy01NmUxLTRjOWQtYTJjMS0wZDUwYzhiZWY4YzUiLCJ0eXBlIjoiQzQi LCJyZW1lbWJlck1lIjoiZmFsc2UiLCJjcmVhdGVkIjoiMTQ3OTIwOTU1MD E3MiIsImhhc2giOiJiVjE2V2pVbmtubEwydWNJSThhUzVnIiwixxxxxx Vzc0NhcHR1cmVkIjoidHJ1ZSJ9; path=/; expires=Wednesday, 16–Nov–2016 23:12:40 GMT; domain=perf.server.com");
        web_remove_cookie("CS_Identity"); //This removes the named cookie from all domains
        web_add_cookie (strtemp1);
        Note: To get the full date in, with the DAY as well, I had to adjust the above slightly:         

        char buffer2[52];
        strftime(buffer2, 52, "%A, %d-%b-%Y %H:%M:%S GMT", tm_info);
        Output is now:
        timer: 1479379838
        17-Nov-2016 10:50:38 GMT
        timer: 1479466238
        18-Nov-2016 10:50:38 GMT
        Friday, 18-Nov-2016 10:50:38 GMT
        ( I got format info from here: http://apidock.com/ruby/DateTime/strftime )    

Exit job if controller already running on this machine

shell script to run from within Jenkins

##Maybe split this up and run the test at the top of the Jenkins job
echo exit job if controller already running on this machine
tasklist > tasks.txt
grep Wlrun.exe tasks.txt
Wlrun=$(grep Wlrun.exe tasks.txt | wc -l)
echo Wlrun value is currently ${Wlrun}
if [ "${Wlrun}" -ge "1" ]
    echo Controller IS IN USE. Cant carry on here. Exiting NOW.
    exit 1
    echo controller not in use. Will start the scenario here
    /cygdrive/c/loadrunner/program/HP/loadrunner/bin/wlrun.exe -Run -TestPath "${scenario}" -ResultsName "${results}"