Documentation
¶
Index ¶
- func ReadTestdata(t *testing.T, filename string) []byte
- func TestdataPath(t *testing.T, filename string) string
- type APIClient
- type Agent
- type AgentOption
- type CmdTest
- type Command
- type Contains
- type Coordinator
- type DAG
- func (d *DAG) Agent(opts ...AgentOption) *Agent
- func (d *DAG) AssertCurrentStatus(t *testing.T, expected core.Status)
- func (d *DAG) AssertDAGRunCount(t *testing.T, expected int)
- func (d *DAG) AssertLatestStatus(t *testing.T, expected core.Status)
- func (d *DAG) AssertOutputs(t *testing.T, outputs map[string]any)
- type Helper
- func (h Helper) Cleanup()
- func (h Helper) CreateDAGFile(t *testing.T, dir string, name string, yamlContent []byte) string
- func (h Helper) DAG(t *testing.T, yamlContent string) DAG
- func (h Helper) DAGExpectError(t *testing.T, name string, expectedErr string)
- func (h Helper) TempFile(t *testing.T, name string, data []byte) string
- type HelperOption
- func WithCaptureLoggingOutput() HelperOption
- func WithConfigMutator(mutator func(*config.Config)) HelperOption
- func WithCoordinatorConfig(host string, port int) HelperOption
- func WithDAGsDir(dir string) HelperOption
- func WithSchedulerTestDAGs(dagsDir string) HelperOption
- func WithServerConfig(cfg *config.Server) HelperOption
- type NotEmpty
- type Options
- type Request
- type Response
- type Scheduler
- type Server
- type SyncBuffer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ReadTestdata ¶ added in v1.16.1
ReadTestdata reads the content of a testdata file.
Types ¶
type APIClient ¶ added in v1.17.0
type APIClient struct {
// contains filtered or unexported fields
}
APIClient handles HTTP requests to the test server
type Agent ¶ added in v1.16.0
func (*Agent) RunCheckErr ¶ added in v1.16.0
func (*Agent) RunSuccess ¶ added in v1.16.0
type AgentOption ¶ added in v1.16.0
type AgentOption func(*Agent)
func WithAgentOptions ¶ added in v1.16.0
func WithAgentOptions(options agent.Options) AgentOption
func WithDAGRunID ¶ added in v1.17.0
func WithDAGRunID(dagRunID string) AgentOption
type CmdTest ¶ added in v1.16.4
type CmdTest struct {
Name string // Name of the test.
Args []string // Arguments to pass to the command.
ExpectedOut []string // Expected output to be present in the standard output / error.
}
CmdTest is a helper struct to test commands.
type Command ¶ added in v1.17.0
type Command struct {
Helper
}
Command is a helper struct to test commands.
func SetupCommand ¶ added in v1.16.4
func SetupCommand(t *testing.T, opts ...HelperOption) Command
func (Command) CreateDAGFile ¶ added in v1.18.0
CreateDAGFile creates a DAG file in the DAGsDir for command tests
func (Command) RunCommand ¶ added in v1.17.0
type Coordinator ¶ added in v1.18.0
type Coordinator struct {
Helper
// contains filtered or unexported fields
}
Coordinator represents a test gRPC coordinator instance
func SetupCoordinator ¶ added in v1.18.0
func SetupCoordinator(t *testing.T, opts ...HelperOption) *Coordinator
SetupCoordinator creates and starts a test coordinator instance
func (*Coordinator) Address ¶ added in v1.18.0
func (c *Coordinator) Address() string
Address returns the address the coordinator is listening on
func (*Coordinator) DispatchTask ¶ added in v1.18.0
func (c *Coordinator) DispatchTask(t *testing.T, task *coordinatorv1.Task) error
DispatchTask dispatches a task to a waiting worker
func (*Coordinator) GetCoordinatorClient ¶ added in v1.18.0
func (c *Coordinator) GetCoordinatorClient(t *testing.T) coordinator.Client
GetCoordinatorClient returns a coordinator client for this coordinator
func (*Coordinator) Port ¶ added in v1.18.0
func (c *Coordinator) Port() int
Port returns the port the coordinator is listening on
func (*Coordinator) Stop ¶ added in v1.18.0
func (c *Coordinator) Stop() error
Stop gracefully shuts down the coordinator
type DAG ¶ added in v1.16.0
func (*DAG) Agent ¶ added in v1.16.0
func (d *DAG) Agent(opts ...AgentOption) *Agent
func (*DAG) AssertCurrentStatus ¶ added in v1.16.0
func (*DAG) AssertDAGRunCount ¶ added in v1.17.0
func (*DAG) AssertLatestStatus ¶ added in v1.16.0
func (*DAG) AssertOutputs ¶ added in v1.16.1
AssertOutputs checks the given outputs against the actual outputs of the DAG Note that this function does not respect dependencies between nodes making the outputs with the same key indeterministic
type Helper ¶ added in v1.16.0
type Helper struct {
Context context.Context
Cancel context.CancelFunc
Config *config.Config
LoggingOutput *SyncBuffer
DAGStore execution.DAGStore
DAGRunStore execution.DAGRunStore
DAGRunMgr runtimepkg.Manager
ProcStore execution.ProcStore
QueueStore execution.QueueStore
ServiceRegistry execution.ServiceRegistry
SubCmdBuilder *runtimepkg.SubCmdBuilder
// contains filtered or unexported fields
}
Helper provides test utilities and configuration
func Setup ¶
func Setup(t *testing.T, opts ...HelperOption) Helper
Setup creates and returns a Helper preconfigured for tests.
Setup prepares an isolated test environment: it creates a temporary DAGU_HOME, writes a minimal config file, initializes stores and a runtime manager, sets key environment variables (e.g. DEBUG, CI, TZ, DAGU_EXECUTABLE, DAGU_CONFIG, SHELL), installs a cancellable context, and registers cleanup to restore the working directory and remove the temp directory. Use the returned Helper to interact with the test runtime and stores.
func (Helper) Cleanup ¶ added in v1.16.0
func (h Helper) Cleanup()
Cleanup removes temporary test directories
func (Helper) CreateDAGFile ¶ added in v1.18.0
CreateDAGFile creates a DAG file in a given directory for tests that need separate DAG files
func (Helper) DAGExpectError ¶ added in v1.16.1
type HelperOption ¶ added in v1.17.0
type HelperOption func(*Options)
HelperOption defines functional options for Helper
func WithCaptureLoggingOutput ¶ added in v1.16.0
func WithCaptureLoggingOutput() HelperOption
WithCaptureLoggingOutput creates a logging capture option
func WithConfigMutator ¶ added in v1.24.5
func WithConfigMutator(mutator func(*config.Config)) HelperOption
WithConfigMutator applies mutations to the loaded configuration after defaults are set.
func WithCoordinatorConfig ¶ added in v1.18.0
func WithCoordinatorConfig(host string, port int) HelperOption
WithCoordinatorConfig creates a coordinator configuration option
func WithDAGsDir ¶ added in v1.16.3
func WithDAGsDir(dir string) HelperOption
func WithSchedulerTestDAGs ¶ added in v1.18.0
func WithSchedulerTestDAGs(dagsDir string) HelperOption
WithSchedulerTestDAGs creates a scheduler option for setting up test DAGs directory
func WithServerConfig ¶ added in v1.17.0
func WithServerConfig(cfg *config.Server) HelperOption
type Request ¶ added in v1.17.0
type Request struct {
// contains filtered or unexported fields
}
Request represents an HTTP request being prepared
func (*Request) ExpectStatus ¶ added in v1.17.0
ExpectStatus sets the expected HTTP status code
func (*Request) WithBasicAuth ¶ added in v1.26.4
WithBasicAuth adds Basic authentication to the request
func (*Request) WithBearerToken ¶ added in v1.26.4
WithBearerToken adds a Bearer token to the Authorization header
func (*Request) WithHeader ¶ added in v1.26.4
WithHeader adds a header to the request
type Scheduler ¶ added in v1.18.0
type Scheduler struct {
Helper
EntryReader scheduler.EntryReader
QueueStore execution.QueueStore
CoordinatorCli execution.Dispatcher
}
Scheduler represents a test scheduler instance
func SetupScheduler ¶ added in v1.18.0
func SetupScheduler(t *testing.T, opts ...HelperOption) *Scheduler
SetupScheduler creates a test scheduler instance with all dependencies
func (*Scheduler) NewSchedulerInstance ¶ added in v1.18.0
NewSchedulerInstance creates a new scheduler instance for testing
type Server ¶ added in v1.17.0
type Server struct {
Helper
}
Server represents a test HTTP server instance
func SetupServer ¶ added in v1.17.0
func SetupServer(t *testing.T, opts ...HelperOption) Server
SetupServer creates and starts a test server instance
type SyncBuffer ¶ added in v1.16.0
type SyncBuffer struct {
// contains filtered or unexported fields
}
SyncBuffer provides thread-safe buffer operations
func (*SyncBuffer) String ¶ added in v1.16.0
func (b *SyncBuffer) String() string