Skip to content

Tags

Tags

v2.2.0

Toggle v2.2.0's commit message

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
feat(coverage): coverage table in the app's JVM; flag tests a job ran…

… in (#194)

Signed-off-by: slayerjain <[email protected]>

v2.1.3

Toggle v2.1.3's commit message

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
ci: sign releases with the new release key, and check secrets first (#…

…191)

The release key 8541784E4EC36FB8 could not sign in GitHub Actions: its
private half was only in the retired Woodpecker pipeline's secrets, so
v2.1.2's "Build, sign and publish to Maven Central" failed with "No secret
key" and never published.

Releases are now signed with a new key, F844278E3B5F9051 (fingerprint
0167FEA3204A35D8C1E11EE9F844278E3B5F9051), held in MAVEN_GPG_PRIVATE_KEY
and MAVEN_GPG_PASSPHRASE and published on keyserver.ubuntu.com, where
Central checks signatures.

release.yml now fails before anything is built or signed, naming each
release secret that is missing, as keploy-junit5-release.yml already did.
SECURITY.md lists the fingerprints of both keys and how to check a file.

Signed-off-by: slayerjain <[email protected]>

v2.1.2

Toggle v2.1.2's commit message

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
fix(dedup): bind the control socket before the app starts (#189)

* fix(dedup): bind the control socket before the app starts

The agent bound /tmp/coverage_control.sock on its background thread, and
nothing ordered that bind before the app's first answer to a health check.
Keploy fires tests as soon as the app answers, so when the bind came late
the first tests' START and END reached no one and their coverage was lost:
a run reported 153 of 200 tests covered. The END that met the socket just
after it came up logged "Ignoring mismatched END command".

start() now binds on the calling thread, which is premain for -javaagent,
before the app's main runs, and hands the bound socket to the accept
thread. A bind failure still leaves the app running without dedup: start()
logs it and returns false, and nothing escapes premain.

An END with no START for that test publishes nothing, yet was answered
ACK, so Keploy took it as delivered and waited for a record that never
came. The unix control socket now answers IGNORED. A Keploy that does not
know the reply reads any answer as taken, as it did before.

* test(dedup): check the control socket is up when main runs, in CI

The smoke harness waited for the control socket file before its first
command. That wait is the race Keploy loses: it fires tests as soon as the
app answers, with no such wait, so the smoke could not see a late bind.
START is now main's first act and nothing waits for the socket, so an agent
that binds it after premain fails the smoke with the jar that ships. The
smoke fails this way on JDK 8, 17 and 21 with the bind put back on the
accept thread.

The verify job built with -DskipTests, so the module's unit tests ran in no
pipeline. It now runs them on each JDK.

* fix(dedup): name a test whose END was ignored on the TCP transport

On the TCP transport an END with no START for it was answered with a bare
ACK and no COV, so the collector could not tell the test had gone unmeasured.
Only the app's own log said so, in a pod the collector never reads. The unix
socket already answers IGNORED for the same END.

The SDK now sends "IGNORED <id>" ahead of the ACK. The ACK stays because it
is what ends the collector's wait: a collector that does not know the frame
skips it and goes on as before, where IGNORED in place of ACK would have cost
it a full ACK timeout on each such test.

* test(dedup): check the app runs when the native library cannot load

The agent binds its control socket in premain, so junixsocket's native
library now loads there, before the app's main. Whatever that throws,
premain must not stop the app: start() catches Throwable and runs the
app without dedup. Nothing tested that guard; narrowed to IOException,
it passed the unit tests and the smoke while a JVM that cannot load the
library aborted before main.

The smoke now runs an app with junixsocket's override properties
pointing at a library that does not exist, and checks that main ran and
that the agent said the control socket is unavailable, so the case
cannot pass with the library loaded.

* test(dedup): assert the IGNORED reply word that Keploy reads

Keploy's agent reads an answer starting "IGNORED", and k8s-proxy's
collector a frame starting "IGNORED ", as a command the SDK did not
take. The rows compared the reply with the SDK's own constant, so a
change to the word passed them while both readers would take every
ignored END as taken. They now compare it with the literal.


Signed-off-by: slayerjain <[email protected]>

v2.1.1

Toggle v2.1.1's commit message

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
chore(dedup): bump shaded jacoco.core to 0.8.15 to raise the Java cei…

…ling (#186)

The ASM shaded into keploy-sdk.jar comes from this dependency, and it is an
independent ceiling on the bytecode dynamic dedup can instrument — separate from
the jacocoagent.jar in k8s-proxy's init image. While it sat on 0.8.12 it was the
LOWER of the two, so it, not the agent, is what capped dedup at Java 22.

Measured by building this module both ways and reading the shaded ASM out of
each jar:

  jacoco.core 0.8.12  ->  ASM declares V23   (JaCoCo officially supports Java 22)
  jacoco.core 0.8.15  ->  ASM declares V27   (JaCoCo officially supports Java 26)

The 0.8.12 row reproduces the "tops out at Opcodes.V23" note k8s-proxy carried,
and shows why it was read one version too high: the highest version ASM DECLARES
is its experimental one, which sits a release ahead of what it accepts by default.

With this, the SDK's shaded ASM matches the agent's (both V27 / Java 26), so once
a release carrying it is pinned as KEPLOY_SDK_VERSION, k8s-proxy can raise
dedupinject.SDKShadedASMMaxJava to 26 and the effective ceiling —
min(JaCoCoOfficialMaxJava, SDKShadedASMMaxJava) — becomes Java 26.

Build and the module's tests pass unchanged against 0.8.15.

Signed-off-by: Shubham Jain <[email protected]>

v2.1.0

Toggle v2.1.0's commit message

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
Feat/dynamic dedup tcp (#184)

* feat(dedup): TCP client transport for k8s (CoverageTcpClient)

In k8s the dedup coverage collector runs in the k8s-proxy Deployment pod while
the app JVM is in a separate pod, so the shared-/tmp unix sockets can't reach it.
Add a TCP transport selected by KEPLOY_COVERAGE_ENDPOINT (host:port): the SDK
dials the collector and keeps one bidirectional connection for the whole replay.

Wire protocol (newline-delimited), matching the k8s-proxy collector:
  collector -> SDK : "START <id>" | "END <id>"
  SDK -> collector : "ACK"                        (after START reset)
                     "COV <compact-json>" + "ACK" (after END dump)

- CoverageTcpClient mirrors CommandServer's dispatch but inverts roles (SDK is the
  client); reuses CoverageCollector reset/capture unchanged. COV precedes ACK so the
  collector records the payload before the ACK releases the caller.
- Connect loop retries (collector listens only once replay begins). No read timeout
  on the long-lived idle-between-tests connection.
- Unix transport stays the default for local/docker (unchanged); the worker field is
  generalized to Closeable so stop() is transport-agnostic.

Validated end-to-end: real JVM (this SDK as -javaagent, TCP client) against the
k8s-proxy DedupCoverage TCP server — coverage flows correctly; the score>=90 pair
dedupes (identical line sets), the score=40 case differs.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>

* fix(dedup): warm up app classes before first test for stable coverage

A fresh JVM runs each class's static initializer (<clinit>) on first use.
JaCoCo charged those one-time lines to whichever test ran first, so a test
could look different from its true duplicates by luck of timing -> the
duplicate set flip-flopped run to run (e.g. 2 vs 4).

On the first START command (app fully started), eagerly Class.forName(...,
initialize=true) every indexed application class so all <clinit> lines run
once, then the normal reset clears them. Every test window then captures
only the lines its own request executes -> deterministic dedup. Best-effort
per class; disable via KEPLOY_JAVA_DEDUP_WARMUP_DISABLED=true. Go is
unaffected (AOT, init() runs once at startup before the first reset).

Co-Authored-By: Claude Opus 4.8 <[email protected]>

* feat(dedup): branch coverage via per-class JaCoCo probe fingerprints

Fingerprint each test by the set of executed JaCoCo probes per class
({className -> [probeIdx]}) instead of executed source lines. Each branch
is instrumented as a distinct probe, so the probe set distinguishes which
branch a test took (true vs false) on a shared line — line status and even
branch counts report identically for both paths. The probe set subsumes
line coverage and uses canonical VM class-name keys (no path normalization).
Only capture() changes; the wire payload, collector, store, and enterprise
compute stay generic over map[string][]int. Removed the now-dead line-decode
helpers (Analyzer/CoverageBuilder, executedLines, resolveSourcePath).

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>

* fix(dedup): address PR review + fix smoke test

- TCP END always emits COV before ACK (even when empty), mirroring the unix
  transport, so the line-oriented collector reads exactly one COV per END and
  cannot desync (Copilot comment).
- Reconnect failures log at INFO only on the first failure, then FINE, to
  avoid ~1/s log spam in k8s; reset on a successful connect (Copilot comment).
- smoke-javaagent.sh asserts the VM class-name key ("smoke/Work") instead of
  the old source-file key ("Work.java"), matching the probe-based fingerprint
  contract; fixes the JDK 8/17/21 smoke jobs.

* feat(dedup): CoverageReporter — line/branch coverage from probe-union + bytecode

Option B for whole-test-set coverage: a pure Java tool that reconstructs
ExecutionData from a fired-probe union (the dedupFingerprints we already persist)
plus a build-constant {classId, probeCount} manifest, runs JaCoCo Analyzer over the
app bytecode, and sums line/branch/instr/method counters over all classes.

Reuses the fingerprints verbatim as input; no JaCoCo internal APIs (id + probeCount
come from the SDK's live ExecutionData). CoverageReporterSelfTest cross-checks the
reconstruct-from-union path against JaCoCo's direct .exec analysis — exact match on
the sample app (lines 78/105, branches 22/42, instr 452/525).

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Signed-off-by: praagyajain <[email protected]>

* feat(dedup): SDK exports bytecode+manifest once per build for coverage (Option B)

After warmup (all app classes loaded), the SDK ships — best-effort, async,
once-per-JVM — a zip of the indexed class bytecode plus a manifest
{vmClassName -> {classId(hex), probeCount}} to k8s-proxy via HTTP multipart
(KEPLOY_BYTECODE_UPLOAD_URL, tagged with KEPLOY_BUILD_TAG). classId/probeCount
come straight from the live ExecutionData, so the offline CoverageReporter needs
no JaCoCo internal APIs. HEAD exists-check uploads at most once per build tag.

Gated by the two envs (webhook-injected); absent => no-op, so dedup-only
deployments are unchanged. Fully non-fatal: never throws into the app or the
per-test dedup path.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Signed-off-by: praagyajain <[email protected]>

* feat(dedup): tolerate proxy self-signed cert on bytecode upload

The bytecode/manifest upload targets k8s-proxy's in-cluster HTTPS control port
(:8080), whose cert is self-signed and may not chain to the app JVM's truststore.
Since the upload is a best-effort, cluster-internal data-plane call (like the
raw-TCP coverage collector), install a trust-all SSLSocketFactory for that HTTPS
call only. No effect on plain-HTTP endpoints.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Signed-off-by: praagyajain <[email protected]>

* feat(dedup): send bytecode manifest+zip over the collector channel

Build a live manifest ({vmClassName -> {classId, probeCount}}) from the proven
per-test capture() path and, when it grows, send the app class bytecode as a
base64 "CLASSES ..." frame on the existing collector TCP connection (:36340)
right after the COV frame. This survives the replay agent's outbound mock
interception, which 502'd the earlier HTTPS upload. k8s-proxy uses this
bytecode + the unioned fingerprints to compute whole-test-set coverage offline.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>

* fix(dedup): address PR review — COV-on-exception, payload-name clarity, doc limits

Resolves the still-open review findings on the current branch (several earlier
ones — dead HTTP/trust-all TLS, reconnect log level, smoke-test assertion,
uploadInFlight — were already fixed by prior commits on this branch):

- COV-on-exception (MED): the TCP END path only emitted COV on success, so a
  capture() failure jumped to the catch and wrote ACK with no COV, desyncing the
  line-oriented collector onto the next test's frames. Restructured so exactly one
  COV (empty on failure) always precedes the ACK; a CLASSES-frame failure is
  isolated and never skips the COV/ACK.
- Payload naming (HIGH): documented that DedupPayload.executedLinesByFile now
  carries probes-by-class ({vmClassName -> [probeIdx]}) under a HISTORICAL wire
  key kept for consumer compat (enterprise #2188, k8s-proxy #574), and renamed the
  local capture/publish variables to executedProbesByClass to match.
- CoverageReporter (MED): documented the load-time-transform undercount (live
  CRC64 class id vs on-disk bytes) — dedup unaffected, only reported numbers.
- Endpoint parsing (LOW): noted the IPv4/DNS host:port assumption of lastIndexOf(':').

Not locally compiled (no JVM/Maven in this environment) — validated by CI.
Deferred (cross-repo / behavioral): send class-zip once vs on manifest growth
(needs k8s-proxy #574 handleClassesFrame to agree), warmup opt-in default,
JUnit fixture tests, and lazy/streamed class-bytes.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>

* fix(dedup): send class zip once per connection, manifest-only after

The coverage bytecode path re-sent the full (constant) class zip on every
manifest growth as one base64 CLASSES line. On a large app the cumulative
class bytecode base64 exceeds k8s-proxy's per-line scanner cap, ending the
collector stream mid-replay with no error — silently corrupting coverage AND
the remaining tests' dedup.

The indexed class set never changes (one-time classpath scan), so:
- send the full CLASSES frame (tag+manifest+zip) ONCE per connection, then
  emit lightweight MANIFEST frames (tag+manifest, no zip) as the manifest grows;
- reset the sent-once flag on every (re)connect so a fresh collector connection
  re-gets the zip (MinIO first-write-wins makes the re-store idempotent),
  preserving the reconnect recovery the old re-send-everything path gave for free.

Removes the O(n^2) resend and keeps any single line small once the zip is out.
Pairs with the k8s-proxy MANIFEST-frame handler. e2e-validated: zip sent once +
4 manifest-only updates per cycle, dedup 66->17 and coverage 81/105 unchanged.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>

* test(dedup): add wire-format unit tests; extract frame-encoding helper

Addresses the review's "no automated tests for the new capture logic" item.
Adds DedupWireFormatTest (JUnit) exercising the REAL serialize path:
- COV payload via GSON — asserts the id + the historical `executedLinesByFile`
  key now carrying {vmClassName -> [probeIdx]}, plus the empty-coverage shape;
- CLASSES frame — "CLASSES <b64tag> <b64manifest> <b64zip>", 3 whitespace-split
  base64 fields, decoded exactly as k8s-proxy's handleClassesFrame does;
- MANIFEST frame — "MANIFEST <b64tag> <b64manifest>", 2 fields (no zip), as
  handleManifestFrame parses it;
- both frames are single-line (a base64 field must not embed a newline).

To test the serialize + frame contract without reaching into the private
collector, extracts two package-private static helpers on KeployDedupAgent —
toDedupJson and encodeBytecodeFrame — and routes pollBytecodeFrame through the
latter (byte-identical frames; no behavior change). Adds junit 4.13.2 (test scope).

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>

---------

Signed-off-by: praagyajain <[email protected]>
Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]>

v2.0.6

Toggle v2.0.6's commit message
Java SDK 2.0.6

v2.0.5

Toggle v2.0.5's commit message
Release Java SDK 2.0.5

v2.0.4

Toggle v2.0.4's commit message
Release Java SDK 2.0.4

v2.0.3

Toggle v2.0.3's commit message
Release Java SDK 2.0.3

v2.0.2

Toggle v2.0.2's commit message
Release Java SDK 2.0.2