harness

package
v1.3.0-main Latest Latest
Warning

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

Go to latest
Published: May 27, 2026 License: Apache-2.0 Imports: 37 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type TestHarness

type TestHarness struct {

	// attributes for the test harness
	Context        context.Context
	Server         *apiserver.Server
	Agent          *agent.Agent
	Client         *apiclient.ClientWithResponses
	Store          *store.Store
	ServiceHandler service.Service // Service handler for direct service calls (bypasses HTTP/auth)
	KVStore        kvstore.KVStore // Same Redis as service; use to set awaiting-reconnect / rendered keys for tests
	TestDirPath    string
	// contains filtered or unexported fields
}

func NewTestHarness

func NewTestHarness(ctx context.Context, testDirPath string, goRoutineErrorHandler func(error), opts ...TestHarnessOption) (*TestHarness, error)

NewTestHarness creates a new test harness and returns a new test harness The test harness can be used from testing code to interact with a set of agent/server/store instances. It provides the necessary elements to perform tests against the agent and server. IMPORTANT: For parallel test execution, you MUST pass WithRedis() with connection params from testdb.CreateTestRedis() called in your suite's BeforeSuite.

func (*TestHarness) AgentConfig added in v1.2.0

func (h *TestHarness) AgentConfig() *agent_config.Config

AgentConfig returns the agent configuration for test customization

func (*TestHarness) AgentDownloadedCertificate

func (h *TestHarness) AgentDownloadedCertificate() bool

func (*TestHarness) AuthenticatedContext added in v1.0.0

func (h *TestHarness) AuthenticatedContext(ctx context.Context) context.Context

AuthenticatedContext adds admin identities and org ID to the provided context for direct service calls Use this when calling ServiceHandler methods to bypass HTTP/auth middleware

func (*TestHarness) Cleanup

func (h *TestHarness) Cleanup()

func (*TestHarness) GetMockK8sClient

func (h *TestHarness) GetMockK8sClient() *k8sclient.MockK8SClient

func (*TestHarness) RestartAgent

func (h *TestHarness) RestartAgent()

func (*TestHarness) StartAgent

func (h *TestHarness) StartAgent()

func (*TestHarness) StopAgent

func (h *TestHarness) StopAgent()

type TestHarnessOption added in v1.0.0

type TestHarnessOption func(h *TestHarness)

func WithAgentAudit added in v1.0.0

func WithAgentAudit() TestHarnessOption

WithAgentAudit enables the agent's audit logging when the harness starts the agent. Note: Audit logging is enabled by default, so this option is primarily for test clarity.

func WithAgentMetrics added in v1.0.0

func WithAgentMetrics() TestHarnessOption

WithAgentMetrics enables the agent's Prometheus metrics endpoint when the harness starts the agent.

func WithAgentPprof added in v1.0.0

func WithAgentPprof() TestHarnessOption

WithAgentPprof enables the agent's pprof HTTP server when the harness starts the agent.

func WithRedis added in v1.2.0

func WithRedis(host string, port uint, password domain.SecureString) TestHarnessOption

WithRedis sets the Redis connection parameters for the test harness. This is required for parallel test execution where each suite has its own ephemeral Redis. Call testdb.CreateTestRedis() in BeforeSuite and pass the connection params here.

func WithVulnerabilityEnabled added in v1.2.0

func WithVulnerabilityEnabled() TestHarnessOption

WithVulnerabilityEnabled enables the vulnerability feature endpoints for the service handler created by NewTestHarness.

func WithoutAutoStartAgent added in v1.2.0

func WithoutAutoStartAgent() TestHarnessOption

Directories

Path Synopsis
Package containers provides shared testcontainers runtime setup (Podman/Docker socket, Ryuk, API version) for integration preflight and e2e auxiliary services.
Package containers provides shared testcontainers runtime setup (Podman/Docker socket, Ryuk, API version) for integration preflight and e2e auxiliary services.
e2e
vm

Jump to

Keyboard shortcuts

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