Service Virtualization

  • 1.  VSE name in scripted assertion?

    Posted Mar 10, 2017 07:52 AM

    Hi All,

     

    One of requirements on current project is to have report, that will show how many transactions were simulated by DevTest when virtual service was in Failover mode.

    Our approach is to log particular events to database. I use scripted assertion, and it writes information about name of virtual service and every transaction (simulated or live) to the database. In addtion to this I need also inormation, on which VSE this virtual service is running, because we have several VSEs in the environment.

    Is there any way to obtain VSE name in scripted assertion?

     

    Thanks in advance

     

    Wojtek



  • 2.  Re: VSE name in scripted assertion?

    Broadcom Employee
    Posted Mar 10, 2017 08:55 AM

    There's an API call that can help with this. It's not entirely straightforward, because I don't know whether a virtual service can know the name of the container in which it's running. As such, I don't know if this is the most logical way of meeting your requirement.

     

    http://yourRegistry:1505/api/Dcm/VSEs/

    I run this API call in a REST step sometime before I launch my script. It returns all the VSEs attached to yourRegistry, along with all the virtual services running in each of those VSEs.

    My usual method in a script is to make an array for each VSE, each line in each array containing information for a virtual service loaded in that VSE, and then iterate through each of them for the virtual service name.

     

    As long as you don't have the same virtual service name in multiple VSEs, you'll have a lot of the data you might want for logging.



  • 3.  Re: VSE name in scripted assertion?
    Best Answer

    Posted Mar 10, 2017 10:41 AM

    Try the code below and let us know what happens.  

    I added this as a Scriptable DPH in the listen step, but it should work inside any type of script. I only had one VSE in my environment, and its name was "VSE"; so, hopefully, the code is not sending some fake value back. 

     

    I ran a service in ITR mode, sent a request, and used logger to write the name as an event.  After the listen step, I checked the Test Events tab and saw the name print. 

    Not certain of the behavior if the service is deployed to one or more VSEs.

     

    If the code works for you, you could set the name into a property that your SQL statement could write to the DB.

     

    %beanshell%

    _logger.info( " The VSE Name is: {}", testExec.getStateValue( "lisa.vseName" ) );

    return;

     

    Third line from the bottom:



  • 4.  Re: VSE name in scripted assertion?

    Posted Mar 10, 2017 10:56 AM

    Hopeful the above will work.  I deployed a second VSE to my environment named "VSE2".  Deployed the service and ran a test.  Here is the output written into the vse.log.

    2017-03-10 15:53:03,037Z (09:53) [FakeService [VS_FakeService_Run]/1] INFO com.itko.lisa.script.logger - <<<
    2017-03-10 15:53:03,038Z (09:53) [FakeService [VS_FakeService_Run]/1] INFO com.itko.lisa.script.logger - The VSE Name is: tcp://localhost:2020/VSE2
    2017-03-10 15:53:03,038Z (09:53) [FakeService [VS_FakeService_Run]/1] INFO com.itko.lisa.script.logger - <<<

     

    So, you might need to add code to strip out the hostname and port to get only the VSE name.  Probably seeing the above because my VMOPTIONS file contained this directive to name the VSE2.

    -Dlisa.vseName=tcp://localhost:2020/VSE2



  • 5.  Re: VSE name in scripted assertion?

    Posted Mar 13, 2017 07:55 AM

    Thank you Joel, it works for me!