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.

JD Retail Technology
JD Retail Technology
JD Retail Technology
Moonlight Box: A Traffic Recording and Replay Platform for Automated Regression Testing

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

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.

Microservicestest automationtraffic recordingregression testingreplay testing
JD Retail Technology
Written by

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.

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.