Service Virtualization

Expand all | Collapse all

Responding with 1 rsp followed by another rsp for 1 req

Jump to Best Answer
  • 1.  Responding with 1 rsp followed by another rsp for 1 req

    Posted 07-06-2016 04:23 PM

    Hi everyone,

     

    I have to virtualize a JSON req, which has 2 rsps - rsp1 and rsp2. The goal is to setup the VSE in such a way that when a req comes in, VSE should send rsp1, then after 10 seconds, send rsp2. So far, the VSE is able to respond with just rsp1.

     

    Also, in the responses, I have to provide the current time-stamp (example: 2016-07-06 T 04:15:52.063) . I tried passing the values through config file, and tried parameterizing the timestamp in the VSI, and neither worked.

     

    Can someone provide any tips on how I can accomplish the above two?



  • 2.  Re: Responding with 1 rsp followed by another rsp for 1 req

    Posted 07-06-2016 05:59 PM

    What transport protocol are you using?

    If JMS, couldn't response 1 of 2 go on the wire immediately, and response 2 of 2 delay with a Think Time of 10 seconds.  The Think Times control the timing and DevTest controls everything else OOTB.

     

    If using HTTP protocol, I don't know how you are sending two responses since the protocol standard is to close the socket after a single request / response pairing.

    However, if your second response is actually a 'callback' in the form of a request, you could add steps to the model that retrieve the second response (i.e., lisa_vse_response.get(1).getBodyAsString() ), send the first response, thread sleep for 10 seconds, send the response as a Webservice / REST request step, then loop to LISTEN.

     

    For your date/time issue, are you saying that {{=doDateDeltaFromCurrent("yyyy-MM-dd 'T' HH:mm:ss.SSS", "0D");/*2016-07-06 T 04:15:52.063*/}} is not working for you?  I could see a potential issue using: {{=doDateDeltaFromCurrent("yyyy-MM-dd 'T' HH:mm:ss.SSS", "10S");/*2016-07-06 T 04:16:02.063*/}}

     

    You might add a date/time filter in the VS Image Response Selection Step to create a property representing the current date/time and another filter representing the current date/time + 10 seconds using your simple date format?  Then in your VSI, replace the date/time stamp with the appropriate {{currentTime}} and {{currentTimePlus10}} property, respectively.  This may not be a 100% accurate way to correct the date/time issue, but it could be reasonably painless to try.

     

    Lastly, for HTTP, I have delegated the second "response" off to another VS via the Shared or Persistent Model Map.  This 'worker' VSE does not have a LISTEN step, rather it wakes up, iterates the Model Map, sends what it needs to, goes to sleep and wakes up again after 'n' amount of time.  This is a technically complex approach because your services have to manage the information going onto / off of the Map. And, testing/debugging is a bit more difficult.  But, there are times and reasons why a functional VSM may not be able to thread sleep for 10 seconds in order to get the 2nd HTTP "response" on the wire.



  • 3.  Re: Responding with 1 rsp followed by another rsp for 1 req

    Posted 07-07-2016 11:42 AM

    Thanks for your reply and tips Joel.

     

    The protocol I am using is HTTP, and yes I understand the socket closing for every req/rsp transaction. But I will ask the customer if they would like to send a second request to get the second response (Although I believe the customer wouldn't want it this way). For the sake of understanding, think of these 2 rsp's as Name in rsp1, and SSN in rsp2. I will try the suggestions you provided and will let you know as to how it goes.

     

    As for the time stamp, I initially had it as {{=doDateDeltaFromCurrent("yyyy-MM-dd 'T' HH:mm:ss.SSS", "-12D");/*2016-06-24 T 04:15:52.063*/}}, but that didn't work. That's why I tried few other ways. I also tried deleting my "lisatmp_8.5.0" folder to get rid of cache, and tried your suggestion to add filter in VS Image Response Selection step, and unfortunately, that didn't work either. I know there is some small thing which I am overlooking. Will continue to work on it and resolve it.



  • 4.  Re: Responding with 1 rsp followed by another rsp for 1 req
    Best Answer

    Posted 07-07-2016 12:27 PM

    The best course would be to find out from your customer which HTTP spec they are following. 

     

    Perhaps, they are using the HTTP/2 Server Push feature which allows the server to "push" content that was not requested.  It seems this could be the scenario.

     

    If they are using HTTP/2, it may be more appropriate for a DevTest product team member to chime in as I am not familiar with how DevTest handles HTTP/2.



  • 5.  Re: Responding with 1 rsp followed by another rsp for 1 req

    Posted 07-07-2016 03:15 PM

    I have asked the customer about HTTP/2; waiting for the reply. Thanks for the information.



  • 6.  Re: Responding with 1 rsp followed by another rsp for 1 req

    Posted 07-07-2016 01:56 PM

    On Current date, you can use a filter as shown in enclosed image.

    Current Date.JPG



  • 7.  Re: Responding with 1 rsp followed by another rsp for 1 req

    Posted 07-07-2016 03:16 PM

    Thanks for your reply and screen shot. I tried this and a few other ways, but I am still not getting the current date; not sure where the mistake is. Will let you know once I resolve it.