Cloudflare Flamingo Adds DNS Testing Across Every Data Center
Cloudflare has extended Flamingo, its internal end-to-end testing framework, so it can run DNS tests directly in production from every data center. The trigger was a painful experience: a release of the service that publishes DNS records to the edge shipped with a bug, even though every unit test passed and the dashboards were green.
The bug that slipped past unit tests
During that rollout, a scheduling bug left some record changes unpublished for hours. The service stayed up and healthy. But new hostnames were slow to resolve, and certificates couldn't be issued until the bug was fixed.
According to Cloudflare's DNS team, DNS failures are hard to catch because they are slow, spread across the network, and only partially impactful. That is why they needed to test DNS the way customers experience it: constantly, from every data center, and against production.
Getting to know Flamingo
Flamingo was originally built for complex multi-step HTTP testing. Today it runs hundreds of millions of tests a day against Cloudflare's edge. It has a control plane and scheduler that let teams target specific environments, specific data centers, or a percentage of bare-metal servers. It also plugs into internal reporting, metrics, and analytics tooling, and it is written in Rust for consistent performance on resource-constrained servers.
Tests in Flamingo aren't written in a general-purpose programming language. They use a domain-specific language (DSL) with a setup-request-response format. The reason is that when a test fails, developers shouldn't have to debug both the system under test and the test itself. For example, a test that checks whether unencrypted traffic is redirected to its encrypted counterpart takes only five lines:
- Name the test test-redirect
- Set the hostname variable to www.cloudflare.com
- Send a GET to the http version of that hostname
- Assert that the response status is 301
- Assert that the Location header points to the https version
A script that short can run anywhere on Cloudflare's edge and scale to thousands of requests per minute. The millions of data points from tests like this are then turned into graphs showing how the service performs in the real world.
DNS support through a modular design
The key is the middle step. In the DSL format above, the middle step doesn't have to be an HTTP request. It can be any action whose outcome you want to measure. Cloudflare calls each kind of action a module and has worked hard to make modules as easy as possible to write.
Rust's strong type system helps here. In Flamingo's action runner, the Action type now has a DnsQuery variant alongside the Query variant for HTTP. DnsQuery carries a query_name and a query_type, while results are wrapped in an ActionOutput that can hold either an HTTP or a DNS response. The logic for each action is split into a dynamically dispatched function that can be called independently of other actions.
Cloudflare says its original post also covers how it measures DNS propagation and how those measurements decide whether a release goes ahead or gets rolled back. That part wasn't included in the excerpt we received. For anyone running a distributed service, the core idea still holds: internal health checks aren't enough, so test from the customer's point of view too.
Source: blog.cloudflare.com