15
JDBC Virtualization using DevTest Agent in JBOSS/Tomcat Server 20-Jan-2022 Page 1 of 15

Java Agent Virtualization

Embed Size (px)

Citation preview

Page 1: Java Agent Virtualization

JDBC Virtualization using DevTest Agent in JBOSS/Tomcat Server

01-May-2023 Page 1 of 12

Page 2: Java Agent Virtualization

Contents

Contents......................................................................................................................................................... 2

Change Management................................................................................................................................. 3

1. Overview............................................................................................................................................... 4

2. Approach............................................................................................................................................... 4

3. Pre-Requisites..................................................................................................................................... 4

4. High level flow to configure Agent and Create Virtual service............................................5

5. Steps to Configure DevTest8.1 for enabling pathfinder........................................................6

6. Steps to Configure DevTest Agent................................................................................................. 7

7. Configuring Pure Java Agent in JBOSS.........................................................................................7

8. Configuring Pure Java Agent in Tomcat......................................................................................9

9. Configuration needs to be done on Agent Side for recording the transactions........................11

01-May-2023 Page 2 of 12

Page 3: Java Agent Virtualization

Change Management

Version Description Author Reviewer Date

1.0 Initial Document Rajesh Rajendran 11/16/2016

01-May-2023 Page 3 of 12

Page 4: Java Agent Virtualization

1. Overview

Applications use database for storing the information needed for the application. To Access the data, java applications use JDBC drivers. Since applications become more complex, testing all the interactions within the database would be a tedious task. The down time of the databases can cause in to lots of challenges. Because of these constraints the time to market the product would not be easy. The Devtest tool allows us to address these challenges by allowing the developers/testers to record the database interactions and deploying those as a virtual service. This virtual service can then be used for testing the application without interacting with the real database.

2. Approach

We can virtualize the Java classes of system under test using Java Agent based virtualization. For example, if Java classes makes JDBC call, then it can be recorded as JDBC transaction using a Lisa Agent. The Lisa Agent should be installed in a JBOSS server and it should be in the recording mode while recording the transactions. Once transactions are recorded, deploy it as a virtual service. The virtual service would respond in place of the actual system during Agent playback mode.

3. Pre-Requisites

The below are the pre-requisites required for Java Agent based virtualization The DevTest9.1 server components should be installed in a Linux Red hat server

instance JBOSS EAP6.4 instance should be spinned up in a JBOSS server The DevTest9.1 DB components should be installed in Oracle Server

01-May-2023 Page 4 of 12

Page 5: Java Agent Virtualization

4. High level flow to configure Agent and Create y6Virtual service

No

Yes

01-May-2023 Page 5 of 12

Start

Enable continuous Application Insight in to DevTest Registry

Start the Registry and verify whether the broker is started

Copy the DevTest Agent jar files in to JBOSS server location. Keep these Jars outside of JBOSS installation directory

Restart the JBOSS server by using the required commands. Do not start and stop on the server by clicking in the instance

Verify that devtest_agent_pid.log is created or not?

Agent is not created. Check the server logs for more about the exception details

Agent is created. Open the Continuous Application Insight (CAI) console to see the Agent in recording mode

Execute the application flows to which JDBC virtualization has to be done. Check whether Agent is recording the transactions

Page 6: Java Agent Virtualization

5. Steps to Configure DevTest8.1 for enabling pathfinder

Below is the configuration for enabling the CAI server components in the Devtest.

1. In the sites. Properties, make sure

a. lisadb.internal.enabled property is set to false. b. lisa.pathfinder.on property is set to true.c. Point to Oracle DB.

lisadb.pool.common.driverClass=oracle.jdbc.driver.OracleDriverlisadb.pool.common.url=jdbc:oracle:thin:@hostname:Port:SIDlisadb.pool.common.user=DBUserlisadb.pool.common.password_enc=DBPassword

2. Restart the server components in the below orderi. EnterpriseDashboardii. Registryiii. Portaliv. Brokerv. Coordinatorvi. Simulatorvii. VSE

Monitor server logs and verify you are able to get required logs stating that broker/pathfinder is started

01-May-2023 Page 6 of 12

Filter the transactions for JDBC and shelve the transactions

Create virtual service and deploy it in the VSE

Restart the JBOSS server to turn the Agent back to playback mode

Execute the application flows. Now response will be getting from the virtual service.

Page 7: Java Agent Virtualization

6. Steps to Configure DevTest Agent

There are two types of devtest agents

Pure Java agent Native agent

The pure Java agent has no platform-dependent code. The native agent requires a platform-dependent library module.

If you use Java 1.4, you must install the native agent. If you use Java 1.5 or newer, install the pure Java agent

7. Configuring Pure Java Agent in JBOSS

Connect JBOSS server providing required information through WinSCP.

Copy LisaAgent2.jar, LisaAgent.jar and InsightAgent.jar to a location in the server where you have read and execute access permissions. Should not copy the above jar files in any of the application classpath (such as /WEB-INF/lib directories) or JBOSS installed location.

For Safe purpose create a directory in the root (/tmp/LisaAgentJars) and place all these jars there.

Make sure JRE1.6 or JRE1.7 is installed in the JBOSS server path.

For Example - /sys_apps_01/java/jdk1.7.0_45

Ensure real applications are deployed in JBOSS server

For example - http://hostname:port/console/App.html#deployments

Navigate to standalone.conf in the JBOSS>bin directory

For example - /vol_01/sys_apps_01/JBoss/jboss-eap-6.4/bin

Open standalone.conf and provide the below commands at the end of the script and save the file.

JAVA_TOOL_OPTIONS=-javaagent:/tmp/LisaAgentJars/InsightAgent.jar=name=AgentName,url=tcp://LisaServer:2009

01-May-2023 Page 7 of 12

Page 8: Java Agent Virtualization

export JAVA_TOOL_OPTIONS

Add com.itko in the JBOSS_MODULES_SYSTEM_PKGS

For example, replace JBOSS_MODULES_SYSTEM_PKGS="org.jboss.byteman" with

JBOSS_MODULES_SYSTEM_PKGS="com.itko,org.jboss.byteman"

If you are seeing any permission error while saving the file, follow the below steps to save the file.

1. Open Putty.exe2. Login with dc-user/password3. Enter the command for login as “admin” sudo su – admin4. Navigate to standalone.conf directory /vol_01/sys_apps_01/JBoss/jboss-eap-6.4/bin5. Open the standalone.conf in vi editor using vi standlone.conf6. Press INSERT command and modify the contents in standalone as specified above7. Press ESC Key8. Save and quit vi editor using :wq9. Type exit to exit from putty.exe

Check whether the standalone.conf is updated through WinScp.

Once standalone.conf is updated, go to login to putty and restart the JBOSS server

1. Do steps from #1 to #3 mentioned above2. Navigate to directory cd /apps_01/webapps/JBoss/bin3. Enter the command to stop the JBOSS server ./sample_server0.sh -a stop4. Provide mc username/password admin/password5. Start the server ./sample_server0.sh -a start

You will now see a log message in the console “JBOSS server is ready to start”

Navigate to the LisaAgentJars directory. You will be able to see an agent log “devtest_agent_<pid>.log” is created. Where pid is the process id.

8. Configuring Pure Java Agent in Tomcat

Connect Tomcat server providing required information through WinSCP.

01-May-2023 Page 8 of 12

Page 9: Java Agent Virtualization

Copy LisaAgent2.jar, LisaAgent.jar and InsightAgent.jar to a location in the server where you have read and execute access permissions. Should not copy the above jar files in any of the application classpath (such as /WEB-INF/lib directories) or Tomcat installed location.

For Safe purpose create a directory in the root (/tmp/LisaAgentJars) and place all these jars there.

Make sure JRE1.6 or JRE1.7 is installed in the Tomcat server path.

For Example - /sys_apps_01/java/jdk1.6.0_45

Ensure real applications are deployed in Tomcat Web application manager

For example - http://ech-10-157-136-58.mastercard.int:7910/manager

Navigate to sample_server0.sh in the Tomcat>bin directory

For example - /apps_01/webapps/tomcat/bin

Open Catalina.sh and provide the below commands at the start and restart sections of the server.

CATALINA_OPTS="$CATALINA_OPTS -javaagent:/home/dc-user/infa_install/LisaAgentJars/LisaAgent2.jar=name=AgentName,url=tcp://ServerName:Port"

If you are using infaService.sh as a startup script, provide the below command in the server start section

INFA_JAVA_OPTS="-javaagent:/home/dc-user/infa_install/LisaAgentJars/LisaAgent2.jar=name=AgentName,url=tcp://ServerName:2009 -Xmx2048m ${INFA_JAVA_OPTS} -XX:GCTimeRatio=9 -XX:MaxPermSize=128m"export INFA_JAVA_OPTS

In some of the Tomcat versions we need to use JAVA_OPTS as shown below instead of the INFA_JAVA_OPTS or CATALINA_OPTS. A sample JAVA_OPTS command is displayed below

JAVA_OPTS="$JAVA_OPTS -javaagent:/tmp/LisaAgentJars/LisaAgent2.jar=name=AgentName,url=ServerName:2009"

The command for creating the agent varies according to the startup script you are using.

01-May-2023 Page 9 of 12

Page 10: Java Agent Virtualization

If you are seeing any permission error while saving the file, follow the below steps to save the file.

1. Open Putty.exe2. Login with dc-user/password3. Enter the command for login as “mc” sudo su – admin4. Navigate to sample_server0.sh directory /apps_01/webapps/tomcat/bin5. Open the sample_server0.sh in vi editor using vi sample_server0.sh

6. Press INSERT command and modify the contents in sample_server0.sh as specified above

7. Press ESC Key8. Save and quit vi editor using :wq9. Type exit to exit from putty.exe

Check whether the sample_server0.sh is updated or not from Winscp.

Once sample_server0.sh is updated, go to login to putty and restart the Tomcat server

1. Do steps from #1 to #3 mentioned above2. Navigate to directory cd /apps_01/webapps/JBoss/bin3. Enter the command to restart the Tomcat server

sudo /apps_01/webapps/tomcat/bin/sample_server0.sh restart

You will now see a log message in the console “Tomcat server is ready to Rock”

Navigate to the LisaAgentJars directory. You will be able to see an agent log “devtest_agent_<pid>.log” is created. Where pid is the process id.

9. Configuration needs to be done on Agent Side for recording the transactions

Once the JVM is started, you will be able to see the agent & broker in devtest portal

01-May-2023 Page 10 of 12

Page 11: Java Agent Virtualization

Select the Agent you want to capture the transactions and make the following protocols to full data

Go to the Agent -> settings tab. Select capture and uncheck the “Enable Capture” feature.

01-May-2023 Page 11 of 12

Page 12: Java Agent Virtualization

Go to Agent->Settings tab. Select “Transactions” and enable “Attach synthetic parent” if you are going to record transactions which is having parent calls. Apply the settings once you selected

Now you can start recording the transactions with the help of agent and create virtual service from it. Please go through CA documentation for – How to record and playback the transactions using Agent.

01-May-2023 Page 12 of 12