Framework.Test.SequenceGapSimulator (Framework v0.5.0)

View Source

Simulates sequence gaps for testing consumer gap tolerance.

Creates gaps in the sequence by reserving sequence numbers in transactions that are then rolled back, simulating real-world scenarios where operations fail after sequence allocation.

Summary

Functions

Create a sequence gap by reserving and rolling back.

Create multiple sequence gaps in succession.

Get current sequence value without consuming it.

Get next sequence value that would be allocated.

Functions

create_gap()

Create a sequence gap by reserving and rolling back.

This simulates a real scenario where:

  1. Transaction begins and reserves nextval('outbox_sequence')
  2. Some operation fails (validation, constraint, etc.)
  3. Transaction rolls back, leaving a gap in the sequence

The gap tests that consumers handle missing sequence numbers correctly.

create_gaps(count)

Create multiple sequence gaps in succession.

current_sequence()

Get current sequence value without consuming it.

Useful for test verification and debugging.

peek_next_sequence()

Get next sequence value that would be allocated.

Uses nextval() to advance and return the sequence. Only use in tests since this consumes a sequence number.