Documentation
¶
Overview ¶
Package validation verifies that a finished migration actually landed.
ValidateFileSystem, ValidateObjectStorage and ValidateDBMS each re-read both ends of a completed transfer and compare them, reporting one ValidationDetailItem per mismatch: file inventories with their sizes and either their modification times (ModeQuick) or their SHA256 checksums (ModeChecksum), object inventories with their ETags, and for DBMS the per-table row counts plus the schema object inventories. Comparing rows alone would miss anything without them — a view, a function, a trigger — and those are exactly what fails quietly.
Each end is read at the same time as the other, and Options.Progress hears where a run has got to — files hashed, tables counted — so a validation that takes minutes can be told from one that has stopped.
Cross-storage transfers (filesystem↔objectstorage) are compared by path and size only: the two ends share no content fingerprint to compare, and a modification time does not survive the move into object storage.
Connections are resolved through pkg/core/migration, using the same resolvers the migration itself used. Resolving them a second way here is how a transfer that succeeded ends up failing verification.
Index ¶
- Constants
- func ValidMode(mode string) bool
- func ValidateDBMS(ctx context.Context, m targetmodel.MigrationDBModel, opt Options) ([]model.ValidationDetailItem, error)
- func ValidateFileSystem(ctx context.Context, m targetmodel.MigrationFileSystemModel, opt Options) ([]model.ValidationDetailItem, error)
- func ValidateObjectStorage(ctx context.Context, m targetmodel.MigrationObjectStorageModel, opt Options) ([]model.ValidationDetailItem, error)
- type Options
Constants ¶
const ( // ModeQuick compares each file's size and modification time. Seconds for // any number of files, since nothing is read — but a file whose content // changed without either moving passes. The default: a validation of // gigabytes should not take minutes unless asked to. ModeQuick = "quick" // ModeChecksum adds a SHA256 of every file the migration carried, on both // hosts. It reads all of that data, so it takes as long as reading it does. ModeChecksum = "checksum" )
Validation modes. They apply to file system → file system items only: object storage is always compared by size and ETag, a cross-storage item by path and size, and a database by row counts and schema objects, whichever mode was asked for.
Variables ¶
This section is empty.
Functions ¶
func ValidateDBMS ¶
func ValidateDBMS(ctx context.Context, m targetmodel.MigrationDBModel, opt Options) ([]model.ValidationDetailItem, error)
ValidateDBMS compares every database this model migrated: per-table row counts and the schema object inventories.
Comparing data alone would miss anything without rows — a view, a function, a trigger — and those are exactly what fails quietly, most often because a MySQL/MariaDB DEFINER clause names a user the target does not have.
A database that cannot be read is reported as one failed item and the next one is validated: one unreachable database does not erase what the others would have said. opt.Mode does not apply here.
func ValidateFileSystem ¶
func ValidateFileSystem(ctx context.Context, m targetmodel.MigrationFileSystemModel, opt Options) ([]model.ValidationDetailItem, error)
ValidateFileSystem checks that each dst folder in m contains exactly the same files as the corresponding src folder. opt.Mode decides what "the same" means: size and modification time (ModeQuick), or size and SHA256 (ModeChecksum). Returns one ValidationDetailItem per mismatch (missing file, extra file, or a size, time or hash diff). Connection errors are reported as a failed item for the folder root.
A folder that landed in object storage (cross-storage) is compared by path and size only, whatever opt.Mode says — see validateCrossStorage.
func ValidateObjectStorage ¶
func ValidateObjectStorage(ctx context.Context, m targetmodel.MigrationObjectStorageModel, opt Options) ([]model.ValidationDetailItem, error)
ValidateObjectStorage checks that each dst bucket in m contains exactly the same objects as the corresponding src bucket, with identical ETags. Returns one ValidationDetailItem per mismatch (missing object, extra object, or ETag diff). Connection errors are reported as a failed item for the bucket path.
Objects are compared from their listings alone — nothing is downloaded — so opt.Mode does not apply here.
Types ¶
type Options ¶
type Options struct {
// Mode is ModeQuick or ModeChecksum; empty means ModeQuick.
Mode string
// Progress, when set, is told where the run has got to in one line. It is
// called from several goroutines at once and as often as every file, so it
// must be safe for concurrent use and cheap: throttling is the caller's.
Progress func(message string)
}
Options steers one validation run.