Moonlight Box: Enabling Fully Automated High‑Coverage Regression Testing with Traffic Recording and Replay
This article introduces the Moonlight Box traffic‑recording and replay platform, explains its core functions and design principles, and presents multiple practical regression‑testing scenarios—including simple forward and reverse read replay, bidirectional replay, write replay, and compatibility adaptation—for both read‑only and write‑heavy interfaces.
The article provides an in‑depth overview of the Moonlight Box traffic‑recording and replay platform, focusing on its core capabilities and design rationale for automated regression testing.
Simple forward read replay
Records traffic at service entry points in production (old version) and replays it in real‑time to a pre‑release environment (new version). Features include recording only entry methods, low deployment cost, and immediate replay without reuse. Suitable for read‑only APIs, routine iteration testing, and PaaS migration where external interfaces remain unchanged.
Simple reverse read replay
Records traffic from a gray (staging) environment and replays it to production. Two approaches are described: external load‑balancer traffic splitting and application‑level proxy splitting, both enabling real‑time validation during gray‑release phases. Features mirror the forward scenario, with emphasis on detecting incompatibilities between new and old versions.
Bidirectional (forward‑and‑reverse) read replay
Combines forward and reverse replay: production traffic is replayed to pre‑release while gray traffic is replayed to production, allowing simultaneous comparison of old and new versions. The platform automatically filters replay traffic to avoid recording loops.
Simple write replay
Records both entry and sub‑methods, allowing sub‑method calls to be mocked during replay, thereby eliminating external dependencies and non‑idempotent functions. Typically targets isolated test environments to prevent contaminating production data, though it incurs higher storage and setup costs.
Read‑write combined replay
Extends simple write replay by also replaying read requests, requiring a real database for persistent methods while still mocking other sub‑methods. This approach is widely used in componentized gray‑release scenarios.
New‑old interface compatibility adaptation
Addresses incompatibilities during system refactoring by adapting recorded old‑interface traffic to the new‑interface format before replay. Two solutions are presented: inserting an adaptation layer on the old service side, or deploying a separate old‑version production group that routes traffic to the new version with an adapter.
The article concludes by summarizing the practical cases, emphasizing the flexibility and extensibility of Moonlight Box, and hints at upcoming topics such as MQ/Worker recording and load‑testing scenarios.
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.