Service Virtualization

  • 1.  Virtualizing SQL DB

    Posted Jan 23, 2018 06:33 PM

    We're using v10.1 and we've virtualized SOAP/REST calls, but haven't done SQL DB virtualization before.

     

    We've looked at the docs but the steps aren't clear to us. From this, it seems we install something on the SQL DB server itself - I hope that's not necessary.

          Install the Database Simulator - DevTest Solutions - 8.0 - CA Technologies Documentation 

     

    Can someone share basic steps to virtualize SQL DB interaction (basic query/return results)? Here's some context - we have a test flow with multiple service calls and DB steps and we want to virtualize this flow so we have a stable mini-environment to develop similar automation against. 

     

    Thanks in advance.



  • 2.  Re: Virtualizing SQL DB
    Best Answer

    Broadcom Employee
    Posted Jan 23, 2018 09:09 PM

    Hi Jason,

     

    Definitely don't go down that path - it's deprecated.  Once upon a time, databases were virtualized using a special DevTest JDBC driver.  Now, there's an easier way.  Look into the Java Agent:

     

    https://docops.ca.com/devtest-solutions/10-1/en/agents/devtest-java-agent

     

    The Java Agent allows Java virtualization (the ability to override the behavior of any arbitrary Java object in an executing JVM).  You could override the JDBC classes or, if your code was built using the Data Access Object design pattern, you  could intercept the DAO calls instead.

     

    You'd begin by instrumenting the consuming application with the Java agent (this is a JVM parameter).  An Agent is simply a companion that executes alongside the JVM.  When starting a VSE recorder, you'd select the "Java" transport protocol.

     

    This is not for the faint of heart.  Start by researching "Java Virtualization" in the documentation.

     

    A challenge in Java virtualization is that you must have detailed knowledge of how the consuming application is built (things like fully qualified class names of relevant classes).

     

    If your team has scheduled any engagements with CA professional services, it'd be best to work with the CA architect to get up and running on this.

     

    --Mike



  • 3.  Re: Virtualizing SQL DB

    Posted Jan 23, 2018 11:52 PM

    Thanks for the detailed reply Mike.

     

    I must be missing something. I'm not following why virtualizing DB requires installing an agent on the server/Java/JVM level stuff. I saw this doc (JDBC Service Image - DevTest Solutions - 10.0 - CA Technologies Documentation ) that showed after using the traffic recording that you can edit the image metadata to handle different requests and use xml to return different query results <-- this image is what I want to do. 

     

    Is there any way to create a simple image like this and manage the metadata that will simulate DB w/out the overhead of agent and other traffic recording steps?

     

    Thanks,

    -Jason



  • 4.  Re: Virtualizing SQL DB

    Broadcom Employee
    Posted Jan 24, 2018 09:47 AM

    No, the agent is required.

     

    It's not installed on the database - it's installed on the machine making the database calls.  The agent is necessary in order to intercept calls to the JDBC Java objects.  When the database interaction is virtualized, the agent gathers the parameters passed to a Java method and sends them to VSE.  Using the service image, a response is selected and sent back to the agent.  The agent uses that response as the return value from the method.  The real logic of the method (making a network call to the real DB) is bypassed.

     

    Installing the agent is as simple as copying the "agent" folder (found in the DevTest installion folder) to the machine to be instrumented.  Then, you define the "javaagent" parameter as part of the JVM options passed to the application that interacts with the database.

     

    https://docops.ca.com/devtest-solutions/10-0/en/agents/devtest-java-agent/java-agent-installation/install-the-pure-java-agent

     

    --Mike



  • 5.  Re: Virtualizing SQL DB

    Posted Jan 24, 2018 12:10 PM

    Thanks again Mike. I get it now, virtualization is at the Java calling level and not the DB receiving level.

     

    In our case, the Java code that's connecting to DB and executing queries is running inside of DevTest script (we wrote custom code to execute parameterized DB connect/query). I'm assuming there is a way to configure javaagent in Lisa JVM via a properties file.

     

    We'll try the agent install/configure steps and reply back if we're still stuck. 

     

    Thanks,

    -Jason



  • 6.  Re: Virtualizing SQL DB

    Broadcom Employee
    Posted Jan 24, 2018 02:46 PM

    In the "bin" folder of where DevTest is installed, edit a file called "Workstation.vmoptions" and add a line with the agent configuration:

     

    -javaagent:your config information goes here

     

    When you bring up Workstation, check Workstation.log.  If you see new DEBUG level messages announcing the presence of the agent, you'll know it was picked up.

     

    Also, you'll need "BrokerService" running on the DevTest server.  One of the javaagent parameters is a URL to that broker.

     

    Good luck!  You're jumping into the deep end of the pool!

     

    --Mike



  • 7.  Re: Virtualizing SQL DB

    Posted Jan 26, 2018 01:43 PM

    Hi,

    For the Agent configuration,

    I am able to connect to the agent part using the 

    java -javaagent:C:\MongoDB\..\InsightAgent.jar=url=ssl://{{URL}}:2009,name={{x}}

    but I get the error message regarding the rules.xml.

    I copied the rules.xml from the LISA root folder and ran the command

    java -javaagent:C:\MongoDB\..\InsightAgent.jar=url=ssl://{{URL}}:2009,name={{x}}

     

    But then, it shows the Generated rules from ...

    and after that shows the options like 

    java [options]...

     

    Could you please help with the rules.xml?

    Do I need to copy the rules from the broker?

    Or Do i need to configure the rules.xml in the agent differently?

    If I need to configure differently, what is the sample I can use? 

    I have this page 

    https://docops.ca.com/devtest-solutions/10-2/en/agents/devtest-java-agent/rules-xml-file

    but the information present there is not much helpful.

     

    Regards