tests

package
v1.22.5-rc2 Latest Latest
Warning

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

Go to latest
Published: Feb 22, 2024 License: MIT Imports: 89 Imported by: 0

Documentation

Index

Constants

View Source
const NamespaceCacheRefreshInterval = time.Second

Variables

View Source
var TestFlags struct {
	FrontendAddr                  string
	FrontendHTTPAddr              string
	PersistenceType               string
	PersistenceDriver             string
	TestClusterConfigFile         string
	PersistenceFaultInjectionRate float64
}

TestFlags contains the feature flags for integration tests

Functions

func NewContext

func NewContext() context.Context

NewContext create new context with default timeout 90 seconds.

func NewFrontendClient

func NewFrontendClient(connection *grpc.ClientConn) workflowservice.WorkflowServiceClient

NewFrontendClient creates a client to temporal frontend client

func WithDropTask added in v1.22.1

func WithDropTask(o *PollAndProcessWorkflowTaskOptions)

func WithDumpHistory added in v1.22.1

func WithDumpHistory(o *PollAndProcessWorkflowTaskOptions)

func WithForceNewWorkflowTask added in v1.22.1

func WithForceNewWorkflowTask(o *PollAndProcessWorkflowTaskOptions)

func WithNoDumpCommands added in v1.22.1

func WithNoDumpCommands(o *PollAndProcessWorkflowTaskOptions)

func WithPollSticky added in v1.22.1

func WithPollSticky(o *PollAndProcessWorkflowTaskOptions)

func WithRespondSticky added in v1.22.1

func WithRespondSticky(o *PollAndProcessWorkflowTaskOptions)

Types

type AdminClient

type AdminClient interface {
	adminservice.AdminServiceClient
}

AdminClient is the interface exposed by admin service client

func NewAdminClient

func NewAdminClient(connection *grpc.ClientConn) AdminClient

NewAdminClient creates a client to temporal admin client

type ArchiverBase

type ArchiverBase struct {
	// contains filtered or unexported fields
}

ArchiverBase is a base struct for archiver provider being used in integration tests

type FrontendClient

type FrontendClient interface {
	workflowservice.WorkflowServiceClient
}

FrontendClient is the interface exposed by frontend service client

type HistoryClient

type HistoryClient interface {
	historyservice.HistoryServiceClient
}

HistoryClient is the interface exposed by history service client

func NewHistoryClient

func NewHistoryClient(connection *grpc.ClientConn) HistoryClient

NewHistoryClient creates a client to temporal history service client

type HistoryConfig

type HistoryConfig struct {
	NumHistoryShards           int32
	NumHistoryHosts            int
	HistoryCountLimitError     int
	HistoryCountLimitWarn      int
	BlobSizeLimitError         int
	BlobSizeLimitWarn          int
	MutableStateSizeLimitError int
	MutableStateSizeLimitWarn  int
}

HistoryConfig contains configs for history service

type IntegrationBase

type IntegrationBase struct {
	suite.Suite

	Logger log.Logger
	// contains filtered or unexported fields
}

IntegrationBase is a base struct for integration tests

func (*IntegrationBase) DurationNear

func (s *IntegrationBase) DurationNear(value, target, tolerance time.Duration)

func (*IntegrationBase) EqualHistory

func (s *IntegrationBase) EqualHistory(expectedHistory string, actualHistory *historypb.History)

func (*IntegrationBase) EqualHistoryEvents

func (s *IntegrationBase) EqualHistoryEvents(expectedHistory string, actualHistoryEvents []*historypb.HistoryEvent)

type PollAndProcessWorkflowTaskOptionFunc added in v1.22.1

type PollAndProcessWorkflowTaskOptionFunc func(*PollAndProcessWorkflowTaskOptions)

func WithExpectedAttemptCount added in v1.22.1

func WithExpectedAttemptCount(c int) PollAndProcessWorkflowTaskOptionFunc

func WithQueryResult added in v1.22.1

func WithRetries added in v1.22.1

type PollAndProcessWorkflowTaskOptions added in v1.22.1

type PollAndProcessWorkflowTaskOptions struct {
	DumpHistory          bool
	DumpCommands         bool
	DropTask             bool
	PollSticky           bool
	RespondSticky        bool
	ExpectedAttemptCount int
	Retries              int
	ForceNewWorkflowTask bool
	QueryResult          *querypb.WorkflowQueryResult
}

type PollAndProcessWorkflowTaskResponse added in v1.22.1

type PollAndProcessWorkflowTaskResponse struct {
	IsQueryTask bool
	NewTask     *workflowservice.RespondWorkflowTaskCompletedResponse
}

type SearchAttributeTestMapper

type SearchAttributeTestMapper struct{}

func NewSearchAttributeTestMapper

func NewSearchAttributeTestMapper() *SearchAttributeTestMapper

func (*SearchAttributeTestMapper) GetAlias

func (t *SearchAttributeTestMapper) GetAlias(fieldName string, namespace string) (string, error)

func (*SearchAttributeTestMapper) GetFieldName

func (t *SearchAttributeTestMapper) GetFieldName(alias string, namespace string) (string, error)

type TaskPoller

type TaskPoller struct {
	Engine                       FrontendClient
	Namespace                    string
	TaskQueue                    *taskqueuepb.TaskQueue
	StickyTaskQueue              *taskqueuepb.TaskQueue
	StickyScheduleToStartTimeout time.Duration
	Identity                     string
	WorkflowTaskHandler          workflowTaskHandler
	ActivityTaskHandler          activityTaskHandler
	QueryHandler                 queryHandler
	MessageHandler               messageHandler
	Logger                       log.Logger
	T                            *testing.T
}

TaskPoller is used in integration tests to poll workflow or activity task queues.

func (*TaskPoller) HandlePartialWorkflowTask

func (p *TaskPoller) HandlePartialWorkflowTask(response *workflowservice.PollWorkflowTaskQueueResponse, forceCreateNewWorkflowTask bool) (*workflowservice.RespondWorkflowTaskCompletedResponse, error)

HandlePartialWorkflowTask for workflow task

func (*TaskPoller) PollAndProcessActivityTask

func (p *TaskPoller) PollAndProcessActivityTask(dropTask bool) error

PollAndProcessActivityTask for activity tasks

func (*TaskPoller) PollAndProcessActivityTaskWithID

func (p *TaskPoller) PollAndProcessActivityTaskWithID(dropTask bool) error

PollAndProcessActivityTaskWithID is similar to PollAndProcessActivityTask but using RespondActivityTask...ByID

func (*TaskPoller) PollAndProcessWorkflowTask

func (p *TaskPoller) PollAndProcessWorkflowTask(funcs ...PollAndProcessWorkflowTaskOptionFunc) (res PollAndProcessWorkflowTaskResponse, err error)

func (*TaskPoller) PollAndProcessWorkflowTaskWithOptions added in v1.22.1

func (p *TaskPoller) PollAndProcessWorkflowTaskWithOptions(opts *PollAndProcessWorkflowTaskOptions) (res PollAndProcessWorkflowTaskResponse, err error)

type TemporalParams

type TemporalParams struct {
	ClusterMetadataConfig            *cluster.Config
	PersistenceConfig                config.Persistence
	MetadataMgr                      persistence.MetadataManager
	ClusterMetadataManager           persistence.ClusterMetadataManager
	ShardMgr                         persistence.ShardManager
	ExecutionManager                 persistence.ExecutionManager
	TaskMgr                          persistence.TaskManager
	NamespaceReplicationQueue        persistence.NamespaceReplicationQueue
	Logger                           log.Logger
	ClusterNo                        int
	ArchiverMetadata                 carchiver.ArchivalMetadata
	ArchiverProvider                 provider.ArchiverProvider
	EnableReadHistoryFromArchival    bool
	HistoryConfig                    *HistoryConfig
	ESConfig                         *esclient.Config
	ESClient                         esclient.Client
	WorkerConfig                     *WorkerConfig
	MockAdminClient                  map[string]adminservice.AdminServiceClient
	NamespaceReplicationTaskExecutor namespace.ReplicationTaskExecutor
	SpanExporters                    []otelsdktrace.SpanExporter
	DynamicConfigOverrides           map[dynamicconfig.Key]interface{}
	TLSConfigProvider                *encryption.FixedTLSConfigProvider
	CaptureMetricsHandler            *metricstest.CaptureHandler
}

TemporalParams contains everything needed to bootstrap Temporal

type TestCluster

type TestCluster struct {
	// contains filtered or unexported fields
}

TestCluster is a base struct for integration tests

func NewCluster

func NewCluster(options *TestClusterConfig, logger log.Logger) (*TestCluster, error)

NewCluster creates and sets up the test cluster

func (*TestCluster) GetAdminClient

func (tc *TestCluster) GetAdminClient() AdminClient

GetAdminClient returns an admin client from the test cluster

func (*TestCluster) GetExecutionManager

func (tc *TestCluster) GetExecutionManager() persistence.ExecutionManager

GetExecutionManager returns an execution manager factory from the test cluster

func (*TestCluster) GetFrontendClient

func (tc *TestCluster) GetFrontendClient() FrontendClient

GetFrontendClient returns a frontend client from the test cluster

func (*TestCluster) GetHistoryClient

func (tc *TestCluster) GetHistoryClient() HistoryClient

GetHistoryClient returns a history client from the test cluster

func (*TestCluster) GetHost

func (tc *TestCluster) GetHost() *temporalImpl

func (*TestCluster) GetMatchingClient added in v1.21.0

func (tc *TestCluster) GetMatchingClient() matchingservice.MatchingServiceClient

GetMatchingClient returns a matching client from the test cluster

func (*TestCluster) GetOperatorClient

func (tc *TestCluster) GetOperatorClient() operatorservice.OperatorServiceClient

func (*TestCluster) SetFaultInjectionRate

func (tc *TestCluster) SetFaultInjectionRate(rate float64)

func (*TestCluster) TearDownCluster

func (tc *TestCluster) TearDownCluster() error

TearDownCluster tears down the test cluster

type TestClusterConfig

type TestClusterConfig struct {
	FrontendAddress        string
	EnableArchival         bool
	IsMasterCluster        bool
	ClusterNo              int
	ClusterMetadata        cluster.Config
	Persistence            persistencetests.TestBaseOptions
	HistoryConfig          *HistoryConfig
	ESConfig               *esclient.Config
	WorkerConfig           *WorkerConfig
	MockAdminClient        map[string]adminservice.AdminServiceClient
	FaultInjection         config.FaultInjection `yaml:"faultinjection"`
	DynamicConfigOverrides map[dynamicconfig.Key]interface{}
	GenerateMTLS           bool
	EnableMetricsCapture   bool
}

TestClusterConfig are config for a test cluster

func GetTestClusterConfig

func GetTestClusterConfig(configFile string) (*TestClusterConfig, error)

GetTestClusterConfig return test cluster config

type WorkerConfig

type WorkerConfig struct {
	EnableArchiver    bool
	EnableReplicator  bool
	StartWorkerAnyway bool
}

WorkerConfig is the config for enabling/disabling Temporal worker

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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