DevOps Automation

DevOps Automation

Join this online group to communicate across IBM product users and experts by sharing advice and best practices with peers and staying up to date regarding product enhancements.


#DevOps
#Businessautomation
#DevOpsAutomation
 View Only

Capturing JDBC Database Events Using the Recording Studio in IBM DevOps Test Integrations and APIs

By Rupali Bodekar posted 15 hours ago

  

This blog explains how to capture JDBC database events using the Recording Studio perspective of the IBM DevOps Test Integrations and APIs (Test Integrations and APIs) from a simple Java web application hosted on Apache Tomcat. This is useful for creating tests out of recorded events, database stubs or virtual services, while SQL events are being recorded from a database.  

Before starting, ensure the following setup is complete: 

  • Installation of IBM DevOps Test Integrations and APIs, integrated with a supported Database. 

  • Installation of IBM DevOps Test Virtualization Control Panel (Test Virtualization Control Panel), matching the version of Test Integrations and APIs. 

  • Installation of an Apache Tomcat server. 

  • A Java web application deployed on any web server (In this blog it is Apache Tomcat) that performs successful JDBC operations. 

  • Installation and configuration of a supported Database server so that the deployed Java web application can perform JDBC operations required for recording database events. In this blog, Microsoft SQL Server is used. 

This blog is divided into four major sections: 

  1. Successful connectivity of the Database from Test Integrations and APIs

  1. Setting Up a Logical and Physical Database for Test Integrations and APIs 

  1. Deploying the Test Integrations and APIs JDBC proxy into Apache Tomcat   

  1. Creating database stubs using the Recording Studio

All the above sections are explained in detail as follows. 

Successful connectivity of the Database from Test Integrations and APIs

It is essential to verify that the Test Integrations and APIs is able to connect to both the “MSSQL database” and the Test Virtualization Control Panel. Check the connectivity as outlined below: 

  1. Launch IBM DevOps Test Integrations and APIs and open your project. 

  1. Go to Project Project Settings > Server Settings.

  1. Confirm that a successful connection was made with the Microsoft SQL Server database. 
     

  1. Also, verify on the same page that the connection to Test Virtualization Control Panel is active, look for the green checkmark beside the server URL 


     

Setting Up a Logical and Physical Database in Test Integrations and APIs

  1. To create the database connection, go to Architecture School > Logical View
    Click General > Database Server and provide the name. 
     

  1. Navigate to Architecture School > Physical View, double-click on the recently created database connection to configure the connection to match that used by the Java application. Check the successful database connection message by clicking Test Connection

  2. Also, configure the Simulation Database connection to your separate schema and click on Test Stub Connection 


     

Deploying the Test Integrations and APIs JDBC proxy into Apache Tomcat 

The configuration changes described in the following topics must be made to each stand-alone application and hosted application that communicates with a Test Integrations and APIs JDBC proxy. 

A Test Integrations and APIs JDBC proxy must be deployed on each application server that is running Apache Tomcat. The JDBC proxy enables a server that hosts applications to use JDBC to access a live database that you want to record or virtualize.  
 
First, install the tool package by following the steps below: 

  1. Log in to Test Virtualization Control Panel, open the Tools page, and download the JDBC driver package (.zip file).  
    Alternatively, copy the package from “C:\Program Files\IBM\DevOpsTestControlPanel\tools” folder. For more details, refer here

  1. Extract the JDBCIntercept.zip file. Copy the below files into the <Tomcat installation directory>\common\lib or to whichever Tomcat library folder that contains JDBC drivers.

    com.ibm.rational.rit.jdbcdriver4.jar, 

    jsqlparser15.jar, 
    antlr-3.4.jar, and  
    registration.xml (JDBC proxy configuration file)    

       

  1. Locate the Tomcat startup script; its location depends on the Operating System.  

    a. Windows: %CATALINA_HOME%\bin\catalina.bat 
    b. Unix-Linux: $CATALINA_HOME/bin/catalina.sh

    Open the catalina file for editing and add the following JAVA_OPTS variable, set the jdbc.drivers property as follows: 

    SET JAVA_OPTS=%JAVA_OPTS% -Djdbc.drivers=com.greenhat.jdbc.Driver


    Save and close the file. For more details, refer here.  

  1. Restart Control Panel Service and restart Tomcat server to reflect the changes, refer here.
     

Now, log in to the Test Virtualization Control Panel, then navigate to the Infrastructure page. Verify that the JDBC Agent shows the status as "Connected". The configuration changes must be made to each stand-alone application and hosted application that communicates with a Test Integrations and APIs JDBC proxy. 
 

Creating database stubs using the Recording Studio 

  1. Open the Test Integrations and APIs product and open the Recording Studio perspective. 

  1. In the Monitor Configuration view, click on the symbol “+“ to select the operators or resources to monitor.  

  1. Click OK after adding the resource, which will be displayed as an active connection ready for monitoring.  
     

  1. Start Recording the JDBC Events by clicking on the Record button  in the Events View tab. On Events View popup, select Yes, record the SQL... and Create a database stub but don't start it. It is not possible to create a stub from previously recorded events; you must create the stub directly as part of the recording process. 
     

     
    The recording rule is shown on the DevOps Test Control Panel Network Dashboard
     

    Note that the Recipient column shows the destination for matching events. By default, Recording Studio listens on a different random port number each time it is started. In this case, the Library Manager has been used to fix the port number to “7777” to avoid problems with firewalls. 

     

  1. Invoke your java program or AUT hosted on Tomcat server, to interact with database and capture the events. 
     

  2. Execute some SQL queries, in this case, insert data into the UserDetails table. 


  3. The event is being seen in the Recording StudioEvents will be posted directly from the Integration Tester JDBC Agent within the Java application to the Recording Studio.  Events are not sent via Test Integrations and APIs.   
     

  4. The matching table is created in the stub simulation schema as well as an internal table to store the SQL command. (Check the SQL Dashboard Database as shown below)
     

  5. Stop the recording and see the stub created in Test Factory.
     



  6. The Tables tab shows a summary of tables captured and their data columns and rows. 

  7. The Queries tab lists any SQL queries that were recorded. 

  8. After events are recorded, you can create a test from the selected events in the Events View pane. Click the Create Test from selected events icon in the Events View toolbar, or right-click the messages and select Create Test or Create Parameterized Test from the menu. 
     

  9. On the Resource Type dialog, select a type of test that you want to create, click Next
     

  10. On the Data Storage page, choose one of the following storage options, click Next



  11.  On the Summary page, enter a name for the test. To edit the new test immediately after it is created, select Open resource after finish and Click Finish


     

  12. A test is created. The test contains Test Steps that relate to the selected events. Test steps vary on the type of event. 
     
     

Refer to the product documentation below for additional details. 

0 comments
2 views

Permalink