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. A scanner-side alert built by SourceFinding folds into the Finding built by the same index, because the label hash follows the accumulation-key recipe the ingester persists.
TEST-ONLY: import this package only from _test.go files, never from 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 is where the generated objects live. 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. It must match the recipe internal/controller/integration persists (hex of the first 5 bytes of 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.
func SourceFinding ¶
SourceFinding builds the scanner-side alert whose accumulation key matches Finding(i, o): ingesting it against an Integration named IntegrationName folds it into that family. alert distinguishes deliveries within the family.
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 shapes a synthetic dataset. The zero value is usable.