Skip to content

Commit 4b084eb

Browse files
docs(dedup): add deduplication guides
Document static deduplication and Java coverage-based dedup Docker requirements. Add Vale vocabulary entries for Java dedup terminology. Signed-off-by: Asish Kumar <officialasishkumar@gmail.com>
1 parent 74c2f37 commit 4b084eb

5 files changed

Lines changed: 396 additions & 12 deletions

File tree

vale_styles/config/vocabularies/Base/accept.txt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,13 @@ Cmd
1212
Cobertura
1313
config
1414
containerName
15+
classpath
1516
custom_functions
1617
DBs
1718
declaratively
1819
Deduplication
20+
Distroless
21+
distroless
1922
distros
2023
dockerfile
2124
Docusaurus
@@ -105,3 +108,11 @@ updated_at
105108
shipping_address_id
106109
[Ll]inux
107110
[Ee]nv
111+
[Kk]8s
112+
[Dd]edup
113+
[Cc]ron
114+
[Tt]oolchain
115+
[Rr]untime[s]?
116+
normalisation
117+
behaviour
118+
polyglot

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

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ keywords:
1212
- deduplication
1313
- duplicate tests
1414
- golang
15+
- java
1516
- testcases
1617
---
1718

@@ -113,3 +114,97 @@ In order to remove all the duplicate test cases, run the following command:
113114
```bash
114115
keploy dedup --rm
115116
```
117+
118+
### For Java Applications
119+
120+
**1. Pre-requisite**
121+
122+
Attach a JaCoCo agent when you start the application for replay. Keploy reads coverage directly from JaCoCo during `keploy test`.
123+
124+
Do **not** package `org.jacoco.agent` inside the application runtime classpath or fat jar. Keep it as a standalone agent jar and attach it only through `-javaagent`.
125+
126+
**2. Native Run Configuration**
127+
128+
Build the application and keep a `jacocoagent.jar` next to the app artifact:
129+
130+
```bash
131+
mvn clean package -DskipTests
132+
```
133+
134+
Run deduplication natively with:
135+
136+
```bash
137+
keploy test -c "java -javaagent:target/jacocoagent.jar -jar target/app.jar" --dedup
138+
```
139+
140+
**3. Dockerfile Configuration (Important for Docker Users)**
141+
142+
Your runtime image must copy the JaCoCo agent jar and start Java with `destfile=/tmp/jacoco.exec`.
143+
144+
Example fat-jar runtime image:
145+
146+
```dockerfile
147+
FROM eclipse-temurin:17-jre
148+
149+
WORKDIR /app
150+
151+
COPY target/app.jar /app/app.jar
152+
COPY target/jacocoagent.jar /app/jacocoagent.jar
153+
154+
ENTRYPOINT ["java", "-javaagent:/app/jacocoagent.jar=destfile=/tmp/jacoco.exec", "-jar", "/app/app.jar"]
155+
```
156+
157+
Example exploded-classpath runtime image:
158+
159+
```dockerfile
160+
FROM eclipse-temurin:17-jre
161+
162+
WORKDIR /app
163+
164+
COPY target/classes /app/classes
165+
COPY target/dependency /app/libs
166+
COPY target/jacocoagent.jar /app/jacocoagent.jar
167+
168+
ENV KEPLOY_JAVA_CLASS_DIRS=/app/classes
169+
170+
ENTRYPOINT ["java", "-javaagent:/app/jacocoagent.jar=destfile=/tmp/jacoco.exec", "-cp", "/app/classes:/app/libs/*", "com.example.Main"]
171+
```
172+
173+
Keep these Docker constraints in mind:
174+
175+
- Rebuild the image before replay with `docker compose build` so Keploy runs the current jar, agent, and Dockerfile.
176+
- Leave `/tmp` available to the container. Keploy injects a shared `/tmp` mount during `keploy test`, so do not pre-bind or replace `/tmp` in your Compose service.
177+
- Distroless and read-only root filesystem images are supported as long as the image still includes a Java launcher, copies `jacocoagent.jar`, and leaves `/tmp` writable at runtime.
178+
- Fat-jar images do not need `KEPLOY_JAVA_CLASS_DIRS`. Exploded-classpath images do.
179+
- The current Java dedup sample is validated in CI on Java 8, 17, and 21. The distroless example uses Java 17.
180+
181+
**4. Run Deduplication**
182+
183+
For Docker, run:
184+
185+
```bash
186+
docker compose build
187+
keploy test -c "docker compose up" --containerName containerName --dedup
188+
```
189+
190+
For Native, run:
191+
192+
```bash
193+
keploy test -c "java -javaagent:target/jacocoagent.jar -jar target/app.jar" --dedup
194+
```
195+
196+
This will generate a `dedupData.yaml` file.
197+
198+
After this, run:
199+
200+
```bash
201+
keploy dedup
202+
```
203+
204+
This command will create a `duplicates.yaml` file which will contain all the test cases which were found to be duplicate.
205+
206+
In order to remove all the duplicate test cases, run the following command:
207+
208+
```bash
209+
keploy dedup --rm
210+
```

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

Lines changed: 96 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
id: deduplication
33
title: Remove Duplicates Tests
44
sidebar_label: Remove Duplicate Tests
5-
description: "Remove duplicate test cases with Keploy Enterprise deduplication save time and resources by eliminating redundant tests."
5+
description: "Remove duplicate test cases with Keploy Enterprise deduplication: save time and resources by eliminating redundant tests."
66
tags:
77
- explanation
88
- feature guide
@@ -13,6 +13,7 @@ keywords:
1313
- deduplication
1414
- duplicate tests
1515
- golang
16+
- java
1617
- testcases
1718
---
1819

@@ -114,3 +115,97 @@ In order to remove all the duplicate test cases, run the following command:
114115
```bash
115116
keploy dedup --rm
116117
```
118+
119+
### For Java Applications
120+
121+
**1. Pre-requisite**
122+
123+
Attach a JaCoCo agent when you start the application for replay. Keploy reads coverage directly from JaCoCo during `keploy test`.
124+
125+
Do **not** package `org.jacoco.agent` inside the application runtime classpath or fat jar. Keep it as a standalone agent jar and attach it only through `-javaagent`.
126+
127+
**2. Native Run Configuration**
128+
129+
Build the application and keep a `jacocoagent.jar` next to the app artifact:
130+
131+
```bash
132+
mvn clean package -DskipTests
133+
```
134+
135+
Run deduplication natively with:
136+
137+
```bash
138+
keploy test -c "java -javaagent:target/jacocoagent.jar -jar target/app.jar" --dedup
139+
```
140+
141+
**3. Dockerfile Configuration (Important for Docker Users)**
142+
143+
Your runtime image must copy the JaCoCo agent jar and start Java with `destfile=/tmp/jacoco.exec`.
144+
145+
Example fat-jar runtime image:
146+
147+
```dockerfile
148+
FROM eclipse-temurin:17-jre
149+
150+
WORKDIR /app
151+
152+
COPY target/app.jar /app/app.jar
153+
COPY target/jacocoagent.jar /app/jacocoagent.jar
154+
155+
ENTRYPOINT ["java", "-javaagent:/app/jacocoagent.jar=destfile=/tmp/jacoco.exec", "-jar", "/app/app.jar"]
156+
```
157+
158+
Example exploded-classpath runtime image:
159+
160+
```dockerfile
161+
FROM eclipse-temurin:17-jre
162+
163+
WORKDIR /app
164+
165+
COPY target/classes /app/classes
166+
COPY target/dependency /app/libs
167+
COPY target/jacocoagent.jar /app/jacocoagent.jar
168+
169+
ENV KEPLOY_JAVA_CLASS_DIRS=/app/classes
170+
171+
ENTRYPOINT ["java", "-javaagent:/app/jacocoagent.jar=destfile=/tmp/jacoco.exec", "-cp", "/app/classes:/app/libs/*", "com.example.Main"]
172+
```
173+
174+
Keep these Docker constraints in mind:
175+
176+
- Rebuild the image before replay with `docker compose build` so Keploy runs the current jar, agent, and Dockerfile.
177+
- Leave `/tmp` available to the container. Keploy injects a shared `/tmp` mount during `keploy test`, so do not pre-bind or replace `/tmp` in your Compose service.
178+
- Distroless and read-only root filesystem images are supported as long as the image still includes a Java launcher, copies `jacocoagent.jar`, and leaves `/tmp` writable at runtime.
179+
- Fat-jar images do not need `KEPLOY_JAVA_CLASS_DIRS`. Exploded-classpath images do.
180+
- The current Java dedup sample is validated in CI on Java 8, 17, and 21. The distroless example uses Java 17.
181+
182+
**4. Run Deduplication**
183+
184+
For Docker, run:
185+
186+
```bash
187+
docker compose build
188+
keploy test -c "docker compose up" --containerName containerName --dedup
189+
```
190+
191+
For Native, run:
192+
193+
```bash
194+
keploy test -c "java -javaagent:target/jacocoagent.jar -jar target/app.jar" --dedup
195+
```
196+
197+
This will generate a `dedupData.yaml` file.
198+
199+
After this, run:
200+
201+
```bash
202+
keploy dedup
203+
```
204+
205+
This command will create a `duplicates.yaml` file which will contain all the test cases which were found to be duplicate.
206+
207+
In order to remove all the duplicate test cases, run the following command:
208+
209+
```bash
210+
keploy dedup --rm
211+
```

0 commit comments

Comments
 (0)