Service Virtualization

  • 1.  Different execution behaviour with Pre and Post steps in VSM

    Posted Jun 20, 2016 12:58 PM


    Hi All,

    I have added few Pre and Post steps in VSM. Pre step before listener will check for server status and start the server accordingly. Post step will stop the server.

    What i observer is for every incoming request will not only be consumed by Listener but it will be pass through pre steps and those are executed.

    Here is my VSM -

    The issue i am facing is, my Post stop server step will be executed but after that start server will get executed again. I am not sure whether its a common behavior of VSM.

    Here is Inspection View -

    Thanks.



  • 2.  Re: Different execution behaviour with Pre and Post steps in VSM

    Posted Jun 20, 2016 01:29 PM

    Do you feel like your logic is correct?  Are you starting/stopping ActiveMQ for each and every incoming TXN?  That seems like a lot of overhead.


    Your error....

    It looks like your execution timed out for some reason (based on the info displayed in your output) while trying to stop ActiveMQ.


    Your stop server step has a timeout assertion which appears to branch to end the service.  


    Maybe this is why you see the start step fire service rather than a branch to listen.  If you deployed with "automatically restart service" you might be causing the start to fire again.


    The question is why is the timeout happening?  Look at the time stamps and you see several seconds go by.  How long does the start/stop of ActiveMQ normally take?



  • 3.  Re: Different execution behaviour with Pre and Post steps in VSM

    Posted Jun 20, 2016 03:07 PM

    Hi Joel,

     

    Do you feel like your logic is correct?  Are you starting/stopping ActiveMQ for each and every incoming TXN?

    >>> I have confirmed that logic is correct. Its working as expected.

     

    That seems like a lot of overhead.

    >>> Yes its true but this will be only for single functional test case execution.

     

    Your error. It looks like your execution timed out for some reason (based on the info displayed in your output) while trying to stop ActiveMQ.

    >>> I am executing below command and what i observed is command will run successfully and server start at the background but not return proper exit code so control will not pass to next step. Either execute step will abort the test because of timeout error or not accepting incoming requests.

     

    Your stop server step has a timeout assertion which appears to branch to end the service. 

    >>> The same problem i am facing here with timeout. execute command step is not return proper exit code and goes on executing command.

     

    Maybe this is why you see the start step fire service rather than a branch to listen.  If you deployed with "automatically restart service" you might be causing the start to fire again.

     

    The question is why is the timeout happening?  Look at the time stamps and you see several seconds go by. How long does the start/stop of ActiveMQ normally take?

    >>> I have setup timeout as 15 sec and most of the times it is happening within time.



  • 4.  Re: Different execution behaviour with Pre and Post steps in VSM

    Posted Jun 20, 2016 06:17 PM

    Barring the timeout problem you are experiencing, it seems that part of the problem is that the step that Stops ActiveMQ is looping to the LISTEN step which bypasses the logic to start up ActiveMQ for subsequent incoming requests.  Once this branch  happens, the service cannot check the ActiveMQ Status and start ActiveMQ when the next transaction arrives.

     

    In the world of VSMs, the LISTEN steps acts as a polling type step.  The LISTEN step waits for something to trigger its execution.  In this case, that trigger is an incoming request.  Any steps inserted to the left of a LISTEN step fire one time when the service is launched (started, deployed, or redeployed).  Steps that are left of the LISTEN step do not act like polling steps.  Therefore, once ActiveMQ shuts down at the end of one transaction, ActiveMQ is not restarted until the service is stopped & started or the service is re/deployed to VSE.  To fix this issue, you could move your status check and start of ActiveMQ to the right side of the LISTEN step.

     

    I wonder though if it would be easier (or perhaps more controllable, or readable, or a better separation of concerns) to implement your requirement using two services?  The main service and a helper service that only starts / stops ActiveMQ on demand.  For example:

     

    Service 1 contains your current service.  Rather than start/stop Active MQ, this service calls another service that handles ActiveMQ start / stop logic.  Basic steps in this service are:

    LISTEN -> REST CALL to Start ActMQ -> VSI Image Selection -> Respond -> REST CALL to Stop ActMQ -> Loop to LISTEN Step

     

    Service 1 is only responsible for processing incoming transactions.  It invokes another service to start/stop ActiveMQ using REST with a query string such as:  http:// Then custom steps that perform logic such as…

     

    -          if query string cmdValue equal “start”, Check ActMQ Status, if is already running, Respond with ActMQ started and loop to listen; else Start ActMQ, wait desired amount of time, respond with ActMQ started, Loop to Listen

     

    -          if query string cmdValue equal “stop”, if ActMQ already stopped, respond with ActiveMQ stopped and loop to listen; else stop ActMQ, respond with ActMQ stopped, Loop to Listen

     

    In Service 2, the timeout assertions are forced to branch to the LISTEN step.  To do this, Right CLICK on the timeout assertion and force branch to the LISTEN step.

    To access the query parameter, you can use   String cmdValue = lisa_vse_reqeust.getAttributes().get(“cmd”);

     

    Obviously, the descriptions are missing a few steps, and some branching logic, but hopefully you get the idea.

     

    Lastly, I have concerns about the threading model your service seems to be implementing.  Are you able to control the speed with which incoming transactions arrive on the LISTEN step?

     

    My fear is that the service(s) might experience issues when incoming requests are flowing in & out faster than ActiveMQ can shut down and start up.  For example, if it takes 15 seconds for ActiveMQ to stop and 15 seconds to start (30 wall seconds), the incoming transactions have to be spaced accordingly.  Otherwise, one transaction might be trying to start Active MQ while another transaction has fired the Active MQ stop step.  I do not believe forcing the concurrency of the Service to a value of “1” is going to help you control this potential issue.



  • 5.  Re: Different execution behaviour with Pre and Post steps in VSM
    Best Answer

    Posted Jun 23, 2016 05:03 PM

    Hi Joel, here is my solution -

    Whenever user starts the virtual service, activemq will stand up as a pre-activity. Managing activemq server start time with the help of step "think time" settings. User can perform JMS testing against the virtual service. Whenever user stops the virtual service, with companion capture shutdown signal and shut down activemq server.

    VSM:

    Start Activity Sub-process -

    Stop Activity Sub-process -