Moonlight Box: A Traffic Recording and Replay Platform for Automated Regression Testing
The Moonlight Box (JCASE) platform records production traffic and replays it in test environments to achieve fully automated, high‑coverage regression testing, reducing test data preparation effort and supporting online, offline, stress, and pre‑heat scenarios across large‑scale service architectures.
R&D teams face increasing complexity in business scenarios, rapid requirement iterations, and frequent technical refactoring, leading to massive regression testing workloads that are hard to manage with manual test case creation and data preparation.
Recording production traffic and replaying it in test environments offers a solution for fully automated, high‑coverage regression testing.
Existing tools are often tightly coupled to specific business logic, lack extensibility, or are built on non‑Java stacks, making them unsuitable for our needs.
Therefore, we developed a new traffic recording and replay platform called Moonlight Box (JCASE), inspired by the movie "A Chinese Odyssey" and meaning "time reversal".
The core idea is to capture real production traffic, replay it in a test environment, and compare results to detect logic errors, providing reliable test cases and data without manual effort.
Moonlight Box consists of three core modules forming a triangular architecture: Record‑Agent, Replay‑Service, and Replay‑Agent. The Record‑Agent captures method calls, parameters, results, and context in production, supporting both read‑only and write scenarios with optional deep recording of sub‑calls.
The Replay‑Service, deployed independently, handles replay calls, compares results at field level, filters noise (e.g., timestamps, IPs), and stores comparison outcomes for analysis.
The Replay‑Agent runs in the test environment, providing mock data for dependent services (e.g., RPC, Redis, databases) based on recorded sub‑calls, and can be omitted for pure read‑only interfaces.
In addition to online replay, Moonlight Box supports offline replay where recorded traffic is persisted (via MQ, HBase/ES/MySQL) and later replayed, enabling repeated use, coverage analysis, and safe handling of write‑heavy scenarios.
Key components for offline replay include MQ for buffering, databases for storage, Record‑Dumper, Record‑Pumper, and Record‑Service for data handling and query.
Overall, Moonlight Box is a highly modular, extensible platform that reduces testing cost, improves coverage, and integrates with JD's monitoring and configuration systems, becoming a standard part of regression testing workflows across multiple business lines.
For more details, case studies, and technical discussions, contact [email protected].
Figure 1: Basic workflow of Moonlight Box
Figure 2: Online replay architecture
Figure 3: Offline replay architecture
JD Retail Technology
Official platform of JD Retail Technology, delivering insightful R&D news and a deep look into the lives and work of technologists.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.