tests

package
v1.21.6 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2024 License: MIT Imports: 85 Imported by: 0

Documentation

Index

Constants

View Source
const NamespaceCacheRefreshInterval = time.Second

Variables

View Source
var TestFlags struct {
	FrontendAddr                  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

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 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(dumpHistory bool, dropTask bool) (isQueryTask bool, err error)

PollAndProcessWorkflowTask for workflow tasks

func (*TaskPoller) PollAndProcessWorkflowTaskWithAttempt

func (p *TaskPoller) PollAndProcessWorkflowTaskWithAttempt(
	dumpHistory bool,
	dropTask bool,
	pollStickyTaskQueue bool,
	respondStickyTaskQueue bool,
	workflowTaskAttempt int32,
) (isQueryTask bool, err error)

PollAndProcessWorkflowTaskWithAttempt for workflow tasks

func (*TaskPoller) PollAndProcessWorkflowTaskWithAttemptAndRetry

func (p *TaskPoller) PollAndProcessWorkflowTaskWithAttemptAndRetry(
	dumpHistory bool,
	dropTask bool,
	pollStickyTaskQueue bool,
	respondStickyTaskQueue bool,
	workflowTaskAttempt int32,
	retryCount int,
) (isQueryTask bool, err error)

PollAndProcessWorkflowTaskWithAttemptAndRetry for workflow tasks

func (*TaskPoller) PollAndProcessWorkflowTaskWithAttemptAndRetryAndForceNewWorkflowTask

func (p *TaskPoller) PollAndProcessWorkflowTaskWithAttemptAndRetryAndForceNewWorkflowTask(
	dumpHistory bool,
	dropTask bool,
	pollStickyTaskQueue bool,
	respondStickyTaskQueue bool,
	workflowTaskAttempt int32,
	retryCount int,
	forceCreateNewWorkflowTask bool,
	queryResult *querypb.WorkflowQueryResult,
) (isQueryTask bool, newTask *workflowservice.RespondWorkflowTaskCompletedResponse, err error)

PollAndProcessWorkflowTaskWithAttemptAndRetryAndForceNewWorkflowTask for workflow tasks

func (*TaskPoller) PollAndProcessWorkflowTaskWithSticky

func (p *TaskPoller) PollAndProcessWorkflowTaskWithSticky(dumpHistory bool, dropTask bool) (isQueryTask bool, err error)

PollAndProcessWorkflowTaskWithSticky for workflow tasks

func (*TaskPoller) PollAndProcessWorkflowTaskWithoutRetry

func (p *TaskPoller) PollAndProcessWorkflowTaskWithoutRetry(dumpHistory bool, dropTask bool) (isQueryTask bool, err error)

PollAndProcessWorkflowTaskWithoutRetry for workflow tasks

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{}
}

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{}
}

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