Documentation
¶
Index ¶
Constants ¶
const ( StatusPass = "PASS" StatusFail = "FAIL" StatusSkip = "SKIP" )
Status constants for test results.
Variables ¶
var DefaultFatalPatterns = []string{
"bad array subscript",
"unbound variable",
"syntax error",
"command not found",
"No such file or directory",
"panic:",
"segmentation fault",
"traceback",
"SIGSEGV",
"nil pointer dereference",
}
DefaultFatalPatterns are runtime errors that always indicate FAIL. These catch shell explosions, Go panics, and missing binaries.
Functions ¶
func ExitCode ¶
ExitCode returns the process exit code for a smoke summary. 0 = all PASS (SKIPs don't count as failure) 1 = any FAIL
func FormatHuman ¶
FormatHuman returns a human-readable smoke report.
func FormatJSON ¶
FormatJSON returns a JSON smoke report.
Types ¶
type Prerequisite ¶
type Prerequisite struct {
Type string // "daemon", "file", "binary"
Name string // e.g. "nftband.service", "/etc/nftban/main.conf", "nftban-validate"
}
Prerequisite defines a condition that must be true for a test to run. If not met, the test is SKIP (not FAIL).
type SmokeTest ¶
type SmokeTest struct {
ID string
Name string
Category string // truth, daemon, config, metrics
Command []string // command + args to execute
AllowedExit []int // exit codes that count as PASS (e.g. [0,1,2])
Timeout time.Duration
Prerequisites []Prerequisite
FatalPatterns []string // stderr/stdout patterns that force FAIL
Assert func(TestOutput) bool // custom assertion on output (optional)
Notes string
}
SmokeTest defines a single registered smoke probe. All test execution is driven by this metadata — no ad hoc logic outside the registry.
func DefaultRegistry ¶
func DefaultRegistry() []SmokeTest
DefaultRegistry returns the Phase 1 smoke test set. Small, high-value, contract-safe. No module-deep or counter assertions.
type Summary ¶
type Summary struct {
Version string `json:"version"`
Result string `json:"result"` // PASS or FAIL
Counts SummaryCounts `json:"summary"`
Tests []TestResult `json:"tests"`
}
Summary holds the overall smoke run result.
type SummaryCounts ¶
SummaryCounts holds pass/fail/skip counts.
type TestOutput ¶
TestOutput holds captured output from a test execution.
type TestResult ¶
type TestResult struct {
ID string `json:"id"`
Name string `json:"name"`
Category string `json:"category"`
Status string `json:"status"` // PASS, FAIL, SKIP
DurationMs int64 `json:"duration_ms"`
Detail string `json:"detail,omitempty"`
}
TestResult holds the outcome of a single smoke test.