Skip to content

Commit aef783a

Browse files
Merge branch 'main' into docs/k8s-proxy-benefits-update
2 parents bba1609 + d3a9c86 commit aef783a

4 files changed

Lines changed: 145 additions & 136 deletions

File tree

vale_styles/config/vocabularies/Base/accept.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,12 @@ Deduplication
2020
distros
2121
dockerfile
2222
Docusaurus
23+
Dropwizard
2324
expected_string
2425
Functionize
2526
GitHub
2627
gjson
28+
Gradle
2729
graphql
2830
Hacktoberfest
2931
HAProxy
@@ -40,11 +42,13 @@ Idempotency
4042
JaCoCo
4143
Jacoco
4244
JBehave
45+
Jersey
4346
JMeter
4447
json_contains
4548
json_equal
4649
json_path
4750
JUnit
51+
[Kk]araf
4852
kubectl
4953
kubernetes
5054
test-gen
@@ -68,6 +72,7 @@ Redis
6872
[Rr]epo
6973
Reqnroll
7074
SDK
75+
servlet
7176
signin
7277
Spotify
7378
status_code

versioned_docs/version-4.0.0/keploy-cloud/deduplication.md

Lines changed: 67 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -121,52 +121,63 @@ keploy dedup --rm
121121

122122
#### 1. Pre-requisite
123123

124-
Add the Keploy Java SDK to your application:
124+
Java dynamic deduplication uses JaCoCo runtime coverage. Attach the Keploy Java agent to emit per-test coverage signals, and attach the JaCoCo runtime agent so the SDK can read the coverage data. The Java agent is framework-agnostic across Spring Boot, Dropwizard/Jersey, plain executable jars, classpath-based apps, servlet/WAR archives, etc.
125125

126-
```xml
127-
<dependency>
128-
<groupId>io.keploy</groupId>
129-
<artifactId>keploy-sdk</artifactId>
130-
<version>2.0.0</version>
131-
</dependency>
132-
```
133-
134-
For Spring Boot 2 or other `javax.servlet` applications, register the Keploy middleware in your main class:
135-
136-
```java
137-
import io.keploy.servlet.KeployMiddleware;
138-
import org.springframework.boot.autoconfigure.SpringBootApplication;
139-
import org.springframework.context.annotation.Import;
140-
141-
@SpringBootApplication
142-
@Import(KeployMiddleware.class)
143-
public class App {
144-
}
145-
```
146-
147-
For Spring Boot 3, Jakarta EE applications, other frameworks, or custom launchers, start the agent during application startup:
148-
149-
```java
150-
import io.keploy.dedup.KeployDedupAgent;
151-
152-
KeployDedupAgent.start();
153-
```
154-
155-
Java dynamic deduplication uses JaCoCo runtime coverage. The SDK reads coverage in-process via JaCoCo's runtime API (`org.jacoco.agent.rt.RT.getAgent()`), so attaching the JaCoCo Java agent is enough: no TCP server flags, no `--pass-through-ports`.
156-
157-
```bash
158-
java -javaagent:/path/to/org.jacoco.agent-runtime.jar -jar target/app.jar
159-
```
126+
Copy both jars into `target/` during your Maven build (do not add the Keploy SDK as an application dependency, and do not import Keploy classes from your code).
160127

161-
If the in-process API is unavailable for some reason (for example, an isolated class loader), the SDK transparently falls back to JaCoCo's TCP server mode. To force the fallback, launch JaCoCo in `tcpserver` mode and tell Keploy to leave that port alone:
162-
163-
```bash
164-
java -javaagent:/path/to/org.jacoco.agent-runtime.jar=address=127.0.0.1,port=36320,output=tcpserver \
128+
```xml
129+
<plugin>
130+
<groupId>org.apache.maven.plugins</groupId>
131+
<artifactId>maven-dependency-plugin</artifactId>
132+
<version>3.6.1</version>
133+
<executions>
134+
<execution>
135+
<id>copy-keploy-java-agent</id>
136+
<phase>package</phase>
137+
<goals><goal>copy</goal></goals>
138+
<configuration>
139+
<artifactItems>
140+
<artifactItem>
141+
<groupId>io.keploy</groupId>
142+
<artifactId>keploy-sdk</artifactId>
143+
<version>2.0.6</version>
144+
<outputDirectory>${project.build.directory}</outputDirectory>
145+
<destFileName>keploy-sdk.jar</destFileName>
146+
</artifactItem>
147+
</artifactItems>
148+
</configuration>
149+
</execution>
150+
<execution>
151+
<id>copy-jacoco-agent</id>
152+
<phase>package</phase>
153+
<goals><goal>copy</goal></goals>
154+
<configuration>
155+
<artifactItems>
156+
<artifactItem>
157+
<groupId>org.jacoco</groupId>
158+
<artifactId>org.jacoco.agent</artifactId>
159+
<version>0.8.12</version>
160+
<classifier>runtime</classifier>
161+
<type>jar</type>
162+
<outputDirectory>${project.build.directory}</outputDirectory>
163+
<destFileName>jacocoagent.jar</destFileName>
164+
</artifactItem>
165+
</artifactItems>
166+
</configuration>
167+
</execution>
168+
</executions>
169+
</plugin>
170+
```
171+
172+
Run the app with both agents attached:
173+
174+
```bash
175+
java \
176+
-javaagent:target/keploy-sdk.jar \
177+
-javaagent:target/jacocoagent.jar \
165178
-jar target/app.jar
166179
```
167180

168-
The default JaCoCo endpoint for the fallback is `127.0.0.1:36320`. You can override it with `KEPLOY_JACOCO_HOST` and `KEPLOY_JACOCO_PORT`, or with the JVM properties `keploy.jacoco.host` and `keploy.jacoco.port`. When using the fallback, add the JaCoCo port to `--pass-through-ports` so coverage-control traffic is not mocked.
169-
170181
#### 2. Build Configuration
171182

172183
Build the application before running Keploy so the Java class files are available for coverage analysis:
@@ -175,33 +186,27 @@ Build the application before running Keploy so the Java class files are availabl
175186
mvn clean package -DskipTests
176187
```
177188

178-
By default, the SDK scans `target/classes`, `build/classes/java/main`, and runtime classpath jars. For custom layouts or restricted Docker images, set `KEPLOY_JAVA_CLASS_DIRS` to the class directories or jars that should be analyzed.
189+
By default, the SDK scans Maven `target/classes`, Gradle `build/classes/java/main`, executable jars, Spring Boot `BOOT-INF/classes`, servlet `WEB-INF/classes`, and runtime classpath archives. For custom layouts or restricted Docker images, set `KEPLOY_JAVA_CLASS_DIRS` to the class directories or archives that should be analyzed. For shaded or uber-jar Docker images, copy the compiled application classes into the image and point `KEPLOY_JAVA_CLASS_DIRS` at that directory so dependency classes do not participate in dedup signatures.
179190

180191
#### 3. Dockerfile Configuration (Important for Docker Users)
181192

182-
When you use Docker or Docker Compose, make sure the final runtime image contains:
183-
184-
- the runnable application jar,
185-
- the JaCoCo runtime agent jar,
186-
- the compiled classes or the fat jar that contains the application classes.
187-
188-
For example:
193+
When you use Docker or Docker Compose, copy four artifacts into the runtime image and attach both agents in the entrypoint:
189194

190195
```dockerfile
191-
COPY target/app.jar /app/app.jar
192-
COPY target/classes /app/target/classes
193-
COPY jacocoagent.jar /app/jacocoagent.jar
194-
```
196+
COPY target/app.jar /app/app.jar
197+
COPY target/keploy-sdk.jar /app/keploy-sdk.jar
198+
COPY target/jacocoagent.jar /app/jacocoagent.jar
199+
COPY target/classes /app/classes
195200

196-
Then run the app with the JaCoCo agent attached:
201+
ENV KEPLOY_JAVA_CLASS_DIRS=/app/classes
197202

198-
```bash
199-
java -javaagent:/app/jacocoagent.jar -jar /app/app.jar
203+
ENTRYPOINT ["java", \
204+
"-javaagent:/app/keploy-sdk.jar", \
205+
"-javaagent:/app/jacocoagent.jar", \
206+
"-jar", "/app/app.jar"]
200207
```
201208

202-
Keploy and the Java SDK exchange per-test coverage signals over `/tmp/coverage_control.sock` and `/tmp/coverage_data.sock`. For Docker and Docker Compose, Keploy injects a shared `keploy-sockets-vol:/tmp` mount into the application container and the Keploy agent container so both processes see the same socket paths.
203-
204-
For hardened Docker runs, the Java dedup sample is validated with a non-root runtime user, a read-only root filesystem, dropped Linux capabilities, `no-new-privileges`, and Keploy's shared `/tmp` named volume for the Keploy control/data sockets and JaCoCo output. Do not add a conflicting `/tmp` bind mount or `tmpfs`; Keploy requires the injected shared `/tmp` volume to reach the Java SDK control socket.
209+
Keploy injects a shared `keploy-sockets-vol:/tmp` mount into both the application container and the Keploy agent container at replay time so the dedup sockets are visible on both sides. Keep `/tmp` writable in the container; do not add a conflicting `/tmp` bind mount or `tmpfs`. Restricted containers (non-root user, read-only root filesystem, dropped capabilities) work as long as `/tmp` stays writable.
205210

206211
#### 4. Run Deduplication
207212

@@ -214,22 +219,16 @@ keploy test -c "docker compose up" --container-name containerName --dedup --lang
214219
For Native, run:
215220

216221
```bash
217-
keploy test -c "java -javaagent:/path/to/org.jacoco.agent-runtime.jar -jar target/app.jar" --dedup --language java
222+
keploy test -c "java -javaagent:target/keploy-sdk.jar -javaagent:target/jacocoagent.jar -jar target/app.jar" --dedup --language java
218223
```
219224

220-
If the SDK falls back to the JaCoCo TCP server, also pass `--pass-through-ports <jacoco-port>` so Keploy does not try to mock the coverage-control connection.
221-
222-
This will generate a `dedupData.yaml` file.
223-
224-
After this, run:
225+
This produces `dedupData.yaml`, a per-testcase coverage map (`testSetID/testCaseID` to executed lines per source file) Keploy uses to compute redundancy.
225226

226227
```bash
227228
keploy dedup
228229
```
229230

230-
This command will create a `duplicates.yaml` file containing the test cases that dynamic deduplication marked as redundant.
231-
232-
To apply the dynamic deduplication cleanup to the local Keploy test set, run:
231+
This reads `dedupData.yaml` and writes `duplicates.yaml`, listing the testcases that dedup marked redundant (grouped by test-set). To remove those testcases from the local Keploy test set:
233232

234233
```bash
235234
keploy dedup --rm

versioned_docs/version-4.0.0/running-keploy/keploy-karaf.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,13 @@ curl --silent -O -L https://keploy.io/ent/install.sh && source install.sh
3535

3636
Use `wget` to download the necessary JAR files:
3737

38-
- [io.keploy.agent-2.0.1.jar](https://keploy-enterprise.s3.us-west-2.amazonaws.com/agent-jars/io.keploy.agent-2.0.1.jar)
38+
- [io.keploy.agent-2.0.2.jar](https://keploy-enterprise.s3.us-west-2.amazonaws.com/agent-jars/io.keploy.agent-2.0.2.jar)
3939
- [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)
4040

4141
Run the following commands to download the files:
4242

4343
```bash
44-
wget https://keploy-enterprise.s3.us-west-2.amazonaws.com/agent-jars/io.keploy.agent-2.0.1.jar
44+
wget https://keploy-enterprise.s3.us-west-2.amazonaws.com/agent-jars/io.keploy.agent-2.0.2.jar
4545
wget https://keploy-enterprise.s3.us-west-2.amazonaws.com/agent-jars/org.jacoco.agent-0.8.12-runtime.jar
4646
```
4747

@@ -54,7 +54,7 @@ wget https://keploy-enterprise.s3.us-west-2.amazonaws.com/agent-jars/org.jacoco.
5454
3. Add the paths of the downloaded agents under the `JAVA_OPTS` section. For example:
5555

5656
```bash
57-
export JAVA_OPTS="-javaagent:/path/to/io.keploy.agent-2.0.1.jar"
57+
export JAVA_OPTS="-javaagent:/path/to/io.keploy.agent-2.0.2.jar"
5858
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"
5959
```
6060

0 commit comments

Comments
 (0)