AREX: Java Instrumentation‑Based Automated Regression Testing Platform for Backend Services

The article introduces AREX, a Java instrumentation framework that captures real production traffic to create high‑coverage, low‑cost automated regression tests for complex backend systems, detailing its architecture, trace propagation techniques, and open‑source implementation.

Ctrip Technology
Ctrip Technology
Ctrip Technology
AREX: Java Instrumentation‑Based Automated Regression Testing Platform for Backend Services

In complex online business systems, ensuring the correctness of modified code is challenging due to frequent iterations, high manual testing costs, and difficulty reproducing production issues; traditional automated testing often falls short in coverage and efficiency.

AREX addresses these problems by copying real production traffic into a test environment, using Java instrumentation to collect request/response data and automatically mock external interactions such as database writes, message queues, and Redis, thereby enabling high‑coverage regression testing without generating dirty data.

The core technical principle relies on the java.lang.Instrument package introduced in JDK 1.5, which allows runtime bytecode modification. AREX builds on this foundation using the ByteBuddy library to weave instrumentation code into target classes.

Key implementation details include:

Trace propagation across threads by wrapping Runnable and Callable objects with a RunnableWrapper that carries a TraceTransmitter context.

Instrumentation of ForkJoinPool tasks via a weak‑cache mechanism to preserve trace continuity without altering the original class structure.

Support for various asynchronous frameworks (Reactor, RxJava, Apache Async HTTP client, Lettuce) by instrumenting their callback mechanisms to maintain trace integrity.

Version management that detects component versions (e.g., Jedis) before class loading to apply the correct bytecode injection.

Time mocking that records timestamps during data collection and replays them by intercepting System.currentTimeMillis and System.nanoTime calls.

Local cache capture and mock for in‑memory data, ensuring consistent test results across environments.

Class‑loader isolation to keep the AREX agent separate from application code while still allowing necessary interactions.

AREX offers several advantages: low integration cost (no code intrusion), high test case stability, support for write verification, rapid local debugging of production issues, and intelligent resource management that throttles data collection under heavy load.

The project originated within Ctrip’s ticketing system, has been open‑sourced, and is now used across multiple business units for automated regression testing, inviting community contributions.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

JavaInstrumentationAutomated TestingTrace PropagationAREX
Ctrip Technology
Written by

Ctrip Technology

Official Ctrip Technology account, sharing and discussing growth.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.