Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions .github/workflows/java-agent.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,11 @@ jobs:
name: JDK ${{ matrix.java-version }}
runs-on: ubuntu-latest
# A hung step would otherwise hold its runner for GitHub's default of
# 6 hours. The steps below take about 2 minutes on 4 CPUs with an empty
# Maven cache, and the smoke stops its own Tomcat case after 180 s, so a
# run that reaches 10 minutes is stuck, not slow.
timeout-minutes: 10
# 6 hours. The full matrix (including forked Jetty 9.4/11/12.0/12.1 and
# Undertow 2.3 honesty suites plus the 180 s smoke test) runs ~7-10 minutes
# on 4 CPUs and up to ~12 minutes with additional forked suites, so 20
# minutes gives headroom without letting a truly stuck job linger.
timeout-minutes: 20
strategy:
fail-fast: false
matrix:
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Keploy Enterprise drives dynamic dedup per testcase.

Coverage is collected at per-testcase granularity, not process granularity.

A server sends a response before it is done with the request: a filter's code after the chain (a request log, an authentication filter's cleanup) runs after Enterprise has the response and has sent `END`. Since 2.2.0 the agent counts the requests of Tomcat (8.5 to 11), Jetty (9.4 to 12.1) and Undertow, Spring Boot's three servers, from where the server starts running a request to where its response is finished, and each async dispatch of it alike, and `END` first waits until every request that came in since the testcase's `START` is done, for at most `KEPLOY_JAVA_END_WAIT_MS` (200 ms by default, 2 s at most). A request that comes in once `END` has come (a readiness probe, a metrics scrape, or a call the testcase's own code makes after its response) is not waited for. Before, `END` read the probes at once, so under load that code was missed, and the next `START` cleared it as background: the same testcase had different coverage from run to run. A request that is done costs `END` nothing, and a request that came in before the `START` (a stream, a request of the testcase before) is never waited for. When the wait reaches its bound, the log says so at WARNING and the testcase's record ends with `"windowCut":true` (after `classMismatch`; left out otherwise): it holds what was read then, a Keploy that reads the flag does not judge that testcase (an older one judges the hits the record holds), and what the next `START` clears is not sent as background. Limits: work handed to unverified custom executors, untracked async primitives (`ScheduledExecutorService.schedule*`, `ExecutorService.invokeAny`, `Thread.start()`, `ForkJoinTask.fork()`, Reactor `subscribe()`, async method references), or an Undertow completion listener running on the IO thread after an async write is not waited for — instead the active window and following tail window are marked contaminated so dedup fails closed (see below); Netty/WebFlux, gRPC, Vert.x, Micronaut, and JDK `HttpServer` are not counted, nor is a server whose classes were loaded before the agent started (attached to a running JVM) or whose class loader does not see the agent's classes (a module system such as JBoss Modules); the log says once when a testcase's `END` does not wait, and why. To count them, the agent changes the one method of each server that runs a request (Tomcat's `CoyoteAdapter.service` and `asyncDispatch`, Jetty's `HttpChannel.handle` or, on Jetty 12, its servlet channel's `handle`, Undertow's `Connectors.executeRootHandler`) as the class loads: the server's own code moves to a private method `keploy$request$<name>` beside it, which shows in a stack trace and keeps the method's annotations; the method of the old name, which counts the request and calls it, carries none, so reflection that reads the annotations of `service` itself finds none. The agent makes its change after those of every agent that cannot retransform classes, JaCoCo's among them, whatever the order the agents are attached in: a JaCoCo agent attached before or after keploy-sdk.jar, or in `JAVA_TOOL_OPTIONS`, instruments the server's own class, so `classMismatch` never names it for that. When another agent retransforms or redefines the class later (an APM agent, a profiler, a hot-swap tool), the agent makes its change again, unless the new bytes already carry it (a copy taken from the class as the agent changed it).
A server sends a response before it is done with the request: a filter's code after the chain (a request log, an authentication filter's cleanup) runs after Enterprise has the response and has sent `END`. Since 2.2.0 the agent counts the requests of Tomcat (8.5 to 11), Jetty (9.4 to 12.1) and Undertow, Spring Boot's three servers, from where the server starts running a request to where its response is finished, and each async dispatch of it alike, and `END` first waits until every request that came in since the testcase's `START` is done, for at most `KEPLOY_JAVA_END_WAIT_MS` (200 ms by default, 2 s at most). A request that comes in once `END` has come (a readiness probe, a metrics scrape, or a call the testcase's own code makes after its response) is not waited for. Before, `END` read the probes at once, so under load that code was missed, and the next `START` cleared it as background: the same testcase had different coverage from run to run. A request that is done costs `END` nothing, and a request that came in before the `START` (a stream, a request of the testcase before) is never waited for. When the wait reaches its bound, the log says so at WARNING and the testcase's record ends with `"windowCut":true` (after `classMismatch`; left out otherwise): it holds what was read then, a Keploy that reads the flag does not judge that testcase (an older one judges the hits the record holds), and what the next `START` clears is not sent as background. Limits: work handed to unverified custom executors, untracked async primitives (`ScheduledExecutorService.schedule*`, `ExecutorService.invokeAny`, `Thread.start()`, `ForkJoinTask.fork()`, Reactor `subscribe()`, async method references), or an Undertow completion listener running on the IO thread after an async write is not waited for — instead the active window and following tail window are marked contaminated so dedup fails closed (see below); on older Jetty 9.4.0–9.4.18 (`QueuedThreadPool$2#run`, before `QueuedThreadPool$Runner` in 9.4.19+), pool hand-offs resolve to an unlisted caller and latch `asyncExecutors=false` (fail-closed); Netty/WebFlux, gRPC, Vert.x, Micronaut, and JDK `HttpServer` are not counted, nor is a server whose classes were loaded before the agent started (attached to a running JVM) or whose class loader does not see the agent's classes (a module system such as JBoss Modules); the log says once when a testcase's `END` does not wait, and why. To count them, the agent changes the one method of each server that runs a request (Tomcat's `CoyoteAdapter.service` and `asyncDispatch`, Jetty's `HttpChannel.handle` or, on Jetty 12, its servlet channel's `handle`, Undertow's `Connectors.executeRootHandler`) as the class loads: the server's own code moves to a private method `keploy$request$<name>` beside it, which shows in a stack trace and keeps the method's annotations; the method of the old name, which counts the request and calls it, carries none, so reflection that reads the annotations of `service` itself finds none. The agent makes its change after those of every agent that cannot retransform classes, JaCoCo's among them, whatever the order the agents are attached in: a JaCoCo agent attached before or after keploy-sdk.jar, or in `JAVA_TOOL_OPTIONS`, instruments the server's own class, so `classMismatch` never names it for that. When another agent retransforms or redefines the class later (an APM agent, a profiler, a hot-swap tool), the agent makes its change again, unless the new bytes already carry it (a copy taken from the class as the agent changed it).

The work a request hands to a Spring executor (Spring 5.3 to 6.2) or to verified standard JDK executors and `CompletableFuture` / `CompletionStage` stages from application code counts as the request's too: an event listener on an async event multicaster (a `SimpleAsyncTaskExecutor`), a task given to a `ThreadPoolTaskExecutor`, `ThreadPoolTaskScheduler`, or `ConcurrentTaskExecutor` (`execute`, `submit`, `submitListenable`, and `submitCompletable`), an `@Async` method, and rewritten application call sites of `Executor`/`ExecutorService`/`ThreadPoolExecutor`/`ScheduledThreadPoolExecutor`/`ForkJoinPool` (`execute`, `submit`, `remove`, `shutdownNow`) and `CompletableFuture` / `CompletionStage` (`runAsync`, `supplyAsync`, `completeAsync`, `*Async` instance methods, and plain dependent stages registered on incomplete futures such as external library `HttpClient.sendAsync().thenAccept(...)`). `END` waits for that work under the same bound, from the hand-off until the task (and any synchronous `CompletableFuture` dependent stage registered before completion) returns or throws, and a testcase whose work still runs at the bound says `windowCut`. Whenever a testcase is cut at `END`, a new `START` arrives without a preceding `END`, or a window records an untracked async hand-off, subsequent windows are marked contaminated (`"tail:<prevTestId>"`) until prior lingering work drains (or the untracked tail window elapses). Only work handed off on a thread that runs a counted request, or on one that runs such work, counts: what a scheduler or the application's own threads hand off is not waited for (what a Quartz job, an `@Scheduled` method, or a message listener hands off counts as that job's run instead; see the next paragraph). A task the executor rejects by throwing or whose `Future` is cancelled, removed, or drained via `shutdownNow()` before starting releases its permit promptly.

Expand Down
88 changes: 88 additions & 0 deletions keploy-sdk/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,94 @@
</artifactItems>
</configuration>
</execution>
<execution>
<id>copy-jetty11</id>
<phase>generate-test-resources</phase>
<goals>
<goal>copy</goal>
</goals>
<configuration>
<skip>${skipTests}</skip>
<outputDirectory>${project.build.directory}/jetty11</outputDirectory>
<artifactItems>
<artifactItem><groupId>org.eclipse.jetty</groupId><artifactId>jetty-servlet</artifactId><version>11.0.24</version></artifactItem>
<artifactItem><groupId>org.eclipse.jetty</groupId><artifactId>jetty-security</artifactId><version>11.0.24</version></artifactItem>
<artifactItem><groupId>org.eclipse.jetty</groupId><artifactId>jetty-server</artifactId><version>11.0.24</version></artifactItem>
<artifactItem><groupId>org.eclipse.jetty</groupId><artifactId>jetty-http</artifactId><version>11.0.24</version></artifactItem>
<artifactItem><groupId>org.eclipse.jetty</groupId><artifactId>jetty-io</artifactId><version>11.0.24</version></artifactItem>
<artifactItem><groupId>org.eclipse.jetty</groupId><artifactId>jetty-util</artifactId><version>11.0.24</version></artifactItem>
<artifactItem><groupId>org.eclipse.jetty.toolchain</groupId><artifactId>jetty-jakarta-servlet-api</artifactId><version>5.0.2</version></artifactItem>
<artifactItem><groupId>org.slf4j</groupId><artifactId>slf4j-api</artifactId><version>2.0.9</version></artifactItem>
</artifactItems>
</configuration>
</execution>
<execution>
<id>copy-jetty12</id>
<phase>generate-test-resources</phase>
<goals>
<goal>copy</goal>
</goals>
<configuration>
<skip>${skipTests}</skip>
<outputDirectory>${project.build.directory}/jetty12</outputDirectory>
<artifactItems>
<artifactItem><groupId>org.eclipse.jetty.ee10</groupId><artifactId>jetty-ee10-servlet</artifactId><version>12.0.16</version></artifactItem>
<artifactItem><groupId>org.eclipse.jetty</groupId><artifactId>jetty-security</artifactId><version>12.0.16</version></artifactItem>
<artifactItem><groupId>org.eclipse.jetty</groupId><artifactId>jetty-session</artifactId><version>12.0.16</version></artifactItem>
<artifactItem><groupId>org.eclipse.jetty</groupId><artifactId>jetty-server</artifactId><version>12.0.16</version></artifactItem>
<artifactItem><groupId>org.eclipse.jetty</groupId><artifactId>jetty-http</artifactId><version>12.0.16</version></artifactItem>
<artifactItem><groupId>org.eclipse.jetty</groupId><artifactId>jetty-io</artifactId><version>12.0.16</version></artifactItem>
<artifactItem><groupId>org.eclipse.jetty</groupId><artifactId>jetty-util</artifactId><version>12.0.16</version></artifactItem>
<artifactItem><groupId>jakarta.servlet</groupId><artifactId>jakarta.servlet-api</artifactId><version>6.0.0</version></artifactItem>
<artifactItem><groupId>org.slf4j</groupId><artifactId>slf4j-api</artifactId><version>2.0.16</version></artifactItem>
</artifactItems>
</configuration>
</execution>
<execution>
<id>copy-jetty121</id>
<phase>generate-test-resources</phase>
<goals>
<goal>copy</goal>
</goals>
<configuration>
<skip>${skipTests}</skip>
<outputDirectory>${project.build.directory}/jetty121</outputDirectory>
<artifactItems>
<artifactItem><groupId>org.eclipse.jetty.ee11</groupId><artifactId>jetty-ee11-servlet</artifactId><version>12.1.15</version></artifactItem>
<artifactItem><groupId>org.eclipse.jetty</groupId><artifactId>jetty-security</artifactId><version>12.1.15</version></artifactItem>
<artifactItem><groupId>org.eclipse.jetty</groupId><artifactId>jetty-session</artifactId><version>12.1.15</version></artifactItem>
<artifactItem><groupId>org.eclipse.jetty</groupId><artifactId>jetty-server</artifactId><version>12.1.15</version></artifactItem>
<artifactItem><groupId>org.eclipse.jetty</groupId><artifactId>jetty-http</artifactId><version>12.1.15</version></artifactItem>
<artifactItem><groupId>org.eclipse.jetty</groupId><artifactId>jetty-io</artifactId><version>12.1.15</version></artifactItem>
<artifactItem><groupId>org.eclipse.jetty</groupId><artifactId>jetty-util</artifactId><version>12.1.15</version></artifactItem>
<artifactItem><groupId>jakarta.servlet</groupId><artifactId>jakarta.servlet-api</artifactId><version>6.1.0</version></artifactItem>
<artifactItem><groupId>org.slf4j</groupId><artifactId>slf4j-api</artifactId><version>2.0.16</version></artifactItem>
</artifactItems>
</configuration>
</execution>
<execution>
<id>copy-undertow23</id>
<phase>generate-test-resources</phase>
<goals>
<goal>copy</goal>
</goals>
<configuration>
<skip>${skipTests}</skip>
<outputDirectory>${project.build.directory}/undertow23</outputDirectory>
<artifactItems>
<artifactItem><groupId>io.undertow</groupId><artifactId>undertow-servlet</artifactId><version>2.3.18.Final</version></artifactItem>
<artifactItem><groupId>io.undertow</groupId><artifactId>undertow-core</artifactId><version>2.3.18.Final</version></artifactItem>
<artifactItem><groupId>org.jboss.xnio</groupId><artifactId>xnio-api</artifactId><version>3.8.16.Final</version></artifactItem>
<artifactItem><groupId>org.jboss.xnio</groupId><artifactId>xnio-nio</artifactId><version>3.8.16.Final</version></artifactItem>
<artifactItem><groupId>org.jboss.threads</groupId><artifactId>jboss-threads</artifactId><version>3.5.0.Final</version></artifactItem>
<artifactItem><groupId>org.jboss.logging</groupId><artifactId>jboss-logging</artifactId><version>3.4.3.Final</version></artifactItem>
<artifactItem><groupId>org.wildfly.common</groupId><artifactId>wildfly-common</artifactId><version>1.5.4.Final</version></artifactItem>
<artifactItem><groupId>org.wildfly.client</groupId><artifactId>wildfly-client-config</artifactId><version>1.0.1.Final</version></artifactItem>
<artifactItem><groupId>jakarta.servlet</groupId><artifactId>jakarta.servlet-api</artifactId><version>6.0.0</version></artifactItem>
<artifactItem><groupId>jakarta.annotation</groupId><artifactId>jakarta.annotation-api</artifactId><version>2.1.1</version></artifactItem>
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
Expand Down
Loading
Loading