Skip to content

Commit e6ee00a

Browse files
committed
feat: add steps to run keploy in karaf
Signed-off-by: Sarthak Shyngle <[email protected]>
1 parent 8141a95 commit e6ee00a

File tree

1 file changed

+108
-0
lines changed

1 file changed

+108
-0
lines changed
Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
---
2+
id: keploy-karaf-example
3+
title: Keploy Karaf Example
4+
sidebar_label: Keploy Karaf Example
5+
description: This section documents how to run keploy with Karaf
6+
tags:
7+
- keploy
8+
- keploy karaf
9+
keywords:
10+
- keploy
11+
- documentation
12+
- running-guide
13+
---
14+
15+
# Setting Up Keploy Agent in Apache Karaf for Local Development
16+
17+
Follow these steps to set up and run the Keploy agent in Apache Karaf for your local development environment.
18+
19+
---
20+
21+
## Step 1: Download Required JARs
22+
23+
Use `wget` to download the necessary JAR files:
24+
25+
- [java-agent-1.0-SNAPSHOT.jar](https://keploy-enterprise.s3.us-west-2.amazonaws.com/agent-jars/java-agent-1.0-SNAPSHOT.jar)
26+
- [org.jacoco.agent-0.8.12-runtime.jar](https://keploy-enterprise.s3.us-west-2.amazonaws.com/agent-jars/org.jacoco.agent-0.8.12-runtime.jar)
27+
28+
Run the following commands to download the files:
29+
30+
```bash
31+
wget https://keploy-enterprise.s3.us-west-2.amazonaws.com/agent-jars/java-agent-1.0-SNAPSHOT.jar
32+
wget https://keploy-enterprise.s3.us-west-2.amazonaws.com/agent-jars/org.jacoco.agent-0.8.12-runtime.jar
33+
```
34+
35+
---
36+
37+
## Step 2: Configure Apache Karaf
38+
39+
### Update `JAVA_OPTS` for linux/mac in `setenv` File
40+
41+
1. Navigate to the `bin` directory of your Apache Karaf installation.
42+
2. Open the `setenv` file for editing.
43+
3. Add the paths of the downloaded agents under the `JAVA_OPTS` section. For example:
44+
45+
```bash
46+
export JAVA_OPTS="-javaagent:/path/to/java-agent-1.0-SNAPSHOT.jar"
47+
export JAVA_OPTS="$JAVA_OPTS -javaagent:/path/to/org.jacoco.agent-0.8.12-runtime.jar=address=*,port=36320,destfile=jacoco-it.exec,output=tcpserver"
48+
```
49+
50+
### Update `JAVA_OPTS` for windows in `setenv.bat` File
51+
1. Navigate to the `bin` directory of your Apache Karaf installation.
52+
2. Open the `setenv.bat` file for editing.
53+
3. Add the paths of the downloaded agents under the `JAVA_OPTS` section. For example:
54+
55+
```bash
56+
set JAVA_OPTS=-javaagent:/path/to/java-agent-1.0-SNAPSHOT.jar
57+
set JAVA_OPTS=%JAVA_OPTS% -javaagent:/path/to/org.jacoco.agent-0.8.12-runtime.jar=address=*,port=36320,destfile=jacoco-it.exec,output=tcpserver
58+
```
59+
Replace `/path/to/` with the actual paths where you downloaded the JAR files.
60+
61+
### Update `config.properties`
62+
63+
1. Navigate to the `etc/config.properties` file in your Karaf installation.
64+
2. Add the following entry under the `bootdelegation` section to allow OSGi bundles to access Keploy artifacts:
65+
66+
```properties
67+
org.osgi.framework.bootdelegation = \
68+
com.sun.*, \
69+
javax.transaction, \
70+
javax.transaction.xa, \
71+
javax.xml.crypto, \
72+
javax.xml.crypto.*, \
73+
javax.security.cert, \
74+
jdk.nashorn.*, \
75+
sun.*, \
76+
jdk.internal.reflect, \
77+
jdk.internal.reflect.*, \
78+
org.apache.karaf.jaas.boot, \
79+
org.apache.karaf.jaas.boot.principal, \
80+
io.keploy.*
81+
```
82+
83+
---
84+
85+
## Step 3: Import Postman Collection
86+
87+
1. Ensure you have a Postman collection ready for your application.
88+
2. Run the following command to import the Postman collection as Keploy tests:
89+
90+
```bash
91+
keploy import postman --path="/path/to/YourPostmanCollection.json"
92+
```
93+
94+
Replace `/path/to/YourPostmanCollection.json` with the actual path to your Postman collection.
95+
96+
---
97+
98+
## Step 4: Run Keploy Tests
99+
100+
Use the following command to run the imported tests:
101+
102+
```bash
103+
keploy test --base-path="http://localhost:8181"
104+
```
105+
106+
This assumes your Karaf application is running locally on port 8181.
107+
108+
After running the tests, a `coverage.xml` file will be generated in the root directory of your project. This file contains the test coverage report, which can be used for further analysis or integrated with CI/CD pipelines.

0 commit comments

Comments
 (0)