Skip to content

Latest commit

 

History

History

java-dedup

README.md

Java Dynamic Deduplication Sample

A Spring Boot application used by Keploy CI to validate Java dynamic deduplication. It mirrors the Go dedup sample by exposing a broad set of endpoints and committing 400 replay fixtures across four testsets.

CI does not record this sample. The keploy/ directory is checked in so the pipeline only builds the app and runs replay with --dedup --skip-app-restart. When the sample behavior changes, record the fixtures locally and push the updated keploy/ files.

The Keploy Java SDK (io.keploy:keploy-sdk >= 2.3.0, current release 2.4.0) is attached as a Java agent at replay time. The sample does not compile against io.keploy:keploy-sdk and does not import Keploy classes in application code.

keploy-sdk.jar bundles the JaCoCo runtime agent and starts it automatically scoped to your application classes. Attach only -javaagent:target/keploy-sdk.jar; do not attach a separate -javaagent:target/jacocoagent.jar alongside it.

Setup

mvn -B -DskipTests -Dkeploy.agent.version=2.4.0 clean package

This builds the runnable application jar and copies target/keploy-sdk.jar next to it.

Run dedup natively

keploy test \
  -c "java -javaagent:target/keploy-sdk.jar -jar target/java-dedup.jar" \
  --dedup --skip-app-restart --language java --delay 1 \
  --health-url "http://127.0.0.1:8080/healthz" \
  --health-poll-timeout 30s \
  --disableMockUpload --disableReportUpload

keploy dedup --path .

Run dedup with Docker

docker compose build
keploy test \
  -c "docker compose up" \
  --container-name "dedup-java" \
  --host "127.0.0.1" \
  --dedup --skip-app-restart --language java --delay 1 \
  --health-url "http://127.0.0.1:8080/healthz" \
  --health-poll-timeout 30s \
  --disableMockUpload --disableReportUpload

keploy dedup --path .

During keploy test, Enterprise rewrites the Compose file and injects its own shared /tmp volume for the dedup control/data sockets. The base sample Compose file does not need a host /tmp bind mount. Re-run docker compose build whenever the jar, keploy-sdk.jar, or Dockerfile changes so replay uses the current image.

Run dedup with direct Docker

docker compose build
keploy test \
  -c "docker run --rm --name dedup-java -p 8080:8080 java-dedup:local" \
  --container-name "dedup-java" \
  --host "127.0.0.1" \
  --dedup --skip-app-restart --language java --delay 1 \
  --health-url "http://127.0.0.1:8080/healthz" \
  --health-poll-timeout 30s \
  --disableMockUpload --disableReportUpload

keploy dedup --path .

During direct docker run, Enterprise injects the same shared /tmp volume into the app container. Do not pass your own /tmp mount in the app command.

The CI pipeline also validates additional production-style layouts for the same app, including native classpath, direct Docker run, Docker Compose, exploded classpath images, restricted runtime, restricted classpath, and distroless packaging.