smoke

package
v1.94.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 16, 2026 License: MPL-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	StatusPass = "PASS"
	StatusFail = "FAIL"
	StatusSkip = "SKIP"
)

Status constants for test results.

Variables

View Source
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

func ExitCode(s Summary) int

ExitCode returns the process exit code for a smoke summary. 0 = all PASS (SKIPs don't count as failure) 1 = any FAIL

func FormatHuman

func FormatHuman(s Summary) string

FormatHuman returns a human-readable smoke report.

func FormatJSON

func FormatJSON(s Summary) (string, error)

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.

func RunSmoke

func RunSmoke(version string, group string) Summary

RunSmoke executes all registered tests, optionally filtered by group. Returns a Summary with PASS/FAIL/SKIP per test.

type SummaryCounts

type SummaryCounts struct {
	Pass int `json:"pass"`
	Fail int `json:"fail"`
	Skip int `json:"skip"`
}

SummaryCounts holds pass/fail/skip counts.

type TestOutput

type TestOutput struct {
	ExitCode int
	Stdout   string
	Stderr   string
	Duration time.Duration
}

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL