Service Virtualization

Expand all | Collapse all

How to set delay for particular set of requests

  • 1.  How to set delay for particular set of requests

    Posted 4 days ago

    Hello All,

    We have scenario, like fixed response delay for particular set of requests.
    For ex: first 30 % requests or 30 requests with 300ms.
    another 20% or 20 requests with 600ms.
    so on..

    How we can accomplish this? just need guidance and way to achieve this which we can implement.

    Thanks,
    Mohammed Sheeraz



  • 2.  RE: How to set delay for particular set of requests

    Broadcom Employee
    Posted 4 days ago
    Hi,

    The approach below wouldn't need any scripting.

    In your VSI, for each of the transactions that are part of this scheme set the Think Time of the transaction to a property, eg. {{DynamicThinkTime}}

    Then create a one-column CSV file in your "data" subfolder, that has following content (it needs to have a header line and 10 datalines), eg.

    DynamicThinkTime
    300
    300
    300
    600
    600
    900
    150
    150
    150
    150

    This would represent: 30% 300ms, 20% 600ms, 10% 900ms and 40% 150ms

    Then add a "Read Rows from Delimited Data File" dataset to your "VS Image Response Selection" data step, with following definition:
    - File Location: Select the above create file as File location,
    - Set the dataset as: Random
    - Max records to Fetch: 10
    - At End: Start Over

    Give it a try, I hope it works  as good in real life as it does inside my head.

    Cheers,

    Danny Saro

    Client Services Consultant

    Broadcom Software


    -------------------------------------------------


    This electronic communication and the information and any files transmitted with it, or attached to it, are confidential and are intended solely for the use of the individual or entity to whom it is addressed and may contain information that is confidential, legally privileged, protected by privacy laws, or otherwise restricted from disclosure to anyone else. If you are not the intended recipient or the person responsible for delivering the e-mail to the intended recipient, you are hereby notified that any use, copying, distributing, dissemination, forwarding, printing, or copying of this e-mail is strictly prohibited. If you received this e-mail in error, please return the e-mail to the sender, delete it from your computer, and destroy any printed copy of it.





  • 3.  RE: How to set delay for particular set of requests

    Posted 4 days ago

    Hi Danny,

    Thanks for your quick response.

     I tried the above steps but it couldn't help me to achieve the requirement. I might be doing some mistake please check the below steps I performed.

    1.I have doubt here, am I doing correct setting up the property to think time.
    2.
    3.
    4.CSV file




  • 4.  RE: How to set delay for particular set of requests

    Posted 4 days ago
    If it is challenging can we randomize delay like min to max for particular transaction
    for ex : I want min 200ms and max 1200ms for a transaction


  • 5.  RE: How to set delay for particular set of requests

    Broadcom Employee
    Posted 4 days ago
    Hi Mohammed,

    It works on my side.

    I think there are 2 attention points.

    1. First, I notice you created your CSV file within Excel. If so, have you checked how it looks when you open it as a text file? Make sure it looks like this:

    DynamicThinkTime;
    300;
    300;
    300;
    600;
    600;
    900;
    150;
    150;
    150;
    150;

    I had much more than 10 rows initially (lots of empty rows) when I opened the Excel created file. Also make sure you set your delimiter character correct in the Dataset definition, it has to be a semicolon.
    With the above data file the following dataset definition works for me:

    image.png

    2. Secondly, are you testing this in a functional VSE? If so, then you can only achieve 10 transactions per second. If you use many virtual users to run your test case than the VSE will slow down the request so the throughput gets throttled to 10 tps.

    For testing, when I used a lisa testcase with one REST step with thinking time set to 1 second, and when using a staging document with 1 instance and RunMAx Nbr of Times equal to 100, I got the following step response times:

    46% between 156 to 175 ms
    23% between 308 to 326 ms
    19% between 607 to 625 ms
    12% between 910 to 922 ms

    The milliseconds are a bit higher as the VSI think time because they are measured from the client side, so it includes client processing time, network latency, ...

    Percentages are not perfect because of the 'random' effect; if you switch off random then they will be perfect but they follow the pattern as defined in the CSV file.

    Hope this helps,

    Danny Saro

    Client Services Consultant

    Broadcom Software


    -------------------------------------------------


    This electronic communication and the information and any files transmitted with it, or attached to it, are confidential and are intended solely for the use of the individual or entity to whom it is addressed and may contain information that is confidential, legally privileged, protected by privacy laws, or otherwise restricted from disclosure to anyone else. If you are not the intended recipient or the person responsible for delivering the e-mail to the intended recipient, you are hereby notified that any use, copying, distributing, dissemination, forwarding, printing, or copying of this e-mail is strictly prohibited. If you received this e-mail in error, please return the e-mail to the sender, delete it from your computer, and destroy any printed copy of it.





  • 6.  RE: How to set delay for particular set of requests

    Posted 3 days ago

    Hi Danny,

    It worked for me thanks a lot.

    I made a mistake in csv file by missing semicolon and I'm testing in the performance VSE for load test, as you said followed the same steps could able to achieve percentage which is almost near to expected results. I will try disabling the random option hope will see exact numbers.

    And, one more method I tried to give random response time in the VSI think time spec not sure whether it is a relevant way but could see some 50% success rate, might be doing some mistake here.

    It gives me the response time up to 550ms not reaching max response time as mentioned in the think time spec.




  • 7.  RE: How to set delay for particular set of requests

    Broadcom Employee
    Posted 3 days ago
    Hi Mohammed,

    Good to hear it helped.

    With regards to generating random response times, I am not sure that you would be able to specify ranges. I think IF it would work then try specifying it as follows: 200-1200  . This is the way how think time ranges for a step in .tst or .vsm files are saved to file.

    One approach that does work would be to create a java one-liner; whenever you wanna do something and you can put it in a one-line expression then it is easy to use it instead of a property (to be correct, you put it in as the right-hand side of a java variable assignment statement, starting from the equal-sign, and ending with the semi-colon) . Try the following as Think Time:

    {{=java.util.concurrent.ThreadLocalRandom.current().nextInt(200, 1200 + 1);}}


     Cheers,

    Danny Saro

    Client Services Consultant

    Broadcom Software


    -------------------------------------------------


    This electronic communication and the information and any files transmitted with it, or attached to it, are confidential and are intended solely for the use of the individual or entity to whom it is addressed and may contain information that is confidential, legally privileged, protected by privacy laws, or otherwise restricted from disclosure to anyone else. If you are not the intended recipient or the person responsible for delivering the e-mail to the intended recipient, you are hereby notified that any use, copying, distributing, dissemination, forwarding, printing, or copying of this e-mail is strictly prohibited. If you received this e-mail in error, please return the e-mail to the sender, delete it from your computer, and destroy any printed copy of it.





  • 8.  RE: How to set delay for particular set of requests

    Posted 3 days ago

    I tried with both the options it worked.

    By having 200-1200, got the same results as with java one-liner.

    To generate random response times, we can give it a try of any one of these options.

    thank you so much for your help.




  • 9.  RE: How to set delay for particular set of requests

    Posted 2 days ago
    Thanks for the update

    ------------------------------
    Regards,
    Vaibhav Jain
    Capgemini
    ------------------------------



  • 10.  RE: How to set delay for particular set of requests

    Posted 3 days ago
    Hi Sheeraz,

    As per your requirement you have to kind of track the previous requests as the next thinktime may be dependent on it. Easiest way is to configure the data set (within tool or outside tool like a csv or delimited file).

    For dataset, you can use the start again when data exhausts.

    Thanks

    ------------------------------
    Regards,
    Vaibhav Jain
    Capgemini
    ------------------------------



  • 11.  RE: How to set delay for particular set of requests

    Posted 3 days ago
    Thanks Danny and Vaibhav for your inputs, this really helps to achieve my requirement.


  • 12.  RE: How to set delay for particular set of requests

    Posted 3 days ago
    No worries

    ------------------------------
    Regards,
    Vaibhav Jain
    Capgemini
    ------------------------------