Skip to content

fix(simple-java-dedup): run on embedded Tomcat for java-sdk v3 dynamic dedup - #158

Open
slayerjain wants to merge 1 commit into
mainfrom
fix/simple-java-dedup-embedded-tomcat
Open

slayerjain wants to merge 1 commit into
mainfrom
fix/simple-java-dedup-embedded-tomcat

Conversation

@slayerjain

Copy link
Copy Markdown
Member

Summary

Switches simple-java-dedup from com.sun.net.httpserver.HttpServer to embedded Tomcat 9 (org.apache.tomcat.embed:tomcat-embed-core:9.0.121, Java 8+ compatible) so it works out of the box with both Kubernetes (k8s-proxy >= v3.8.30) and CLI dynamic deduplication.

Why

keploy-sdk >= 2.3.x counts HTTP request windows at supported server entry points (Tomcat 8.5–11, Jetty 9.4–12, Undertow) so background threads and post-response work cannot leak coverage between test cases. com.sun.net.httpserver.HttpServer is not counted, so Kubernetes dynamic dedup fails closed (unverified:no-server-entry) and keeps all test cases with 0 duplicates.

Changes

  • simple-java-dedup/pom.xml: add tomcat-embed-core:9.0.121, copy runtime dependencies into target/lib, and emit manifest Class-Path: lib/... (agents remain outside target/lib).
  • simple-java-dedup/src/main/java/.../SimpleJavaDedupApplication.java: serve the same 5 exact paths (/healthz, /grade, /shipping, /inventory, /invoice) with the same branch structure and JSON responses on embedded Tomcat.
  • simple-java-dedup/Dockerfile & .dockerignore: include target/lib alongside /app/app.jar (still running as non-root uid 10001).
  • simple-java-dedup/README.md: explain why embedded Tomcat is used and list the supported Java HTTP servers (Tomcat 8.5–11, Jetty 9.4–12, Undertow).

Verification

Box-verified on both Java 8 (eclipse-temurin:8-jre) and Java 17 (eclipse-temurin:17-jre) as non-root uid 10001 with java-sdk 2.3.1 (keploy-dedup-jars:3.8.30):

  • All 14 checked-in keploy/test-set-0/tests/test-*.yaml requests returned exact matching status code, Content-Type: application/json, and JSON body.
  • HELLO reported windowCut=true, asyncExecutors=true, 0 unverified frames.
  • Exact 4 intentional duplicate pairs matched: (test-3, test-2), (test-7, test-6), (test-10, test-9), (test-13, test-12).
…c dedup

com.sun.net.httpserver.HttpServer is not counted by keploy-sdk's
request-window tracker, so Kubernetes dynamic dedup (k8s-proxy >= v3.8.30)
fails closed with unverified:no-server-entry and drops 0 duplicates.

- Switch simple-java-dedup to embedded Tomcat 9 (tomcat-embed-core 9.0.121,
  Java 8+ compatible), preserving all 5 exact endpoints (/healthz, /grade,
  /shipping, /inventory, /invoice), branch structure, and JSON responses.
- Copy runtime dependencies into target/lib with manifest Class-Path so
  both native `java -jar target/simple-java-dedup.jar` and the Dockerfile
  work without baking agents into lib/.
- Document supported Java HTTP servers (Tomcat 8.5-11, Jetty 9.4-12,
  Undertow) and why embedded Tomcat is used in simple-java-dedup/README.md.

Signed-off-by: slayerjain <shubhamkjain@outlook.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

1 participant