Documentation
¶
Index ¶
- func AssertEqual(t *testing.T, expected, actual interface{}, msgAndArgs ...interface{})
- func AssertError(t *testing.T, err error, msgAndArgs ...interface{})
- func AssertFalse(t *testing.T, condition bool, msgAndArgs ...interface{})
- func AssertNoError(t *testing.T, err error, msgAndArgs ...interface{})
- func AssertTrue(t *testing.T, condition bool, msgAndArgs ...interface{})
- func ContainerRuntimeFailedProblem() types.Problem
- func DiskPressureProblem() types.Problem
- func Eventually(t *testing.T, condition func() bool, timeout time.Duration, ...)
- func HealthyDiskStatus() types.Status
- func HealthyKubeletStatus() types.Status
- func HealthyMemoryStatus() types.Status
- func KubeletFailedProblem() types.Problem
- func LoadTestDataFile(filename string) ([]byte, error)
- func LoadTestDataJSON(filename string, v interface{}) error
- func MemoryPressureProblem() types.Problem
- func MultiProblemStatus() types.Status
- func NetworkPluginNotReadyProblem() types.Problem
- func NodeNotReadyProblem() types.Problem
- func TempConfigFile(t *testing.T, name string) string
- func TempDir(t *testing.T) string
- func TempFile(t *testing.T, content string) string
- func TestContext(t *testing.T, timeout time.Duration) (context.Context, context.CancelFunc)
- func UnhealthyDiskStatus() types.Status
- func UnhealthyKubeletStatus() types.Status
- func UnhealthyMemoryStatus() types.Status
- type CommandConfig
- type ExecutedCommand
- type MockCommandExecutor
- func (m *MockCommandExecutor) Execute(ctx context.Context, name string, args ...string) (string, error)
- func (m *MockCommandExecutor) GetExecutedCommandCount() int
- func (m *MockCommandExecutor) GetExecutedCommands() []ExecutedCommand
- func (m *MockCommandExecutor) Reset()
- func (m *MockCommandExecutor) SetCommand(name string, output string, err error)
- func (m *MockCommandExecutor) SetCommandWithDelay(name string, output string, err error, delay time.Duration)
- func (m *MockCommandExecutor) SetDefaultBehavior(output string, err error)
- func (m *MockCommandExecutor) WasCommandExecuted(name string) bool
- type MockHTTPServer
- func (m *MockHTTPServer) GetRequestBodies() []string
- func (m *MockHTTPServer) GetRequestCount() int
- func (m *MockHTTPServer) GetRequests() []*http.Request
- func (m *MockHTTPServer) Reset()
- func (m *MockHTTPServer) SetResponse(statusCode int, body string)
- func (m *MockHTTPServer) SetResponseDelay(delay time.Duration)
- type MockKubernetesClient
- func (m *MockKubernetesClient) GetListRequestCount() int
- func (m *MockKubernetesClient) GetNode(ctx context.Context, nodeName string) (interface{}, error)
- func (m *MockKubernetesClient) GetNodeRequests() []string
- func (m *MockKubernetesClient) ListNodes(ctx context.Context) ([]interface{}, error)
- func (m *MockKubernetesClient) Reset()
- func (m *MockKubernetesClient) SetNodeError(err error)
- func (m *MockKubernetesClient) SetNodeResponse(nodeName string, response interface{})
- func (m *MockKubernetesClient) SetResponseDelay(delay time.Duration)
- type ProblemFixture
- func (f *ProblemFixture) Build() types.Problem
- func (f *ProblemFixture) WithDetectedAt(t time.Time) *ProblemFixture
- func (f *ProblemFixture) WithMessage(message string) *ProblemFixture
- func (f *ProblemFixture) WithMetadata(key, value string) *ProblemFixture
- func (f *ProblemFixture) WithResource(resource string) *ProblemFixture
- func (f *ProblemFixture) WithSeverity(severity types.ProblemSeverity) *ProblemFixture
- func (f *ProblemFixture) WithType(problemType string) *ProblemFixture
- type StatusFixture
- func (f *StatusFixture) Build() types.Status
- func (f *StatusFixture) WithCondition(condition types.Condition) *StatusFixture
- func (f *StatusFixture) WithConditions(conditions []types.Condition) *StatusFixture
- func (f *StatusFixture) WithEvent(event types.Event) *StatusFixture
- func (f *StatusFixture) WithEvents(events []types.Event) *StatusFixture
- func (f *StatusFixture) WithSource(source string) *StatusFixture
- func (f *StatusFixture) WithTimestamp(t time.Time) *StatusFixture
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AssertEqual ¶
AssertEqual fails the test if expected != actual.
func AssertError ¶
AssertError fails the test if err is nil.
func AssertFalse ¶
AssertFalse fails the test if condition is true.
func AssertNoError ¶
AssertNoError fails the test if err is not nil.
func AssertTrue ¶
AssertTrue fails the test if condition is false.
func ContainerRuntimeFailedProblem ¶
ContainerRuntimeFailedProblem returns a problem representing a failed container runtime.
func DiskPressureProblem ¶
DiskPressureProblem returns a problem representing disk pressure.
func Eventually ¶
func Eventually(t *testing.T, condition func() bool, timeout time.Duration, interval time.Duration, msgAndArgs ...interface{})
Eventually retries a condition function until it returns true or timeout.
func HealthyDiskStatus ¶
HealthyDiskStatus returns a healthy status from disk monitor.
func HealthyKubeletStatus ¶
HealthyKubeletStatus returns a healthy status from kubelet monitor.
func HealthyMemoryStatus ¶
HealthyMemoryStatus returns a healthy status from memory monitor.
func KubeletFailedProblem ¶
KubeletFailedProblem returns a problem representing a failed kubelet service.
func LoadTestDataFile ¶
LoadTestDataFile loads a file from the testdata directory.
func LoadTestDataJSON ¶
LoadTestDataJSON loads and unmarshals a JSON file from testdata.
func MemoryPressureProblem ¶
MemoryPressureProblem returns a problem representing memory pressure.
func MultiProblemStatus ¶
MultiProblemStatus returns a status with multiple problems.
func NetworkPluginNotReadyProblem ¶
NetworkPluginNotReadyProblem returns a problem representing network plugin not ready.
func NodeNotReadyProblem ¶
NodeNotReadyProblem returns a problem representing a node not ready condition.
func TempConfigFile ¶ added in v1.0.1
TempConfigFile creates a temporary config file with minimal valid content for tests.
func TestContext ¶
TestContext creates a test context with timeout.
func UnhealthyDiskStatus ¶
UnhealthyDiskStatus returns an unhealthy status from disk monitor.
func UnhealthyKubeletStatus ¶
UnhealthyKubeletStatus returns an unhealthy status from kubelet monitor.
func UnhealthyMemoryStatus ¶
UnhealthyMemoryStatus returns an unhealthy status from memory monitor.
Types ¶
type CommandConfig ¶
CommandConfig defines the behavior for a specific command.
type ExecutedCommand ¶
ExecutedCommand tracks an executed command.
type MockCommandExecutor ¶
type MockCommandExecutor struct {
// contains filtered or unexported fields
}
MockCommandExecutor is a mock implementation for executing system commands.
func NewMockCommandExecutor ¶
func NewMockCommandExecutor() *MockCommandExecutor
NewMockCommandExecutor creates a new mock command executor.
func (*MockCommandExecutor) Execute ¶
func (m *MockCommandExecutor) Execute(ctx context.Context, name string, args ...string) (string, error)
Execute simulates command execution.
func (*MockCommandExecutor) GetExecutedCommandCount ¶
func (m *MockCommandExecutor) GetExecutedCommandCount() int
GetExecutedCommandCount returns the number of executed commands.
func (*MockCommandExecutor) GetExecutedCommands ¶
func (m *MockCommandExecutor) GetExecutedCommands() []ExecutedCommand
GetExecutedCommands returns all executed commands.
func (*MockCommandExecutor) Reset ¶
func (m *MockCommandExecutor) Reset()
Reset clears all state from the executor.
func (*MockCommandExecutor) SetCommand ¶
func (m *MockCommandExecutor) SetCommand(name string, output string, err error)
SetCommand configures the behavior for a specific command.
func (*MockCommandExecutor) SetCommandWithDelay ¶
func (m *MockCommandExecutor) SetCommandWithDelay(name string, output string, err error, delay time.Duration)
SetCommandWithDelay configures a command with a delay.
func (*MockCommandExecutor) SetDefaultBehavior ¶
func (m *MockCommandExecutor) SetDefaultBehavior(output string, err error)
SetDefaultBehavior sets the default output and error for unknown commands.
func (*MockCommandExecutor) WasCommandExecuted ¶
func (m *MockCommandExecutor) WasCommandExecuted(name string) bool
WasCommandExecuted checks if a specific command was executed.
type MockHTTPServer ¶
MockHTTPServer provides utilities for creating mock HTTP servers in tests.
func NewMockHTTPServer ¶
func NewMockHTTPServer() *MockHTTPServer
NewMockHTTPServer creates a new mock HTTP server.
func (*MockHTTPServer) GetRequestBodies ¶
func (m *MockHTTPServer) GetRequestBodies() []string
GetRequestBodies returns all request bodies received.
func (*MockHTTPServer) GetRequestCount ¶
func (m *MockHTTPServer) GetRequestCount() int
GetRequestCount returns the number of requests received.
func (*MockHTTPServer) GetRequests ¶
func (m *MockHTTPServer) GetRequests() []*http.Request
GetRequests returns all requests received by the server.
func (*MockHTTPServer) SetResponse ¶
func (m *MockHTTPServer) SetResponse(statusCode int, body string)
SetResponse sets the status code and response body.
func (*MockHTTPServer) SetResponseDelay ¶
func (m *MockHTTPServer) SetResponseDelay(delay time.Duration)
SetResponseDelay sets a delay for all responses.
type MockKubernetesClient ¶
type MockKubernetesClient struct {
// contains filtered or unexported fields
}
MockKubernetesClient is a mock implementation of a Kubernetes client for testing.
func NewMockKubernetesClient ¶
func NewMockKubernetesClient() *MockKubernetesClient
NewMockKubernetesClient creates a new mock Kubernetes client.
func (*MockKubernetesClient) GetListRequestCount ¶
func (m *MockKubernetesClient) GetListRequestCount() int
GetListRequestCount returns the number of list requests made.
func (*MockKubernetesClient) GetNode ¶
func (m *MockKubernetesClient) GetNode(ctx context.Context, nodeName string) (interface{}, error)
GetNode retrieves a node by name.
func (*MockKubernetesClient) GetNodeRequests ¶
func (m *MockKubernetesClient) GetNodeRequests() []string
GetNodeRequests returns the list of node names requested.
func (*MockKubernetesClient) ListNodes ¶
func (m *MockKubernetesClient) ListNodes(ctx context.Context) ([]interface{}, error)
ListNodes returns all configured nodes.
func (*MockKubernetesClient) Reset ¶
func (m *MockKubernetesClient) Reset()
Reset clears all state from the mock client.
func (*MockKubernetesClient) SetNodeError ¶
func (m *MockKubernetesClient) SetNodeError(err error)
SetNodeError sets an error to be returned for node requests.
func (*MockKubernetesClient) SetNodeResponse ¶
func (m *MockKubernetesClient) SetNodeResponse(nodeName string, response interface{})
SetNodeResponse sets the response for a specific node name.
func (*MockKubernetesClient) SetResponseDelay ¶
func (m *MockKubernetesClient) SetResponseDelay(delay time.Duration)
SetResponseDelay sets a delay for all responses.
type ProblemFixture ¶
type ProblemFixture struct {
// contains filtered or unexported fields
}
ProblemFixture provides a fluent builder for creating test Problem instances.
func NewProblemFixture ¶
func NewProblemFixture() *ProblemFixture
NewProblemFixture creates a new Problem fixture with sensible defaults.
func (*ProblemFixture) Build ¶
func (f *ProblemFixture) Build() types.Problem
Build returns the constructed Problem.
func (*ProblemFixture) WithDetectedAt ¶
func (f *ProblemFixture) WithDetectedAt(t time.Time) *ProblemFixture
WithDetectedAt sets the detection timestamp.
func (*ProblemFixture) WithMessage ¶
func (f *ProblemFixture) WithMessage(message string) *ProblemFixture
WithMessage sets the problem message.
func (*ProblemFixture) WithMetadata ¶
func (f *ProblemFixture) WithMetadata(key, value string) *ProblemFixture
WithMetadata sets a metadata key-value pair.
func (*ProblemFixture) WithResource ¶
func (f *ProblemFixture) WithResource(resource string) *ProblemFixture
WithResource sets the resource identifier.
func (*ProblemFixture) WithSeverity ¶
func (f *ProblemFixture) WithSeverity(severity types.ProblemSeverity) *ProblemFixture
WithSeverity sets the problem severity.
func (*ProblemFixture) WithType ¶
func (f *ProblemFixture) WithType(problemType string) *ProblemFixture
WithType sets the problem type.
type StatusFixture ¶
type StatusFixture struct {
// contains filtered or unexported fields
}
StatusFixture provides a fluent builder for creating test Status instances.
func NewStatusFixture ¶
func NewStatusFixture() *StatusFixture
NewStatusFixture creates a new Status fixture with sensible defaults.
func (*StatusFixture) Build ¶
func (f *StatusFixture) Build() types.Status
Build returns the constructed Status.
func (*StatusFixture) WithCondition ¶
func (f *StatusFixture) WithCondition(condition types.Condition) *StatusFixture
WithCondition adds a condition to the status.
func (*StatusFixture) WithConditions ¶
func (f *StatusFixture) WithConditions(conditions []types.Condition) *StatusFixture
WithConditions sets multiple conditions.
func (*StatusFixture) WithEvent ¶
func (f *StatusFixture) WithEvent(event types.Event) *StatusFixture
WithEvent adds an event to the status.
func (*StatusFixture) WithEvents ¶
func (f *StatusFixture) WithEvents(events []types.Event) *StatusFixture
WithEvents sets multiple events.
func (*StatusFixture) WithSource ¶
func (f *StatusFixture) WithSource(source string) *StatusFixture
WithSource sets the status source (monitor name).
func (*StatusFixture) WithTimestamp ¶
func (f *StatusFixture) WithTimestamp(t time.Time) *StatusFixture
WithTimestamp sets the status timestamp.