Sub topic 17
Validating and Testing Requirements
This chapter assumes you can tell functional from non-functional requirements, and that you know what an SLI, an SLO and a percentile are. It shows how to check a requirements set before design starts, then applies the checks to a URL shortener.
Validating requirements
Validation asks whether the requirements are good enough to design from. Review each requirement against four questions:
| Check | Question | Failing example |
|---|---|---|
| Clear | Can two engineers read it and build the same thing? | "Redirects should be fast." |
| Testable | Can a test or measurement show pass or fail? | "The system should be scalable." |
| Consistent | Does it avoid contradicting another requirement? | Strong consistency across regions plus a 5 ms write latency. |
| Traceable | Does it map to a stakeholder need? | A feature nobody asked for. |
A testable non-functional requirement names a quality, a number, a percentile or ratio, a measurement point and a time window. "99% of redirects complete in under 100 ms, measured at the service edge over 30 days" has all five. "Redirects are fast" has none.
You can automate part of this review. The script below flags non-functional requirements that contain no number. It is only a first filter, because a requirement can contain a number and still be vague.
import re
requirements = [
{"id": "NFR-1", "text": "99% of redirects complete in under 100 ms over 30 days."},
{"id": "NFR-2", "text": "The service should be highly available."},
]
for req in requirements:
if not re.search(r"\d", req["text"]):
print(f"{req['id']}: no measurable target")It prints NFR-2: no measurable target.
Worked example: a URL shortener
Here is the requirements document for a URL shortener. It keeps functional requirements, measurable non-functional requirements and out-of-scope items in separate lists.
service: url-shortener
functional:
- id: FR-1
text: A user can submit a long URL and receive a short URL.
- id: FR-2
text: Requesting a short URL redirects to the original long URL.
- id: FR-3
text: A user can delete a short URL they created.
non_functional:
- id: NFR-1
quality: latency
text: 99% of redirects complete in under 100 ms, measured at the service edge over 30 days.
- id: NFR-2
quality: availability
text: Redirects succeed for 99.9% of requests over a 30-day window.
- id: NFR-3
quality: durability
text: A created short URL is never lost once creation has been acknowledged.
out_of_scope:
- Click analytics
- Custom domainsApply the checks:
- Clear and testable: NFR-1 and NFR-2 give numbers and windows. NFR-2 allows about 43.2 minutes of downtime in 30 days, which is the budget you can alert on. NFR-3 has no number, but "never lost after acknowledgment" is still testable. Acknowledge a write, crash a node, and confirm the URL survives.
- Consistent: Fast redirects and durable creation do not conflict. Durability affects the write path, and latency targets the read path.
- Traceable: Each requirement maps to a user need: create, follow, remove.
- Scoped: Analytics and custom domains are listed as out of scope, so nobody designs for them by accident.
The set is not finished. Creation has no latency target, and no requirement says how long a deleted URL must stop redirecting. Validation found two gaps to raise with stakeholders before design starts.
Exercise
A draft says "The system must handle high traffic and respond quickly." Name two validation checks it fails and rewrite it so it passes.
Show answer
It fails the clear and testable checks, because "high traffic" and "quickly" have no numbers. A passing rewrite: "The system sustains 7,000 requests per second at peak, and 99% of requests complete in under 100 ms, measured at the service edge over 30 days."