Documentation ¶
Overview ¶
Package seqtest provides a test fixture for instantiating sequencers and other general-purpose test helpers.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CheckSequencer ¶
func CheckSequencer( t *testing.T, pre func(t *testing.T, fixture *all.Fixture, seqFixture *Fixture) sequencer.Sequencer, post func(t *testing.T, check *Check), )
CheckSequencer implements a general-purpose smoke test of a sequencer.Sequencer implementation. The sequencer must support foreign-key relationships. The post-hook may be nil.
func Fragment ¶
func Fragment(batch *types.MultiBatch) ([]*types.MultiBatch, error)
Fragment breaks a batch up into a number of minimum-sized batches which are representative of how the bulk-transfer CDC feed delivers data (i.e. payloads per table). The data for any given table will remain in a time-ordered fashion.
Types ¶
type Check ¶
type Check struct { // The acceptor returned by [sequencer.Sequencer.Start]. Acceptor types.MultiAcceptor // The total number of transactions to apply. Batches int // Populated by Check. Bounds notify.Var[hlc.Range] // Access to test services. Fixture *all.Fixture // Populated by Check. Generator *Generator // Populated by Check. Group *types.TableGroup // The Sequencer under test. Sequencer sequencer.Sequencer // If true, generated data will be loaded into staging first. This // is used to validate the sweeping behavior of a sequencer. Stage bool }
Check implements a reusable test over a parent/child table pair.
type CheckFlag ¶
type CheckFlag int
CheckFlag describes the range of configurations to be tested. See CheckFlags.
type Fixture ¶
type Fixture struct { *all.Fixture BestEffort *besteffort.BestEffort Chaos *chaos.Chaos Core *core.Core Immediate *immediate.Immediate Retire *retire.Retire Script *script.Sequencer Switcher *switcher.Switcher }
Fixture provides ready-to-use instances of sequencer types.
func NewSequencerFixture ¶
type Generator ¶
type Generator struct { Fixture *all.Fixture MaxTime hlc.Time Parent, Child base.TableInfo[*types.TargetPool] Parents, Children map[int]struct{} // Compare data to ensure time order is maintained. ParentVals, ChildVals map[int]int64 // The keys are child ids and the value the parent id. ChildToParent map[int]int // contains filtered or unexported fields }
Generator creates batches of test data. It assumes that there is a parent table and a child table. The parents map will be updated whenever a new parent entry is required.
func NewGenerator ¶
func NewGenerator( ctx context.Context, fixture *all.Fixture, ) (*Generator, *types.TableGroup, error)
NewGenerator constructs a Generator that will create messages for parent and child tables.
func (*Generator) CheckConsistent ¶
CheckConsistent verifies that the staging tables are empty and that the requisite number of rows exist in the target tables.
func (*Generator) GenerateInto ¶
func (g *Generator) GenerateInto(batch *types.MultiBatch, time hlc.Time)
GenerateInto will add mutations to the batch at the requested time.