Service Virtualization

  • 1.  Same Request - Different Response

    Posted Nov 06, 2018 01:35 AM

    Hi Everyone,

     

    This is not a possible scenario in any real environment but we just got one requirement to do so. 

    The question is to give different responses to the same request. There is no change in the request at all but the virtual service should response with different responses. 

     

    I have written the match script and virtual service is responding with different messages as expected. 

     

    Now the question is - 

    Can we achieve the above mentioned issue without writing the match script. ?

    If so can you please explain how do we do that. 

     

    It can be either for Stateful Transaction or stateless transaction.

     

    J_NeSmith sursu06  Rick.Brown gadpr08 DannySaro

     

    Thanks

    Nikhil



  • 2.  Re: Same Request - Different Response

    Broadcom Employee
    Posted Nov 06, 2018 02:29 AM

    What are some additional requirements for this? You state, no Match Script, ok. But can the .vsm contain other scripting?

     

    If additional scripting is allowed then there are various possibilities depending on exact requirements: how many different responses, does response have to be random, or in specific order, etc…

     

    I don’t believe it is possible using a conversation (stateful service). If requests are similar then every request is a Conversation Starter.

    And even if you could go round the Conversation Starter issue, you could imaging doing a similar round-robin approach where you would have a tree that is one long branch of all the different responses. Each node would have navigation “CLOSE” so the next response would always be the child node of the last response. But you get stuck on the final leaf, because navigation “WIDE” or “LOOSE” will respond with again the last node over and over as that is always done first before jumping to any conversation starter again.

     

    One way I can think of to do this with OOTB virtual services that contain no scripting at all would be to use the round-robin behavior of the VSE whenever 2 or more virtual services are deployed that have the same port and same basepath.

    So, let say you have 3 different responses.

     

       

    •   Create 3 different virtual services (with some difference in the name), each virtual service only returns one type of response.

       

    •   Deploy each virtual service with the same port and same basepath

     

    Now the VSE will do a round-robin and will give first incoming request to service 1, second to 2, third to 3, fourth to 1, fifth to 2, etc…

     

    Cheers,

    Danny



  • 3.  Re: Same Request - Different Response

    Posted Nov 07, 2018 02:26 AM

    Thanks DannySaro for the detail response. 

     

    There are no additional requirements, just that we wanted to get different constant responses to same request. 

    There is one request - 3 different responses. These 3 responses are constant. Won't change any time. 

    When you trigger the request for first time - the first response should come in. 

                                                         second time - the second response and 

                                                         Third time - the last response should come in and fourth time the first.. 

     

    I could do this with the help of match script in VSI. 

    Just wanted to check if there is any other way to do it so. 

     

    As you mentioned - deploying the different virtual services with the same base path and port, yes that is one of the possibility when we have couple of responses to be sent. But if there are n number of responses how do we do that.

     

     

    I am free to add any custom code in the VSM/VSI. Please guide on the same, i shall try and let you know the outcome. 

     

    Thanks

    Nikhil



  • 4.  Re: Same Request - Different Response

    Broadcom Employee
    Posted Nov 07, 2018 05:30 AM
      |   view attached

    Following is a solution with minimal scripting.

     

     

      1.  Add a “Create Numeric Counting Dataset” to your listenstep. Define as printscreen below.

     

     

     

     

     

      1.  Add a Scriptable DPH to your listen step.

     

    %beanshell%

     

    // Add the generated number of the numeric counting dataset

    // as an argument to the incoming request

     

    import com.itko.util.ParameterList;

    import com.itko.util.Parameter;

     

    ParameterList args = lisa_vse_request.getArguments();

    args.addParameter(new Parameter("RoundRobinNumber", testExec.getStateValue("prpRoundRobinNumber")));

    lisa_vse_request.setArguments(args);

     

     

      1.  Edit your .vsi, add an extra argument “RoundRobinNumber” to your signature. For each exact transaction assign a unique RoundRobinNumber eg. 1, 2, 3, ... as many as the “To” value in your dataset.

     

     

    Cheers,

    Danny