Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
136 changes: 136 additions & 0 deletions versioned_docs/version-2.0.0/running-keploy/keploy-karaf.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
---
id: keploy-karaf-example
title: Keploy Karaf Example
sidebar_label: Keploy Karaf Example
description: This section documents how to run keploy with Karaf
tags:
- keploy
- keploy karaf
keywords:
- keploy
- documentation
- running-guide
---

# Setting Up Keploy Agent in Apache Karaf for Local Development

Check failure on line 15 in versioned_docs/version-2.0.0/running-keploy/keploy-karaf.md

View workflow job for this annotation

GitHub Actions / vale

[vale] versioned_docs/version-2.0.0/running-keploy/keploy-karaf.md#L15

[Vale.Spelling] Did you really mean 'Karaf'?
Raw output
{"message": "[Vale.Spelling] Did you really mean 'Karaf'?", "location": {"path": "versioned_docs/version-2.0.0/running-keploy/keploy-karaf.md", "range": {"start": {"line": 15, "column": 37}}}, "severity": "ERROR"}

Follow these steps to set up and run the Keploy agent in Apache Karaf for your local development environment.

Check failure on line 17 in versioned_docs/version-2.0.0/running-keploy/keploy-karaf.md

View workflow job for this annotation

GitHub Actions / vale

[vale] versioned_docs/version-2.0.0/running-keploy/keploy-karaf.md#L17

[Vale.Spelling] Did you really mean 'Karaf'?
Raw output
{"message": "[Vale.Spelling] Did you really mean 'Karaf'?", "location": {"path": "versioned_docs/version-2.0.0/running-keploy/keploy-karaf.md", "range": {"start": {"line": 17, "column": 65}}}, "severity": "ERROR"}

---

## Step 1: Download Required JARs

Use `wget` to download the necessary JAR files:

- [java-agent-1.0-SNAPSHOT.jar](https://keploy-enterprise.s3.us-west-2.amazonaws.com/agent-jars/java-agent-1.0-SNAPSHOT.jar)
- [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)

Run the following commands to download the files:

```bash
wget https://keploy-enterprise.s3.us-west-2.amazonaws.com/agent-jars/java-agent-1.0-SNAPSHOT.jar
wget https://keploy-enterprise.s3.us-west-2.amazonaws.com/agent-jars/org.jacoco.agent-0.8.12-runtime.jar
```

---

## Step 2: Configure Apache Karaf

Check failure on line 37 in versioned_docs/version-2.0.0/running-keploy/keploy-karaf.md

View workflow job for this annotation

GitHub Actions / vale

[vale] versioned_docs/version-2.0.0/running-keploy/keploy-karaf.md#L37

[Vale.Spelling] Did you really mean 'Karaf'?
Raw output
{"message": "[Vale.Spelling] Did you really mean 'Karaf'?", "location": {"path": "versioned_docs/version-2.0.0/running-keploy/keploy-karaf.md", "range": {"start": {"line": 37, "column": 29}}}, "severity": "ERROR"}

### Update `JAVA_OPTS` for linux/mac in `setenv` File

1. Navigate to the `bin` directory of your Apache Karaf installation.

Check failure on line 41 in versioned_docs/version-2.0.0/running-keploy/keploy-karaf.md

View workflow job for this annotation

GitHub Actions / vale

[vale] versioned_docs/version-2.0.0/running-keploy/keploy-karaf.md#L41

[Vale.Spelling] Did you really mean 'Karaf'?
Raw output
{"message": "[Vale.Spelling] Did you really mean 'Karaf'?", "location": {"path": "versioned_docs/version-2.0.0/running-keploy/keploy-karaf.md", "range": {"start": {"line": 41, "column": 51}}}, "severity": "ERROR"}
2. Open the `setenv` file for editing.
3. Add the paths of the downloaded agents under the `JAVA_OPTS` section. For example:

```bash
export JAVA_OPTS="-javaagent:/path/to/java-agent-1.0-SNAPSHOT.jar"
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"
```

### Update `JAVA_OPTS` for windows in `setenv.bat` File

1. Navigate to the `bin` directory of your Apache Karaf installation.

Check failure on line 52 in versioned_docs/version-2.0.0/running-keploy/keploy-karaf.md

View workflow job for this annotation

GitHub Actions / vale

[vale] versioned_docs/version-2.0.0/running-keploy/keploy-karaf.md#L52

[Vale.Spelling] Did you really mean 'Karaf'?
Raw output
{"message": "[Vale.Spelling] Did you really mean 'Karaf'?", "location": {"path": "versioned_docs/version-2.0.0/running-keploy/keploy-karaf.md", "range": {"start": {"line": 52, "column": 51}}}, "severity": "ERROR"}
2. Open the `setenv.bat` file for editing.
3. Add the paths of the downloaded agents under the `JAVA_OPTS` section. For example:

```bash
set JAVA_OPTS=-javaagent:/path/to/java-agent-1.0-SNAPSHOT.jar
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
```

Replace `/path/to/` with the actual paths where you downloaded the JAR files.

### Update `config.properties`

1. Navigate to the `etc/config.properties` file in your Karaf installation.

Check failure on line 65 in versioned_docs/version-2.0.0/running-keploy/keploy-karaf.md

View workflow job for this annotation

GitHub Actions / vale

[vale] versioned_docs/version-2.0.0/running-keploy/keploy-karaf.md#L65

[Vale.Spelling] Did you really mean 'Karaf'?
Raw output
{"message": "[Vale.Spelling] Did you really mean 'Karaf'?", "location": {"path": "versioned_docs/version-2.0.0/running-keploy/keploy-karaf.md", "range": {"start": {"line": 65, "column": 57}}}, "severity": "ERROR"}
2. Add the following entry under the `bootdelegation` section to allow OSGi bundles to access Keploy artifacts:

Check failure on line 66 in versioned_docs/version-2.0.0/running-keploy/keploy-karaf.md

View workflow job for this annotation

GitHub Actions / vale

[vale] versioned_docs/version-2.0.0/running-keploy/keploy-karaf.md#L66

[Vale.Spelling] Did you really mean 'OSGi'?
Raw output
{"message": "[Vale.Spelling] Did you really mean 'OSGi'?", "location": {"path": "versioned_docs/version-2.0.0/running-keploy/keploy-karaf.md", "range": {"start": {"line": 66, "column": 72}}}, "severity": "ERROR"}

```properties
org.osgi.framework.bootdelegation = \
com.sun.*, \
javax.transaction, \
javax.transaction.xa, \
javax.xml.crypto, \
javax.xml.crypto.*, \
javax.security.cert, \
jdk.nashorn.*, \
sun.*, \
jdk.internal.reflect, \
jdk.internal.reflect.*, \
org.apache.karaf.jaas.boot, \
org.apache.karaf.jaas.boot.principal, \
io.keploy.*
```

---

## Step 3: Start Apache Karaf and Export Environment Variables

Check failure on line 87 in versioned_docs/version-2.0.0/running-keploy/keploy-karaf.md

View workflow job for this annotation

GitHub Actions / vale

[vale] versioned_docs/version-2.0.0/running-keploy/keploy-karaf.md#L87

[Vale.Spelling] Did you really mean 'Karaf'?
Raw output
{"message": "[Vale.Spelling] Did you really mean 'Karaf'?", "location": {"path": "versioned_docs/version-2.0.0/running-keploy/keploy-karaf.md", "range": {"start": {"line": 87, "column": 25}}}, "severity": "ERROR"}

1. Start Apache Karaf by navigating to the `bin` directory and running:

Check failure on line 89 in versioned_docs/version-2.0.0/running-keploy/keploy-karaf.md

View workflow job for this annotation

GitHub Actions / vale

[vale] versioned_docs/version-2.0.0/running-keploy/keploy-karaf.md#L89

[Vale.Spelling] Did you really mean 'Karaf'?
Raw output
{"message": "[Vale.Spelling] Did you really mean 'Karaf'?", "location": {"path": "versioned_docs/version-2.0.0/running-keploy/keploy-karaf.md", "range": {"start": {"line": 89, "column": 17}}}, "severity": "ERROR"}

```bash
./karaf
```

2. Export the API key required for Keploy to function by running the following command in the same terminal session:

```bash
export API_KEY="<API_KEY>"
```

Replace the `API_KEY` value with your actual API key if different.

3. Export the application path to point to your target folder containing Java classes:

```bash
export APP_PATH="/Users/sarthak_1/Downloads/karaf-sample/user-service"
```

Replace the `APP_PATH` value with the absolute path to your application's target folder.

---

## Step 4: Import Postman Collection

1. Ensure you have a Postman collection ready for your application.
2. Run the following command to import the Postman collection as Keploy tests:

```bash
keploy import postman --path="/path/to/YourPostmanCollection.json"
```

Replace `/path/to/YourPostmanCollection.json` with the actual path to your Postman collection.

---

## Step 5: Run Keploy Tests

Use the following command to run the imported tests:

```bash
keploy test --base-path="http://localhost:8181"
```

This assumes your Karaf application is running locally on port 8181.

Check failure on line 134 in versioned_docs/version-2.0.0/running-keploy/keploy-karaf.md

View workflow job for this annotation

GitHub Actions / vale

[vale] versioned_docs/version-2.0.0/running-keploy/keploy-karaf.md#L134

[Vale.Spelling] Did you really mean 'Karaf'?
Raw output
{"message": "[Vale.Spelling] Did you really mean 'Karaf'?", "location": {"path": "versioned_docs/version-2.0.0/running-keploy/keploy-karaf.md", "range": {"start": {"line": 134, "column": 19}}}, "severity": "ERROR"}

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.
Loading