Documentation
¶
Overview ¶
Package loadgen generates deterministic synthetic Finding, FindingRollup, and Investigation resources for benchmarks and load tests. The same (index, Opts) pair always yields byte-identical objects, so benchmark datasets are reproducible across runs and machines, and a scanner-side alert built by SourceFinding folds into the Finding built by the same index — the label hash follows the exact accumulation-key recipe the ingester persists.
TEST-ONLY: this package is imported only from _test.go files. It must never be imported by product code — its objects fabricate status fields that production components own exclusively.
Index ¶
- Constants
- func Finding(i int, o Opts) *v1alpha1.Finding
- func FindingName(i int, o Opts) string
- func Findings(n int, o Opts) []v1alpha1.Finding
- func Investigations(n int, o Opts) []v1alpha1.Investigation
- func KeyHash(i int, o Opts) string
- func RepoURL(i int, o Opts) string
- func Rollups(n int) []v1alpha1.FindingRollup
- func SourceFinding(i, alert int, o Opts) source.Finding
- type Opts
Constants ¶
const ( // IntegrationName is the ingesting Integration every finding references. IntegrationName = "loadgen" // SourceID is the source handler id on every finding. SourceID = "loadgen-scanner" // Namespace the generated objects live in. Namespace = "patchy" )
Fixed identities every generated object shares. The integration name enters the accumulation key, so a bench pairing SourceFinding with an Integration CR must name the CR IntegrationName.
Variables ¶
This section is empty.
Functions ¶
func Finding ¶
Finding builds index i's Finding, shaped like a real ingested one: the accumulation labels carry genuine hash values, alerts carry locations and snippets, and status matches the picked phase.
func FindingName ¶
FindingName is index i's deterministic object name (generation 1).
func Investigations ¶
func Investigations(n int, o Opts) []v1alpha1.Investigation
Investigations builds n Investigation children; child i belongs to Finding(i, o) and carries a completed stage result.
func KeyHash ¶
KeyHash is the accumulation-key label value for index i: the exact recipe internal/controller/integration persists (5-byte-hex sha256 over integration|source|scope|advisory).
func Rollups ¶
func Rollups(n int) []v1alpha1.FindingRollup
Rollups builds n FindingRollup objects: index 0 is the total scope, the rest are repository scopes, each with a populated bucket, monthly trend, and a full 512-entry ledger — the shape a long-lived deployment carries.
Types ¶
type Opts ¶
type Opts struct {
// AlertsPerFinding is the alert count folded into each finding
// (default 1, capped at the CRD's 64).
AlertsPerFinding int
// PhaseMix weights the phase distribution; nil means every finding is
// Opened. Terminal phases get a CompletedAt stamp.
PhaseMix map[v1alpha1.Phase]int
// RepoCardinality is the number of distinct repositories findings spread
// over (default 100).
RepoCardinality int
// Seed varies the whole dataset; the default 0 is a valid seed.
Seed uint64
}
Opts shape a synthetic dataset. The zero value is usable.