capture the dynamic values in a file

1,214 views
Skip to first unread message

isha isha

unread,
Feb 4, 2011, 2:01:39 AM2/4/11
to LR-Loa...@googlegroups.com
Hello ,
 
Can Anyone help me in saving the captured correlated value (dynamic value) in a file ; which I can pass in some other script as input.
 
I need help urgently.
 
Thanks,
Isha

James Pulley

unread,
Feb 4, 2011, 6:55:01 AM2/4/11
to lr-loa...@googlegroups.com

You’re heading down a well worn path.   Take a look at the Virtual Table Server on disc two of your LoadRunner media.

--
You received this message because you are subscribed to the Google "LoadRunner" group.
To post to this group, send email to LR-Loa...@googlegroups.com
To unsubscribe from this group, send email to
LR-LoadRunne...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/LR-LoadRunner?hl=en

Viral Patel

unread,
Feb 4, 2011, 9:16:57 AM2/4/11
to lr-loa...@googlegroups.com
Even i am trying to do the same.

I have a string value which alphanumeric and dynamic for each iteration. I  have captured that value using web_reg_save_param(correlation) function. The value i captures is not just numeric but it is Alphanumeric again

I am trying to store that captured alphanumeric value in some variable. And later store/write that variable value to file(txt or excel or anything which is feasible).

The code should be something like this,

int i;
int number;
long file;
.
.
.
.
.

//Insert text check to print Donor ID in Replay log
web_reg_save_param("xxx","LB=","RB=","ORD=1","Search=Body","NotFound=WARNING","RelFrameID=1",LAST);


web_submit_data("ServletKeyAction;jsessionid={SessionID}_11", 
"Action=https://", 
"Method=POST", 
"TargetFrame=", 
"Referer=", 
"Snapshot=t55.inf", 
"Mode=HTML", 
        ITEMDATA, 
"Name=fKeyAction", "Value=7", ENDITEM, 
"Name=timer", "Value={Time}", ENDITEM, 
LAST);

//Print value of parameter xxx in replay log
lr_output_message("The value captured for xxx is %s", lr_eval_string("{xxx}"));

//Store or write paramater DonorID values in to file
number=lr_eval_string("{xxx}");

if ((file = fopen(filename, "wb+" )) == NULL) 
{
lr_output_message("Unable to create %s", filename);
return -1;
}

i = fwrite(number, 1, file);
if ( i > 0)
lr_output_message("Successfully wrote %s to textfile, i");
     fclose(file);


Help/suggestion will be appreciated. 



--

James Pulley

unread,
Feb 4, 2011, 10:59:57 AM2/4/11
to lr-loa...@googlegroups.com

Sorry, even if you write it to a file you will not be able to use it as a parameter for another virtual user using the standard parameterization engine.  Why?  Because when the virtual user starts it loads the data file into RAM.  Even if you modify it on the disk you will not see the new values until the next test.  You need a broker to move the values from one user to another.   This is why the virtual table server was born.   If you want a different path there is another options which uses MySQL as a queuing mechanism developed by some guys over in Australia.  Query Google for “LoadRunner MYSQL VTS” and you should wind up in the right place.

 

 

James Pulley, http://www.loadrunnerbythehour.com/PricingMatrix

Cultivate your ‘architectural eye’

John Crunk

unread,
Feb 4, 2011, 11:06:21 AM2/4/11
to lr-loa...@googlegroups.com
She. Capture data and use c reference to write to file. Do a search on reading and writing files in c for plenty of examples

Sent from my iPhone
--

Viral Patel

unread,
Feb 4, 2011, 11:15:04 AM2/4/11
to lr-loa...@googlegroups.com
Thanks James for the comment. I am planning to use those captured values in different script which will be executed later on. You think still it won't work? 

Thanks,
Viral 

Viral Patel

unread,
Feb 4, 2011, 11:18:52 AM2/4/11
to lr-loa...@googlegroups.com
John

What if the captured value is Alphanumeric (typically in my case, like 33DS or 00033TY). 
If i am not wrong than atoi function can be used the save initial portion of the string only, by stopping at the first non-numerical character. 
Any suggestion regarding that?

Thanks,
Viral

John Crunk

unread,
Feb 4, 2011, 11:59:32 AM2/4/11
to lr-loa...@googlegroups.com
Save it as is and then convert it after you read it back in

Sent from my iPhone

John Crunk

unread,
Feb 4, 2011, 12:00:44 PM2/4/11
to lr-loa...@googlegroups.com
Depends on how many virtual users you run as to if it would work and your scenario

Sent from my iPhone

Viral Patel

unread,
Feb 4, 2011, 12:15:01 PM2/4/11
to lr-loa...@googlegroups.com

Correct me if i am wrong. ATOI function will only capture 33 instead of 33DS (whole string). If that is the case than what function i can use?

James Pulley

unread,
Feb 4, 2011, 1:05:35 PM2/4/11
to lr-loa...@googlegroups.com

If you intend to use the data for another test, then you should be OK.  But within the context of the same test you would most likely be hosed unless you go with a brokered passing of the data from one VU to another.

chaitanya bhatt

unread,
Feb 4, 2011, 1:11:05 PM2/4/11
to lr-loa...@googlegroups.com
If both scripts are supposed to run in the same scenario then just create multiple actions (Action_A and Action_B) in the same script and pass the correlated value from Action_A to Action_B.

-Chaitanya M Bhatt
http://www.performancecompetence.com

--

John Crunk

unread,
Feb 4, 2011, 1:21:29 PM2/4/11
to lr-loa...@googlegroups.com
Atoi and the strcat

Sent from my iPhone

Ruslan Kholyavkin

unread,
Feb 4, 2011, 1:18:46 PM2/4/11
to lr-loa...@googlegroups.com
Virtual Table Server (VTS)
      "Farbtafel, 1930" by Paul Klee.  Get this print framed on your wall!
    Get this print framed for your wall!
    The Virtual Table Server (VTS) Windows service maintains a virtual (in-memory) database accessible by several load generators on a network.

    With VTS, several load generators can obtain values from a single common pool of values. One Vuser can create key values (such as a new customer ID), and any number of other Vusers can immediately use that value.

    Sure, a Vuser can make requests to obtain values, but that may impose a different load profile that may not be realistic.

    Without VTS, a single Vuser can only act on values it creates. As of LR8.0 and 9.10, LoadRunner is limited to having each load generator refer to its own parameter files, which means the same static values are used by multiple load generators. VTS provides a way for load generators to communicate with each other in real time.

    If the script "marks" each value as being used, VTS provides a mechanism for allocating unique values among load generators.

    If the script is written to act according to data obtained from VTS, the behavior of load generators can be controlled in real time.

    An alternative to VTS is making calls to a MySQL C API dll and this VuGen code. But beware that call dll's is not thread safe, which requires running as a process rather than thread and thus drastically reducing the number of Vusers which can be run from each load generator machine.

            http://www.wilsonmar.com/1mercvts.htm   more infor here
     
            easily can be done
     
    Thansk,
    Ruslan

    isha isha

    unread,
    Feb 8, 2011, 2:39:09 AM2/8/11
    to lr-loa...@googlegroups.com
    Hi Chaitanya,
     
    Ok I will make it more clear:
    1. I recorded two scripts.
    2. In first some value is created dynamically
    3. I need to use the same value in the second script.
    4. In LR Scenario , I will make 2 groups - 1st group will execute and save all the values generated by different users in a file  - and then I need to call the same file for the 2nd group which will execute after the 1st group finishes.
     
    Is there any function in Loadrunner or any method where I can execute this kind of scenario.
     
    Regards.

    James Pulley

    unread,
    Feb 8, 2011, 9:26:20 AM2/8/11
    to lr-loa...@googlegroups.com

    Your use hinges on when items get loaded into memory for group two and whether you can modify the data file(s) for group two with the output of group one within the same test before the data files are loaded into RAM.   You make the assumption that the data files are not loaded until the group is initialized.   I would not make such an assumption without a direct observable test result to confirm such a hypothesis.

     

    As you are operating within the context of a singular scenario your safest option would be to make use of the Virtual Table Server, or another broker, for passing the information between virtual users.   If you were to be operating in two completely decoupled scenarios, with the execution for scenario two completely independent of scenario one, then you would most likely be safe in the option of having virtual users in scenario one write to data files for users which are a part of scenario two.   Keep in mind you will still need to manage the locking issues associated with multiple processes attempting to access a single file where only one can have exclusive lock for update/write at a time.   This is a non-trivial task and I would still recommend the VTS if you do not have experiencing in managing/programming for such semaphore locking situations.   You can always export the data from VTS into a file if the scenarios remain decoupled.

     

    James Pulley, http://www.loadrunnerbythehour.com/PricingMatrix

     

     

    From: lr-loa...@googlegroups.com [mailto:lr-loa...@googlegroups.com] On Behalf Of isha isha
    Sent: Tuesday, February 08, 2011 2:39 AM
    To: lr-loa...@googlegroups.com
    Subject: Re: capture the dynamic values in a file

     

    Hi Chaitanya,

     

    Ok I will make it more clear:

    1. I recorded two scripts.

    2. In first some value is created dynamically

    3. I need to use the same value in the second script.

    4. In LR Scenario , I will make 2 groups - 1st group will execute and save all the values generated by different users in a file  - and then I need to call the same file for the 2nd group which will execute after the 1st group finishes.

     

    Is there any function in Loadrunner or any method where I can execute this kind of scenario.

     

    Regards.

    On Fri, Feb 4, 2011 at 11:48 PM, Ruslan Kholyavkin <rkhol...@gmail.com> wrote:

    Virtual Table Server (VTS)

    The Virtual Table Server (VTS) Windows service maintains a virtual (in-memory) database accessible by several load generators on a network.

    Error! Filename not specified.With VTS, several load generators can obtain values from a single common pool of values. One Vuser can create key values (such as a new customer ID), and any number of other Vusers can immediately use that value.

    chaitanya bhatt

    unread,
    Feb 10, 2011, 11:14:11 PM2/10/11
    to lr-loa...@googlegroups.com
    You got the following options:

    1. If Script B depends on Script A, then before the test run Scrip A (with single user) and generate as many data as required and parametrize it in Script B and then run the test with Script A and B together. Since Script B is already loaded with data -- using VTS or other tools won't be necessary, Script B can run without depending on Script A's output.

    2. Create two actions in a script, Put Script A and B in separate action blocks, set priority to ensure Script A runs first and then correlate the data generated in script A and pass it to Script B.

    3. Use VTS or Mysql framework.

    The first two solutions are really easy and quite popular. People who directly stoop to the last option may be doing an overkill. Assess your requirement, determine if you really need the last option to be considered.

    Venkat P

    unread,
    Feb 11, 2011, 2:30:09 PM2/11/11
    to LoadRunner
    There is a "0" Solution that needs to be considered before all the
    others (1,2,3) suggested by Chaitanya are required.

    In many cases, ScriptB can login, and do a "Search" and retrieve the
    items waiting for it for review (or they are already waiting there).
    many Testers immediately decided to jump on the "write-to-disk-read-
    from-disk" solution and tend to complicate a simple situation
    unnecessarily.

    I mean, I never had to script for "write-to-disk-read-from-disk" in
    the gadzillion apps I have tested and all these requests leave me a
    bit perplexed.

    In real world terms - its like a Customer Support Executive opening a
    ticket and then walking over to his manager and giving him a piece of
    paper with the ticket number on it to act upon.. Its not required. the
    manager should have the pending items waiting for him when he logs in
    - or at the very least be able to execute a search to locate the
    action items. Or am I missing something?

    -Venkat

    On Feb 10, 11:14 pm, chaitanya bhatt <bhatt.chaita...@gmail.com>
    wrote:
    > You got the following options:
    >
    > 1. If Script B depends on Script A, then before the test run Scrip A (with
    > single user) and generate as many data as required and parametrize it in
    > Script B and then run the test with Script A and B together. Since Script B
    > is already loaded with data -- using VTS or other tools won't be necessary,
    > Script B can run without depending on Script A's output.
    >
    > 2. Create two actions in a script, Put Script A and B in separate action
    > blocks, set priority to ensure Script A runs first and then correlate the
    > data generated in script A and pass it to Script B.
    >
    > 3. Use VTS or Mysql framework.
    >
    > The first two solutions are really easy and quite popular. People who
    > directly stoop to the last option may be doing an overkill. Assess your
    > requirement, determine if you really need the last option to be considered.
    >
    > -Chaitanya M Bhatthttp://www.performancecompetence.com
    >
    > On Tue, Feb 8, 2011 at 1:09 PM, isha isha <ekish...@gmail.com> wrote:
    > > Hi Chaitanya,
    >
    > > Ok I will make it more clear:
    > > 1. I recorded two scripts.
    > > 2. In first some value is created dynamically
    > > 3. I need to use the same value in the second script.
    > > 4. In LR Scenario , I will make 2 groups - 1st group will execute and save
    > > all the values generated by different users in a file  - and then I need to
    > > call the same file for the 2nd group which will execute after the 1st group
    > > finishes.
    >
    > > Is there any function in Loadrunner or any method where I can execute this
    > > kind of scenario.
    >
    > > Regards.
    >
    > > On Fri, Feb 4, 2011 at 11:48 PM, Ruslan Kholyavkin <rkholyav...@gmail.com>wrote:
    >
    > >> Virtual Table Server (VTS)
    >
    > >>        [image: "Farbtafel, 1930" by Paul Klee. Get this print framed on
    > >>    your wall!]
    > >>    Get this print framed for your wall!<http://affiliates.art.com/get.art?T=15039118&A=139536&L=8&P=10054065&...> The
    > >>    Virtual Table Server (VTS) *Windows service *maintains a *virtual
    > >>    (in-memory) database* accessible by several load generators on a
    > >>    network.
    >
    > >>     With VTS, several load generators can obtain values from a single
    > >>    common pool of values. One Vuser can create key values (such as a new
    > >>    customer ID), and any number of other Vusers can immediately use that value.
    >
    > >>    Sure, a Vuser can make requests to obtain values, but that may impose
    > >>    a different load profile that may not be realistic.
    >
    > >>    Without VTS, a single Vuser can only act on values it creates. As of
    > >>    LR8.0 and 9.10, LoadRunner is limited to having each load generator refer to
    > >>    its own parameter files, which means the same static values are used by
    > >>    multiple load generators. VTS provides a way for load generators to
    > >>    communicate with each other in real time.
    >
    > >>    If the script "marks" each value as being used, VTS provides a
    > >>    mechanism for allocating unique values among load generators.
    >
    > >>    If the script is written to act according to data obtained from VTS,
    > >>    the behavior of load generators can be controlled in real time.
    >
    > >>    An alternative to VTS is making calls to a MySQL C API dll<http://%20http//dev.mysql.com/doc/refman/5.0/en/c-api-functions.html>and this
    > >>    VuGen code<http://www.jds.net.au/tech-tips/query-mysql-with-loadrunner/>.
    > >>    But beware that call dll's is not thread safe, which requires running as a
    > >>    process rather than thread and thus drastically reducing the number of
    > >>    Vusers which can be run from each load generator machine.
    >
    > >>        http://www.wilsonmar.com/1mercvts.htm  more infor here
    >
    > >>         easily can be done
    >
    > >> Thansk,
    > >> Ruslan
    >
    > >>   On Fri, Feb 4, 2011 at 10:11 AM, chaitanya bhatt <
    > >> bhatt.chaita...@gmail.com> wrote:
    >
    > >>> If both scripts are supposed to run in the same scenario then just create
    > >>> multiple actions (Action_A and Action_B) in the same script and pass the
    > >>> correlated value from Action_A to Action_B.
    >
    > >>> -Chaitanya M Bhatt
    > >>>http://www.performancecompetence.com
    >

    chaitanya bhatt

    unread,
    Feb 12, 2011, 11:34:10 PM2/12/11
    to lr-loa...@googlegroups.com
    Correct! I concur.
     
    -Chaitanya M Bhatt

    James Pulley

    unread,
    Feb 13, 2011, 10:01:32 PM2/13/11
    to lr-loa...@googlegroups.com
    True on so many levels. The topic of pre-staging data is one which has
    been discussed many times as an alternative to the dynamic producer
    consumer model within a test. In many ways this comes back to
    answering the question asked versus the question the person should be
    asking (if research has been done).

    In fifteen years I think I have had to use VTS once. Very other time I
    pre-staged enough data at the points of production for consumption
    during the test.

    'Pulley

    Floris Kraak

    unread,
    Feb 14, 2011, 4:05:43 AM2/14/11
    to lr-loa...@googlegroups.com
    On Mon, Feb 14, 2011 at 4:01 AM, James Pulley
    <loadrunn...@jamespulley.com> wrote:
    > True on so many levels.  The topic of pre-staging data is one which has
    > been discussed many times as an alternative to the dynamic producer
    > consumer model within a test.   In many ways this comes back to
    > answering the question asked versus the question the person should be
    > asking (if research has been done).
    >
    > In fifteen years I think I have had to use VTS once.  Very other time I
    > pre-staged enough data at the points of production for consumption
    > during the test.

    I've used VTS twice - once to produce data for later consumption(!),
    once because a tools vendor required it's use.

    And in the latter case using VTS was understandable only because
    loadrunner's rendezvous functionality didn't quite cover what was
    needed. (And even then, the implementation of it was ugly as sin and
    broken beyond belief..)

    Next time I have a need that it might cover I'll probably use MySQL instead.

    Regards,
    Floris
    ---
    'Many people asked me if I was afraid to fly and implied that I should
    have stayed home, close to family and friends. I replied that if I had
    stayed home, the terrorists would have won.

    Unfortunately, my government does not agree with my definition of
    winning. They think that living in fear and trying desperately to keep
    us all 100% safe while flying is the most effective way to fight
    terrorism. It reminds me of a boss that told me he liked it when
    people lived in fear of being fired, they worked harder. I told him
    being fired held no fear for me. When you live in fear, you do
    irrational things - like sending millions of people's shoes through an
    xray scanner every day.'
       -- Stormy Peters

    Reply all
    Reply to author
    Forward
    0 new messages