qtest

package
v0.8.8 Latest Latest
Warning

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

Go to latest
Published: Jun 28, 2023 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Overview

Package qtest contains standard testing routines for exercising various backends in similar ways.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ClientService

func ClientService(ctx context.Context, opener entroq.BackendOpener) (client *entroq.EntroQ, stop func(), err error)

ClientService starts an in-memory gRPC network service via StartService, then creates an EntroQ client that connects to it. It returns the client and a function that can be deferred for cleanup.

The opener is used by the service to connect to storage. The client always uses a grpc opener.

func EqualAllTasksOrderedSkipIDAndTime added in v0.8.4

func EqualAllTasksOrderedSkipIDAndTime(want, got []*entroq.Task) string

EqualAllTasksOrderedSkipIDAndTime returns a string diff if the order of tasks or values of tasks in two slices is not equal. The slices should also be the same length.

func EqualAllTasksUnorderedByValue added in v0.8.4

func EqualAllTasksUnorderedByValue(want, got []*entroq.Task) string

EqualAllTasksUnorderedByValue checks that all task values from want are represented in got. It assumes IDs and queues are not important. Suitable for tests that set a unique value per task, but don't have ID information. Returns a string diff if different.

func EqualAllTasksUnorderedSkipTimesAndCounters added in v0.8.4

func EqualAllTasksUnorderedSkipTimesAndCounters(want, got []*entroq.Task, opts ...cmpOpt) string

EqualAllTasksUnorderedSkipTimesAndCounters returns a diff if any non-time fields are different between unordered task lists. Sorts by ID to accomplish this.

func EqualTasksVersionIncr

func EqualTasksVersionIncr(want, got *entroq.Task, versionBump int) string

EqualTasksVersionIncr checks for equality, allowing a version increment.

func InsertWithID

func InsertWithID(ctx context.Context, t *testing.T, client *entroq.EntroQ, qPrefix string)

InsertWithID tests the ability to insert tasks with a specified ID, including errors when an existing ID is used for insertion.

func MultiWorker

func MultiWorker(ctx context.Context, t *testing.T, client *entroq.EntroQ, qPrefix string)

func QueueMatch

func QueueMatch(ctx context.Context, t *testing.T, client *entroq.EntroQ, qPrefix string)

QueueMatch tests various queue matching functions against a client.

func QueueStats

func QueueStats(ctx context.Context, t *testing.T, client *entroq.EntroQ, qPrefix string)

QueueStats checks that queue stats basically work.

func SimpleChange

func SimpleChange(ctx context.Context, t *testing.T, client *entroq.EntroQ, qPrefix string)

SimpleChange tests that changing things in the task leave most of it intact, and can handle things like queue moves.

func SimpleSequence

func SimpleSequence(ctx context.Context, t *testing.T, client *entroq.EntroQ, qPrefix string)

SimpleSequence tests some basic functionality of a task manager, over gRPC.

func SimpleWorker

func SimpleWorker(ctx context.Context, t *testing.T, client *entroq.EntroQ, qPrefix string)

SimpleWorker tests basic worker functionality while tasks are coming in and being waited on.

func TasksOmitValue

func TasksOmitValue(ctx context.Context, t *testing.T, client *entroq.EntroQ, qPrefix string)

TasksOmitValue exercises the task query where values are not desired.

func TasksWithID

func TasksWithID(ctx context.Context, t *testing.T, client *entroq.EntroQ, qPrefix string)

TasksWithID exercises the task query mechanism that allows specific task IDs to be looked up.

func TasksWithIDOnly

func TasksWithIDOnly(ctx context.Context, t *testing.T, client *entroq.EntroQ, qPrefix string)

TasksWithIDOnly tests that tasks listed by ID only (no queue) can return from multiple queues.

func WorkerDependencyHandler

func WorkerDependencyHandler(ctx context.Context, t *testing.T, client *entroq.EntroQ, qPrefix string)

WorkerDependencyHandler tests that workers with specified dependency handlers get called on dependency errors, and that upgrades to fatal errors happen appropriately.

func WorkerMoveOnError

func WorkerMoveOnError(ctx context.Context, t *testing.T, client *entroq.EntroQ, qPrefix string)

WorkerMoveOnError tests that workers that have MoveTaskError results, causing tasks to be moved instead of crashing.

func WorkerRenewal

func WorkerRenewal(ctx context.Context, t *testing.T, client *entroq.EntroQ, qPrefix string)

WorkerRenewal tests that task claims are renewed periodically for longer-running work tasks.

func WorkerRetryOnError

func WorkerRetryOnError(ctx context.Context, t *testing.T, client *entroq.EntroQ, qPrefix string)

WorkerRetryOnError test that workers that have RetryTaskError results increment attempts and set the error properly. It also checks that after max attempts, things get moved.

Types

type Dialer

type Dialer func() (net.Conn, error)

Dialer returns a net connection.

func StartService

func StartService(ctx context.Context, opener entroq.BackendOpener) (*grpc.Server, Dialer, error)

StartService starts an in-memory gRPC network service and returns a function for creating client connections to it.

type Tester

type Tester func(ctx context.Context, t *testing.T, client *entroq.EntroQ, qPrefix string)

Tester runs a test helper, all of which these test functions are.

Jump to

Keyboard shortcuts

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