This article details Cloudflare's end-to-end testing framework, Flamingo, and its modular architecture designed for validating highly distributed systems like DNS. It highlights how Flamingo allows teams to extend its capabilities for various protocols, enabling proactive detection of issues and automated release decisions based on service-level objectives (SLOs). The discussion emphasizes the importance of a robust testing framework for maintaining reliability and performance in a complex, globally distributed infrastructure.
Read original on Cloudflare BlogTesting in a large-scale, widely distributed system like Cloudflare's edge presents significant challenges. Traditional unit testing is insufficient due to the complex pathways and multiple systems involved in a single network request. Issues can be slow to manifest, spread across the network, and cause partial impact, making them hard to catch without comprehensive end-to-end validation. Cloudflare developed Flamingo to address these complexities, enabling constant, automated testing against real production environments.
Flamingo is designed with a modular architecture that allows teams to extend its capabilities beyond its original HTTP testing focus. This modularity is crucial for testing diverse networking protocols and services across Cloudflare's infrastructure. The framework, written in Rust, leverages its strong type system to facilitate the creation of action modules, where each module encapsulates the logic for performing a specific type of action (e.g., HTTP requests, DNS queries).
pub enum Action {
Query {
method: String,
url: Expression,
parameters: Vec<http::QueryParameters>,
},
DnsQuery {
query_name: Expression,
query_type: Expression,
parameters: Vec<dns::DnsQueryParameters>,
},
}
pub enum ActionOutput {
Http(http::FetchResponse),
Dns(dns::QueryResponse),
}This design decouples the action logic from higher-level concerns like test scheduling and resource management. Module authors only need to focus on the core logic of their action, simplifying development and ensuring consistency.
Simplified Test Authoring
Flamingo utilizes a custom Domain-Specific Language (DSL) that simplifies test authoring to a `setup-request-response` format. This abstraction reduces the debugging complexity for users, as they are less likely to debug the test script itself, focusing instead on the system under test.
TEST test-redirect
SET $hostname www.cloudflare.com
GET "http://$(hostname)/"
ASSERT STATUS IS 301
ASSERT HEADER Location IS "https://$(hostname)/"Cloudflare extended Flamingo to probe DNS propagation, a critical and often problematic component of internet infrastructure. By adding a DNS query module, they can measure how quickly record changes propagate across authoritative nameservers and public resolvers from every data center. This capability is integrated with Service Level Objectives (SLOs) and Service Level Indicators (SLIs) to make informed decisions during deployments. If synthetic traffic from Flamingo encounters issues that breach predefined error budgets, releases can be automatically halted or rolled back, preventing widespread customer impact.