Sunday, March 1, 2015

L.R._File Operations-Sample



Action()
{
    char *filename = "D:\\sundar\\From_LR\\cntr_wid_date_112.txt";
    long file;
                char *groupname;
                int id,m,n;
                m=rand()%21+20;
    n=atoi(lr_eval_string("{VID}"));
                lr_output_message("Vuser ID is: %d",n);
                lr_save_datetime("%y%m%d", DATE_NOW, "FileDate");
                lr_save_datetime("%y/%m/%d", DATE_NOW, "Date");
                lr_save_datetime("%H:%M", TIME_NOW, "Time");
// Create a new file
                file = fopen(filename, "a+" );
fprintf(file, "Random number is: %d and Vuser Number is:  %d \n and today is: %s, at %s on %s. \r\n",m,n,
     lr_eval_string("{FileDate}"), lr_eval_string("{Time}"), lr_eval_string("{Date}"));

// Write the Vuser ID and group to the log file
    lr_whoami(&id, &groupname, NULL);
    fprintf(file, "log file of virtual user ID: %d group: %s\n", id, groupname);
/*  lr_save_datetime("%y%m%d", DATE_NOW, "FileDate");
      lr_save_datetime("%y/%m/%d", DATE_NOW, "Date");
       lr_save_datetime("%H:%M", TIME_NOW, "Time");

// Write the Vuser ID and group to the log file
                                sprintf(OutputFile,"D:\\sundar\\From_LR\\output_33_2.txt", lr_eval_string("{FileDate}"),
                lr_eval_string("{Iteration}"),
                lr_eval_string("{Time}"),
                lr_eval_string("{Date}"));
                lr_whoami(&id, &groupname, NULL);
    fprintf(file, "log file of virtual user ID: %d group: %s\n", id, groupname);   */
    fclose(file);
    lr_think_time(10);
return 0;
}



Note: Some of the articles are grab from various Websites / Blogs.

Load Runner - Functions_v0.1


Action()
{
    /*      Shyam S.Reddy ---- 2015    */

    lr_message("text");  //
    lr_output_message("Ttext");         //To print an output message
    lr_error_message("text");               // To print error message (Error message will be in red)
    lr_save_string("text1","text2");     // To replace text2 with text1

 /*     Find the current iteration Number is::  First create a "Parameter List-->>New-->> Parametertype=iteration number-->>specify text format ->  01, 001, 0002    */


  lr_output_message("Current iteration number is:   %s", lr_eval_string("{Iterat_NoPRM}"));
  Output is:: Action.c(11): Notify: Parameter Substitution: parameter "Iterat_NoPRM" =  "01"
        Action.c(11): Current iteration number is:   01
        (02, 03, 04,...... based No. of iterations specified in "Run Logic")

    lr_start_transaction("SSR_Login_HomePage");
/*  startig transacations bla bla....  */
    lr_end_transaction("SSR_Login_HomePage", LR_AUTO);

    web_reg_save_param("Name","LB=","RB=","ORD=",LAST); //Correlation
    depcity=lr_paramarr_random("Cities"); //Storing "Cities" randomly in a C variable
    city:
    arrcity=lr_paramarr_random("Cities"); //Storing "Cities" in a C variable
        if(strcmp(depcity,arrcity)==0) // If statement
        {
        goto city;
        }
    lr_save_string(depcity,"Depcity"); //Saving Loadrunner variable
    lr_save_string(arrcity,"Arrcity");

    lr_output_message("Travelling from %s") //Printing out message in LR

    temp=lr_paramarr_idx("OFlight",1); //Picking "OFlight" value randomly and Storing in a C variable
    token=(char*)strtok(temp," ");  //strtok returns a token from a string delimited by specified characters.

    lr_save_string(token,"OFlight_1");     //_1 is to replace the first value

    i=rand()%4+1;
    oflight=lr_paramarr_idx("OFlight",i);
    lr_save_string(oflight,"flight");

    Char *text  //Defining Character
    int i;  //Defining Integers

    web_reg_find("Text=Web Tours", "SaveCount=test1",
        LAST)   // To save the count of Text occurance

/*   Array Merging   - SSR */
    int i,l,m,x,y,z;
    char *depcity,*arrcity,*seatpref,*seattype,*temp,*token,*oflight;

    l=lr_paramarr_len("Cities");
    m=lr_paramarr_len("city");

    for(x=1;x<=m;x++)
    {    temp=lr_paramarr_idx("city",x);
        lr_save_int(l+x,"int");
        lr_save_string(temp,lr_eval_string("Cities_{int}"));
    }
        y=rand()%20+1;
    depcity=lr_paramarr_idx("Cities",y);
city:
    z=rand()%20+1;
    arrcity=lr_paramarr_idx("Cities",z);

    if(strcmp(depcity,arrcity)==0)
    {
        goto city;
    }
    lr_save_string(depcity,"Depcity");
    lr_save_string(arrcity,"Arrcity");
    //lr_output_message("Travelling from %s")

    seatpref=lr_paramarr_random("SeatPerf");
    lr_save_string(seatpref,"SPref");

    seattype=lr_paramarr_random("SeatType");
    lr_save_string(seattype,"SType");    /*  Array merging ended SSR */

   i=web_get_int_property(HTTP_INFO_RETURN_CODE); // To save the responce code of the web page (Used in Error handling)
    i=web_get_int_property(HTTP_INFO_DOWNLOAD_SIZE); // To save the size of downloaded file
    i=web_get_int_property(HTTP_INFO_DOWNLOAD_TIME); // To save the
    i=web_get_int_property(HTTP_INFO_TOTAL_REQUEST_STAT); // Returns the accumulated size of all headers and bodies since the first time web_get_int_property was issued 
    i=web_get_int_property(HTTP_INFO_TOTAL_RESPONSE_STAT); // Returns the accumulated size, including header and body, of all responses since the first time web_get_int_property

    LR_EXIT_VUSER // Exit without any condition, and go directly to end action
    LR_EXIT_ACTION_AND_CONTINUE  //Stop current action, and go to the next action.
    lr_exit(LR_EXIT_MAIN_ITERATION_AND_CONTINUE,LR_FAIL);
return 0;
}
                        /*      Shyam S.Reddy ---- 2015    */

 

Note: Some of the articles are grab from various Websites / Blogs.

Friday, August 9, 2013

OPTIM - FAQ's -- III

Optim to convert critical information such as Social Security number (TRANS SSN), credit card number (TRANS CCN), and e-mail IDs (TRANS EML). There are several other functions available in Optim in the data privacy area that provide various masking functions. For example, some of the functions include:
LOOKUP, a function that uses a lookup table to determine the destination column value

HASH_LOOKUP, a function that determines the destination column value from a lookup table according to a value derived from a source column

RAND_LOOKUP, a random lookup function that selects a value for the destination column from a lookup table based on a random number as the subscript in the lookup table

TRANS SSN flags and their descriptions
Flags   Description
n          Generates a random area number and an appropriate group number and serial number.
r          Generates a random area number corresponding to the state of the source SSN and an appropriate group number and serial number.
v          Validates the source group number to ensure the SSN has used it.
-           Generates an SSN with dashes separating the fields (for example, 123-45-6789). Requires a character-type destination column at least 11 characters long.

The TRANS CCN function is used to generate valid and unique credit card numbers (CCNs). A CCN usually consists of a six-digit issuer identifier followed by a variable-length account number and a single-check digit as the final number. By default, TRANS CCN algorithmically generates a consistently altered CCN, but it can also generate a random value for CCN.

The execution steps followed in this section (used to mask credit card numbers) are similar to the steps followed during the execution of the SSN scenarios. All three scenarios described in this section differ from each other with respect to the source file, control file, destination file, and flags used in TRANS CCN function.

TRANS CCN flags and their descriptions

Flags   Description
n          Generates a random CCN, not based on a source value, that includes a valid issuer
identifier associated with American Express, MasterCard, VISA, or Discover.
r          Generates a random CCN that includes the first four digits of the source issuer identifier.
6          Generates a random CCN that includes the first six digits of the source issuer identifier.

TRANS EML

The TRANS EML function is used to generate an e-mail address. An e-mail address has two parts—the user name and the domain name, separated by the at sign (@).

The TRANS EML function generates e-mail addresses based on either the destination data or a literal concatenated with a sequential number. The domain name can be formed using either the source data or randomly chosen from a long list of e-mail service providers. E-mail addresses can also be converted to upper or lower case.

The execution steps followed in this section (where the scenarios will work on e-mail accounts) are similar to the steps followed during the execution of SSN scenarios. Hence, usage of only one is given here, and the rest can be executed in the same way with only the change of the flag values.

TRANS EML flags and their descriptions
Flags   Description
n          Ignores the source value and generates an e-mail address with a random domain name from a list of large e-mail service providers.
.           Separates the name1col and name2col values with a period (.).
-           Separates the name1col and name2col values with an underscore (_).
i           Uses only the first character of the name1col value.
l           Converts the e-mail address to lower case.
u          Converts the e-mail address to upper case.

Note: Some of the articles are grab from various Websites / Blogs.