From the GoReplay team

GoReplay reproduces production bugs. Proof catches them before production.

See Proof
Published on 12/6/2026

Testing Data Integrity: Checks, Steps and Common Failures

Testing Data Integrity: Checks, Steps and Common Failures

Your regression suite is green. Checkout returns 200, the confirmation page shows the right total, and the smoke test passed on the last three builds. Then finance opens the Monday dashboard and revenue is one order short of what the payment processor settled, and nobody can name the missing row.

That gap between the response your application sends and the row your database stores is where integrity failures live. They survive response checks precisely because the response was correct at the moment it was written. The damage shows up later, in the duplicated order, the orphaned line item, the balance that drifted by a few cents and then by a few thousand.

Testing data integrity means asking a different question than functional testing does. Not “did the request succeed” but “is the stored state still true”. The rest of this guide is about how to answer that question with evidence rather than hope.

What Data Integrity Testing Checks and Why Teams Run It

Data integrity testing proves that stored data stays accurate, consistent, complete and valid as it is written, read, migrated, replayed and reported on. Everything in that definition points at the database, the file, or the warehouse table, not at the HTTP response.

The work usually lands on one person with a query window open and a spreadsheet of expected counts next to it.

A professional woman working at a desk, reviewing a document while using a laptop for data tasks.

A bank ledger makes the distinction concrete. The ledger can be perfectly formatted, sum correctly down the page, and still record a transfer twice or post it to the wrong account. Formatting is presentation. Integrity is whether the numbers describe what happened.

A system that returns the right page but stores the wrong number has failed the test.

Failures usually start in four places, and none of them look like bugs in the UI:

  • Retried requests that write twice. A client times out, retries, and the server processes both attempts because nothing enforced idempotency.
  • Partial writes that leave orphaned rows. The order row commits, the process dies, and the inventory or payment row never arrives.
  • Timezone conversions during migration. A timestamp stored as local time lands in a UTC column and shifts by hours.
  • Field mappings that move during a schema change. A column that held cents is repointed at a column that holds dollars.

Teams run these tests for different reasons. QA engineers run them before a release to catch regressions in write paths. DevOps teams run them before an infrastructure move, when the database engine or its configuration changes underneath working code. Data teams run them before a report gets trusted with a decision. In 2024, 57% of data professionals identified poor data quality as their top challenge, according to the dbt Labs survey summarized by Docsumo, which is a fair signal of how often the stored state turns out to be wrong.

The idea is not new. In August 1981 the U.S. National Bureau of Standards, now NIST, published the FIPS 88 guideline on integrity assurance and control in database administration, which treated integrity as an operational control problem. Reviewers were told to examine transaction logs, security-history logs, input and processing controls, and performance against defined standards. Correctness testing and auditability were connected from the start.

Here is a test you can apply today. Restore a backup or replay a batch, then compare a report against the same report from before. If the number changes and no business event explains it, integrity has failed, even if every service is healthy.

Four Checks That Define Data Integrity

Four checks cover most of the ground: accuracy, consistency, completeness and validity. The table shows what each one asks, the failure it catches, and the query that exposes it.

CheckQuestion It AnswersTypical FailureTest to Run
AccuracyDoes the stored value match the source event?Order total differs from the sum of its line itemsRecompute totals from line items and compare
ConsistencyDo related records agree across tables and systems?Invoice exists with no matching paymentReconcile counts and balances between systems
CompletenessDid every expected record arrive and persist?Replay silently drops 2% of checkout eventsCompare expected and stored record counts per batch
ValidityDoes each value follow the defined rules?Email field holds a date, or status is nullRun schema constraints and allowed-value checks

What each check actually catches

Accuracy compares the stored value against the event that produced it. Recompute an order total from its line items, tax and discount, then compare that figure to the stored order_total. A mismatch means the write path computed something different from what the pricing logic should have produced.

Consistency checks that related records agree. Every invoice should have a matching payment, and the sum of payments should equal the invoice total. Cross-system drift is the harder version of this check. When inventory is served to buyers in real time, the listing and the warehouse record have to agree at the moment of the write, which is the problem real-time data for car importers describes: a listing that says available for a vehicle already sold is a consistency failure, not a display bug.

Completeness counts expected against stored records per batch. If a replay pushes a batch of checkout events and some rows never land, the gap is the finding, and it is far easier to spot as a count than as a missing report line weeks later.

Validity enforces the rules each value must follow: data types, ranges, allowed statuses, unique keys and schema constraints. This is the area standardization formalized. NIST’s Special Publication 800-8 records that SQL-92 was approved as both an ANSI and ISO standard, with the related federal profile PIPS 127-2 approved in June 1993, and notes that conformance testing for Intermediate and Full SQL-92 was a major effort still to begin at the time of the report. Declared constraints became something a system could be tested against rather than something each team invented.

Where the four overlap

The checks are not independent. A duplicated order is complete but inconsistent: both rows exist, and they contradict the intent of a single purchase. A negative quantity passes a type check and fails a range check, so it is valid in form and invalid in rule. Expect to write assertions that span two checks.

Set tolerances deliberately. Money and identifiers allow zero difference, because a cent of drift is a defect. Timestamps may allow a documented clock skew, and floating point aggregates may allow a stated percentage, but write the number down and justify it. A tolerance nobody can explain is how real discrepancies get absorbed.

All four checks can pass while the business logic is still wrong. Recomputing a total correctly proves arithmetic, not that the correct item was ordered.

That is why the next layer needs invariants and comparison against expected outcomes, not just field-level rules.

How to Run a Data Integrity Test Step by Step

The routine below works for a checkout flow, an account creation path, or a migration. It runs in a fixed order because each step depends on the one before it, and the order is where errors often occur.

A step-by-step infographic illustrating the seven essential stages of performing a comprehensive data integrity test.

Capture, replay, compare, then break it on purpose

  1. Capture a baseline before anything moves. Hash the tables or files the workflow touches and record key row counts. Store that baseline somewhere the system under test cannot write to. The usual slip is hashing after the replay, which leaves nothing meaningful to compare against.
  2. Write the invariants down as queries. List the totals that must balance, the foreign keys that must resolve, the unique keys that must hold, and the idempotency rules the workflow promises. The slip here is writing invariants only for the happy path and leaving retries and partial failures uncovered.
  3. Replay representative traffic into an isolated target. Disable outbound email, payment gateways, webhooks and anything else with an external side effect. Replaying into a target that still charges cards is the failure mode that gets test environments shut down.
  4. Compare hashes and run the invariant queries after each phase. A wall of 200 responses establishes nothing about stored state. Measuring performance and comparing responses and application state is a separate step from proving correctness, and a successful replay alone does not establish it.
  5. Inject controlled faults. Alter records, delete objects, duplicate events, truncate logs and apply unauthorized updates by hand. Testing only the faults you already expect is the common mistake, and it produces a suite that confirms your assumptions.
  6. Confirm the detection path, not just the detection. For each injected fault, verify that monitoring notices, records what changed, alerts an operator, and restores a known-good version without discarding valid writes. NIST’s data integrity project description lists automated corruption testing, checksums or file hashing, monitoring of database creations and modifications, auditability of metadata changes, and recovery from script-induced modifications as the core capabilities to build.
  7. Record the measured recovery point and recovery time objectives. Measure them from the fault injection runs rather than quoting a target from a design document. A restore that takes four hours when the objective says one is an integrity risk, not an infrastructure footnote.

Why a matching hash is not a passing grade

A hash comparison proves that bytes did not change. It cannot prove the bytes were right in the first place. A validly formatted transaction that writes the wrong customer, or posts to the wrong account, produces a perfectly stable hash and a completely wrong system.

That is why hashing belongs beside schema constraints, reconciliation totals, immutable audit logs and measured recovery objectives. Each catches something the others miss.

If you want to watch a captured workload run against a target and compare the results, the video below walks through the mechanics of replaying recorded traffic.

The table below is the reference for what counts as a pass at each phase.

Test PhaseWhat to ComparePass Condition
Baseline captureTable hashes and key row countsStored outside the system under test
After replayHashes and invariant queriesZero unexplained differences
Fault injectionAltered, deleted and duplicated recordsEach fault detected and alerted
RecoveryRestored state against the baselineMatches the known-good version within RPO and RTO

Integrity Failures That Pass a Simple Replay

Replay testing has a blind spot, and it shows up most clearly in payment flows. Consider a customer who submits an order, sees a spinner, and taps again. The client retries, the gateway retries, and the service processes both attempts because nothing on the write path enforced idempotency. Every response is a 200. The confirmation page renders correctly. The only evidence is in the data: the invoice count is off by one, and the customer now has two orders for the same cart.

An idempotency and uniqueness invariant catches that in a single query. Compare the count of distinct cart identifiers against the count of order rows for the same window. A response-level test never will, because both responses were legitimate.

The orphan that no endpoint reports

Take a second failure. A write lands in the orders table, the process crashes before the inventory update runs, and the transaction boundary was drawn in the wrong place. Order lines now exist for stock that was never reserved. The API returned success for the order and success for the inventory call that never happened.

A reconciliation query between orders and inventory exposes the gap immediately: order lines without a matching reservation, or reserved units with no order. Run that reconciliation per batch and you catch the orphan the same hour it appears instead of during a stock count.

When concurrency breaks a total

The third failure is the hardest to see. Two workers read the same account balance under weaker isolation than production uses, both compute a new value, and the second write overwrites the first. Each request looked correct in isolation. The final state breaks a conservation total: money left one account and never arrived in the other.

This is why isolation behavior belongs in the test plan rather than the database team’s documentation. Research on the LDBC Social Network Benchmark defines data-model-agnostic tests for all ACID properties and explicitly targets 10 isolation anomalies, including dirty reads, non-repeatable reads and write conflicts. Replaying production interactions can look successful while concurrent execution produces an invalid state, if the test system isolates differently from production.

The practical countermeasure is to run identical read and write traces at controlled concurrency, then capture commit order and observed versions so a failing run can be explained rather than re-run until it passes. Understanding how transaction isolation levels change what concurrent workers see is the prerequisite for writing those traces.

Reject a performance gain that comes from weakened isolation or durability. A faster result that is wrong is a failed test, not an optimization.

Teams that compare old and new versions side by side already know the value of this. As one practitioner put it: “We soak test our new and old versions of our web service and the compare their metrics to discover bugs.” The metrics are only meaningful when the data behind them is verified too.

Keeping Masked and Synthetic Test Data Honest

Masked and synthetic datasets have a quiet failure mode: they look realistic and no longer contain the defect. A production trace where a handful of orders use a currency with three decimal places becomes, after masking, a tidy dataset where every order uses two. The rounding bug survives the release because the test data stopped exercising it.

Realistic-looking data is not automatically valid. Validity depends on preserving the dependencies and failure modes that matter.

Assert behavior, not similarity

Row counts and average similarity scores miss relational and behavioral integrity. A 2025 systematic review of synthetic test-data methods found 37 partially suitable approaches across 75 publications, and noted that many still require direct access to real-world data for anonymization or generation, an operational and privacy constraint that most testing guidance skips over, as detailed in the review of synthetic test-data approaches.

The assertions that catch real problems are specific:

  • Referential relationships stay intact, so identifiers link consistently across services.
  • Temporal ordering stays causal, so an event never precedes the event that triggered it.
  • State transitions remain legal, so a cancelled order never returns to pending.
  • Distribution tails survive, so rare combinations and extreme values still appear.
  • Cross-system compatibility holds, so downstream systems produce the same outcomes as in production.

Redaction is where the edge cases die. If your masking tool replaces the values that trigger the interesting branch, you have built a clean dataset that tests the happy path only. Read more about data masking and anonymization before choosing what to replace.

Test privacy as a property, not a vibe

Synthetic data is not automatically safe once it is dissimilar enough from source records. A 2025 experimental study found that Distance to Closest Record and similar distance-based proxies can fail to detect privacy leakage, with datasets judged private by those metrics remaining vulnerable to membership-inference attacks across classical, GAN-based and diffusion-model generators, as reported in the study on synthetic data privacy leakage. The question for an engineering team is not “does this dataset resemble production” but “does it preserve the integrity signals without enabling reconstruction, membership inference or discriminatory behavior”.

The tradeoff is real and it runs in both directions. Aggressive masking breaks correlations and weakens defect detection. Weak masking exposes personal data. Neither extreme is a policy, so define a multi-dimensional acceptance gate covering integrity, privacy, utility and fairness, with documented thresholds, attack-based privacy tests, and subgroup and rare-event utility checks.

A single similarity score is not an acceptance criterion. It is one input to a gate that also asks what the data can leak and what it can no longer detect.

One practical habit when you share sample traffic for review: leave out credentials and production request data before anything goes into a ticket or a chat thread.

Add an Integrity Gate Before Your Next Release

Pick one critical workflow this week, either checkout or account creation, and build an integrity gate around it. Not a dashboard, not a quarterly audit. A gate that fails a build.

  1. Choose three to five invariants for that workflow: totals that must balance, required links between records, and unique keys that must hold.
  2. Capture the baseline hash and key row counts in storage the test environment cannot write to.
  3. Replay a representative sample into an isolated target and run the invariant queries against the result.
  4. Fail the release on any unexplained difference, and log each exception with a named owner so it does not become background noise.
  5. Re-run the gate after every schema migration and major dependency change, since those are the events that reshape stored data.

Keep the gate small enough to run on every build. A gate that runs once a quarter catches nothing before a release, because the failure has already shipped by the time it executes.

A checklist infographic titled Add an Integrity Gate before your next release with five actionable steps.

GoReplay fits at step three only. It records HTTP requests and replays them against an isolated test service, so the same captured workload can be reused when you compare builds or investigate a regression. The gate makes the decision; the tool supplies the traffic.

Aim for one passing gate on one workflow before your next release. Expand from there once the routine holds.


Testing data integrity gets easier when the workload is real and repeatable. GoReplay captures live HTTP traffic and replays it into staging or test environments, which gives your invariants, hashes and reconciliation queries the same requests to work against on every build. If you’re ready to stop trusting green responses and start proving stored outcomes, visit GoReplay and record your first production sample.

Ready to Get Started?

Join these successful companies in using GoReplay to improve your testing and deployment processes.

Talk to the GoReplay team

Describe what you want to capture or replay, your deployment, and any PRO requirements. Or email [email protected].

Please leave out credentials and production request data.