James Pulley, http://www.loadrunnerbythehour.com/PricingMatrix
--
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
Below will help you 100 % this my script used in project
Action()
{
int fp,i,j;
//LPCSTR Rows;
char new_dir[] = "C:\\anaz";
//Create a directory under root called anaz and make it the current dir
if (mkdir(new_dir)==1)
{
lr_output_message ("Directory already created %s ", new_dir);
goto FILEOPEN;
return -1;
}
//Rows=lr_get_attrib_string("rows");
//j=atoi(Rows);
FILEOPEN:
//fp = fopen("c:\\anaz\\my_file{FileName}.csv","w+");
fp=fopen(lr_eval_string
("c:\\anaz\\my_file{FileName}.csv"), "w+");
if (fp==0)
{
lr_error_message ("Cannot open file, it is already opened %s", fp);
return -1;
}
fprintf(fp,"FirstName,LastName,Email,Salutation,title,street,City,State,Country,zip,phone,Department,Custom1,Custom2,Cost
Center\n");
for(i=0;i<=10;i++)
{
fprintf(fp,"%s",lr_eval_string("{FN},{SN},{FN}{SN}@may.com,{SAL},{Title},{Street},{City},{State},{Country},{ZIP},{Phone},DEV,cust1,cust2,cost1\n"));
}
fclose(fp);
//char fp= lr_eval_string("c:\\anaz\\my_file{FileName}.csv");
/*if (remove(lr_eval_string ("c:\\anaz\\my_file{FileName}.csv")) == 0)
lr_output_message (lr_eval_string("Removed new file
c:\\anaz\\my_file{FileName}.csv"));*/
//else
//lr_output_message ("Unable to remove the file %d error %d", fp);
/*if (rmdir(new_dir) == 0)
lr_output_message ("Removed new directory %s", new_dir);
else
lr_output_message ("Unable to remove %s error %d", new_dir);*/
return 0;
}
--
Regards,
Anaz
Looking at your code I suspect you will have the following issues moving
forward
(1) When you get to the load generator your directory creation is in context
to the local disk of the load generator. You may run into issues with
directories you expect to me in place not being in place.
(2) If you don't properly manage your {Filename} parameter you will run into
lock situations where two threads/users attempt to obtain a lock against a
common resource for the purposes of file update. Be careful here to ensure
that your {Filename} is unique per virtual user or adjust your code to
include an explicit semaphore token to let vusers/threads know when it safe
to obtain an exclusive lock for writing.
(3) It is interesting that you are writing our a comma separated variable.
Traditionally when this occurs it is being done as expected input to another
virtual user. The problem with this model is that when a virtual user
starts it takes a copy of the parameter file and places it in RAM. From
this point forward no additional disk access is needed for the virtual user
to hit its parameters, but also no additional updates to the file will be
reflected in the data set used by the virtual user. HP recognized this
years ago and made available the virtual table server to address this
inter-user use of data where one business process depends upon the output of
another. What else does this imply, if you use the Seattle phone book as
your data source for random names and addresses, as was observed one time,
do not be surprised if your resource costs per virtual user are extremely
high on the RAM side. As an alternative to VTS there is also a solution
based upon MYSQL on the market. A couple of quick Google queries on 'MYSQL
VTS LoadRunner' should point you in the right direction.
You are still not clear as to your end goal. You can certainly include readme.txt as an extra file in your virtual user definition such that it will be uploaded to performance center and will also be distributed to your load generators as a part of the virtual user definition.
There is nothing so exotic about performance center as to cause you to develop your virtual users any differently. In the end you have controllers and load generators as a part of the performance center architecture just as you have as a part of the standard LoadRunner deployment model. So long as you construct your virtual user in an environment neutral fashion, using best practices to limit external dependencies you should be fine. What you seem to be confused about is where information is being written and what resources your virtual user can access and how.
James Pulley, http://www.loadrunnerbythehour.com/PricingMatrix
From: lr-loa...@googlegroups.com [mailto:lr-loa...@googlegroups.com] On Behalf Of Gaurav Mishra
Sent: Monday, December 13, 2010 11:20 AM
To: lr-loa...@googlegroups.com
Subject: Re: file handling in LR
@anaz : every thing is looking fine exept 1 thing ....... i need to run my script on performance centre but i can't give a filepath .so i need to upload that file in vugen itself.
--
This is a sample code
For your better understanding of the file operation functions. You
need fine tune it as per your own requirement
Gaurav
This script will run on performance center as on code it will create
folder in C drive in the name anaz (in load generator in which
actually script runs)
No worries it will deleted , In the mean time make note of parameter
names settings options threads etc......
Line is drawn just build your buildings
--
Regards,
Anaz