Documentation
¶
Overview ¶
Package testharness contains opt-in Docker API fault-injection helpers.
Index ¶
Constants ¶
const ( LabelRun = "io.carbon-panel.fault-harness.run" LabelInstall = "io.carbon-panel.fault-harness.install" LabelNode = "io.carbon-panel.fault-harness.node" )
const ManifestVersion = 1
Variables ¶
This section is empty.
Functions ¶
func Cleanup ¶
Cleanup removes only IDs listed in the manifest after confirming each object's daemon identity and all three ownership labels. It never prunes or enumerates.
func WriteManifest ¶
WriteManifest writes atomically and refuses to overwrite an existing run file.
Types ¶
type Daemon ¶
type Daemon struct {
Alias string `json:"alias"`
ID string `json:"id"`
DockerRootDir string `json:"docker_root_dir"`
ServerVersion string `json:"server_version"`
}
Daemon is a qualified Engine identity. Alias maps to endpoint-a or endpoint-b.
type FaultKind ¶
type FaultKind string
FaultKind describes where the proxy interrupts a Docker API exchange.
const ( // DropBefore closes the client connection without sending a request upstream. DropBefore FaultKind = "drop-before" // DelayBefore waits before forwarding; a client deadline can cancel the request // before the daemon sees it. DelayBefore FaultKind = "delay-before" // DropAfter forwards the full request, consumes the daemon response, then drops // the client connection. Mutations may have committed and the result is ambiguous. DropAfter FaultKind = "drop-after" // DelayAfter forwards the request, waits for the daemon response, then delays // delivery. A client timeout at this point is also an ambiguous result. DelayAfter FaultKind = "delay-after" // PullErrorStream appends a Docker JSON progress/error frame to an image-pull // stream while preserving the HTTP status and streaming response shape. PullErrorStream FaultKind = "pull-error-stream" // DisconnectOnce drops the first matching streaming request. Later requests pass. DisconnectOnce FaultKind = "disconnect-once" )
type Manifest ¶
type Manifest struct {
Version int `json:"version"`
RunID string `json:"run_id"`
InstallID string `json:"install_id"`
NodeID string `json:"node_id"`
CreatedAt time.Time `json:"created_at"`
Daemons []Daemon `json:"daemons"`
Resources []OwnedResource `json:"resources"`
}
Manifest records the owner and daemon identity for every disposable resource. Endpoints are deliberately kept outside the file because they can contain credentials; callers supply endpoints again when cleaning up.
func NewManifest ¶
func NewManifest(ctx context.Context, endpointA, endpointB, installID, nodeID, runID string) (*Manifest, error)
NewManifest verifies both endpoints are available, identify different daemons, and report different Docker roots before returning a manifest.
func ReadManifest ¶
ReadManifest parses and validates the version and required ownership fields.
func (*Manifest) AddResource ¶
func (m *Manifest) AddResource(resource OwnedResource) error
AddResource records an exact object only when its ownership labels match this run.
func (*Manifest) OwnershipLabels ¶
OwnershipLabels returns the complete identifying label set for an owned object.
type OwnedResource ¶
type OwnedResource struct {
DaemonAlias string `json:"daemon_alias"`
Kind string `json:"kind"`
ID string `json:"id"`
Name string `json:"name,omitempty"`
Labels map[string]string `json:"labels"`
}
OwnedResource identifies one exact Docker object eligible for scoped cleanup.
type Proxy ¶
type Proxy struct {
Target *url.URL
Listener net.Listener
// contains filtered or unexported fields
}
Proxy forwards Docker Engine HTTP requests to Target and injects configured faults. It does not understand or rewrite Docker API bodies except for the explicit pull error stream rule.
func NewProxy ¶
NewProxy binds a loopback listener and starts a protocol-level HTTP proxy. Target must be an HTTP(S) Docker Engine API endpoint (not a CLI context name).