Quality requires a measurable contract
A website can appear polished while critical journeys fail under concurrency or rare inputs. Define key user journeys before deciding which tests to write: landing page discovery, account sign-in, article publishing, checkout, order fulfillment and data recovery are different contracts. For each journey list preconditions, expected state transitions, accessibility requirements, security constraints and success evidence. The goal is not an impressive count of tests but confidence that the system preserves important properties in realistic conditions.
Apply complementary testing layers
Unit tests verify pure pricing formulas, permission predicates or normalization rules quickly. Integration tests exercise Django ORM behavior, database transactions, cache invalidation and remote-service adapters. Browser tests verify visible navigation, focus order, layout behavior and content delivery. Contract tests protect API responses against unintentional changes. Do not replace all unit tests with slow end-to-end scripts, nor assume unit coverage proves the wiring works. Maintain deterministic fixtures and explicit test isolation so a previous run cannot contaminate the next.
Test negative states and concurrency
Happy-path tests prove little about failure recovery. Simulate duplicate payment callbacks, expired credentials, a second user requesting another person's object, a database timeout, missing static assets and a browser retry after an ambiguous response. Use transaction-aware concurrency tests with the same database engine used in production, especially for unique constraints and row locking. Assert that illegal state transitions are rejected, not merely that an endpoint returns a non-500 response. For content publishing, verify both that the new article appears and that unrelated historic pages remain unchanged.
Define service level indicators and objectives
An SLI measures observed service behavior, such as the fraction of valid requests returning a successful response within a latency threshold. An SLO sets the target over a specified period. For example, a hypothetical availability SLO of 99.9 percent over thirty days permits approximately 43 minutes of unavailability; whether this is appropriate depends on business impact and measurement exclusions. Error budgets help teams decide when reliability work takes priority over features. State exactly which endpoints, users and failures the SLO includes.
Correlate logs, metrics and traces
Structured logs should contain timestamp, route template, request or trace identifier, severity and an error code. Metrics capture rates, duration distributions, saturation and queues. Distributed traces reveal which component consumed time across proxy, application, database and external dependencies. Avoid placing email addresses, session cookies, tokens or full request bodies into high-cardinality labels and logs. Aggregate by bounded dimensions such as route name and version. Observability tools create evidence only when their instrumentation is accurate and alerts have an owner.
Production probes must go beyond the homepage
A synthetic check can confirm the root page is reachable while every deep route returns HTTP 503. Monitor a small but representative set: home, article detail, login, admin where appropriate, staticfiles and application health. External probes detect DNS or TLS failures that an internal process check cannot see. Use readiness checks to determine whether traffic may be sent to an instance, and liveness checks to detect a stuck process; confusing the two can cause restart loops. Keep probes light enough not to overload a constrained server.
Incident response and learning loop
When errors rise, identify blast radius, stop unsafe releases, preserve evidence and restore critical service according to a known runbook. Separate the immediate mitigation from root-cause analysis. If the incident was caused by a bad deploy, compare artifacts and release logs; if saturation is responsible, examine concurrent process limits and queueing. After recovery, write a blameless timeline with technical causes, detection gaps and concrete prevention work. Track fixes to completion and retest rollback. References: https://sre.google/workbook/implementing-slos/ and https://docs.djangoproject.com/en/5.2/topics/testing/ .
Editorial disclosure: Original advanced educational content by Mojtaba Roozegar. Examples are illustrative, not an audit of a particular production deployment or a guarantee of outcomes. Relevant external technical references are linked within each article.
