| 1 | # Testing |
| 2 | |
| 3 | celld makes three important promises: |
| 4 | |
| 5 | - An acknowledged write is durable. |
| 6 | - A cell has one writer at a time. It never has two. |
| 7 | - Code written for Cloudflare Workers and Durable Objects operates the |
| 8 | same on celld. |
| 9 | |
| 10 | We try to break each promise at the layer where a failure shows most |
| 11 | clearly. We test the API contract with differential execution against the |
| 12 | Cloudflare runtime. We test the coordination protocol with deterministic |
| 13 | simulation. We test the full system with fault injection on live fleets. |
| 14 | |
| 15 | ## Conformance: two runtimes, one output |
| 16 | |
| 17 | We test the compatibility promise differentially. We run each Workers and |
| 18 | Durable Objects program twice: once on workerd, the runtime binary that |
| 19 | Cloudflare operates in production, and once on celld, on identical bytes. |
| 20 | The two outputs must be equal. This shows two facts at once: the program |
| 21 | is real Cloudflare code, because workerd accepts it, and celld obeys the |
| 22 | contract, because the outputs are equal. A test cannot agree with our own |
| 23 | runtime by accident. |
| 24 | |
| 25 | The corpus only grows. When celld gets a new API surface, we add fixtures |
| 26 | for that surface, and the fixtures must give equal output on the two |
| 27 | engines. We also port test suites from workerd itself: the Durable |
| 28 | Objects contract, the web-platform globals, and the upstream Web Platform |
| 29 | Tests. Before a release, we also replay scenarios through the full |
| 30 | `celld` binary in each deployment mode: storage, SQL, alarms, streams, |
| 31 | WebSockets, and lifecycle. |
| 32 | |
| 33 | ## Simulation: the protocol under adversarial schedules |
| 34 | |
| 35 | The dangerous bugs live in the coordination: a crash during an ownership |
| 36 | handoff, a lease renewal that races a takeover, an alarm that fires |
| 37 | against a partially restored cell. These windows are nanoseconds wide and |
| 38 | open rarely, so a test cannot wait for them. |
| 39 | |
| 40 | Thus the coordination protocol is a |
| 41 | [pure decision core](https://github.com/denoland/celld/tree/main/crates/logic) |
| 42 | with no I/O of its own: the clock, the randomness, and the object store |
| 43 | are interfaces, and a simulator drives the core. The simulated store |
| 44 | injects latency, compare-and-swap races, and lost responses; the clocks |
| 45 | drift apart; a node can crash at each await point. Scripted adversaries |
| 46 | play the cells: a handler that never returns, a write stream that stops |
| 47 | halfway. V8 stays out of the simulation, because V8 is not deterministic. |
| 48 | |
| 49 | A seeded scheduler drives each run, so a failure is not a fluke: the seed |
| 50 | replays it exactly, every time, and we keep the seed until the bug is |
| 51 | dead. We examine each property for safety (two writers in one epoch, a |
| 52 | lost acknowledged write, an expired lease that comes back) and for |
| 53 | liveness (each armed alarm fires, and ownership settles on one node after |
| 54 | a crash). A property must survive tens of thousands of seeds, and the |
| 55 | core protocols have run through millions of different schedules. |
| 56 | |
| 57 | Simulation has a known failure mode: the checker that cannot fail. Thus |
| 58 | we also test the checkers: we run deliberately broken variants of the |
| 59 | protocol against the properties, and the properties must find the damage. |
| 60 | A suite that stays green against a broken protocol is a broken suite. |
| 61 | |
| 62 | ## Live fleets: what simulation cannot see |
| 63 | |
| 64 | Simulation cannot see the real S3 tail latency, the real kernel and |
| 65 | filesystem behavior, or V8 under memory pressure. The third layer is |
| 66 | therefore a permanent fleet lab: standard VMs from standard providers, |
| 67 | and a real bucket. The workloads rotate: chat rooms under many WebSocket |
| 68 | connections, working sets that shift across tens of thousands of cells |
| 69 | (each cell has a unique checksum), deployment cutovers under load, and |
| 70 | runs that fill the nodes to the memory limit. The lab qualifies each |
| 71 | release, and between releases it pushes the density and the fault |
| 72 | coverage further. Each run makes an archived evidence bundle: the |
| 73 | configuration, the verification sweeps, the node journals, the kernel |
| 74 | logs, and the phase timings. We keep a red run with the same care as a |
| 75 | green run, because a failure that the harness caught is a result, not a |
| 76 | retry. |
| 77 | |
| 78 | We inject the faults between verification passes. A pass fetches each |
| 79 | cell through different nodes and compares the durable state exactly: the |
| 80 | status, the body, and the full message ledger. Each run therefore has a |
| 81 | clean picture before the fault and after it. A cell can be unavailable |
| 82 | for a short time while its ownership moves, but its committed state must |
| 83 | stay complete, and a live node must serve that state again. |
| 84 | |
| 85 | The scenarios attack every seam that we know. We stop a node with |
| 86 | `SIGKILL` in the middle of a write stream and delete its local database, |
| 87 | so the recovery can only come from the bucket: every acknowledged write |
| 88 | comes back, because the output gate held each response until the write |
| 89 | was durable. We freeze an owner node, write to its cells through other |
| 90 | nodes, and unfreeze it: the node sees that its lease moved and refuses to |
| 91 | serve the old state, and each write from the other nodes lands exactly |
| 92 | one time. One epoch has at most one writer. We cut a node off from the |
| 93 | bucket, and it fences itself, because a node that cannot replicate must |
| 94 | not own cells. We throttle the bucket, so it answers each request with a |
| 95 | 429: the engine slows to the write rate of the store and does not amplify |
| 96 | the throttle, because a node that knows its replicated position does not |
| 97 | ask a slow store for extra listings. We stop a full host at the provider |
| 98 | level in the middle of a workload: its cells move to the other nodes, and |
| 99 | when the host returns, it joins again with no duplicate residency. Across |
| 100 | every run of every scenario, no acknowledged write was lost and no |
| 101 | committed state was damaged; the verification sweeps show zero body |
| 102 | faults, zero status faults, and zero lost messages. |
| 103 | |
| 104 | ## A few numbers we trust |
| 105 | |
| 106 | Each number includes the condition of its measurement. A number without |
| 107 | its conditions has no value. |
| 108 | |
| 109 | - **The epoch fence holds under contention.** Five hundred claimants |
| 110 | tried at the same time to own the same cells: 5,500 attempts, one |
| 111 | writer for each epoch, zero violations. |
| 112 | - **A warm resident request is local.** A request to a resident cell does |
| 113 | zero bucket operations and returns in p50 ~1.1 ms and p99 ~7 ms (a |
| 114 | fixed-host measurement). Only a cold activation touches object storage. |
| 115 | - **A durable write costs one bucket round trip.** The response waits |
| 116 | until the write is in the bucket; that is the meaning of RPO=0, and the |
| 117 | storage round trip is therefore the minimum latency for one write. |
| 118 | Concurrent writes to one cell join one shared upload, so the throughput |
| 119 | of one cell is not one round trip for each write. |
| 120 | - **A restore is normal work.** Placement handles the restore of an |
| 121 | inactive cell as ordinary work, and not as an emergency procedure. The |
| 122 | measured restore times come from the retired external replicator, so this |
| 123 | page gives no number until a fleet run measures `celld-ltx`. |
| 124 | - **Ten small nodes held real scale.** A fleet of ten nodes, each with 4 |
| 125 | vCPU and 8 GB, held 10,000 resident cells and 20,000 concurrent |
| 126 | WebSocket connections. We stopped two of the ten nodes, and the data of |
| 127 | every cell was available again on another node in ~11 s at the tail |
| 128 | (with reserve headroom). |
| 129 | |
| 130 | ## The failure edges we intend to find |
| 131 | |
| 132 | We must also know where a policy stops, so we record the edges instead of |
| 133 | tuning them away. The clearest edge is the reserve headroom: a fleet that |
| 134 | is full to its resident limit has no space for the cells of a lost node, |
| 135 | so a failure of more than one node at the limit degrades the service, |
| 136 | and a fleet with headroom does not. We measure both sides of that line, |
| 137 | the good restoration with reserve and the red case without, because this |
| 138 | measurement is part of the work. |
| 139 | |
| 140 | If you find an edge that we did not find, tell us: a schedule that breaks |
| 141 | a promise, a fault that we did not inject, a number that you cannot |
| 142 | reproduce. That is exactly the bug report that we want: |
| 143 | [github.com/denoland/celld/issues](https://github.com/denoland/celld/issues). |