shared

package
v0.3.5 Latest Latest
Warning

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

Go to latest
Published: Feb 11, 2022 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddAuthFlags

func AddAuthFlags(fs *flag.FlagSet) func() (*azservicebus.Client, *admin.Client, error)

AddAuthFlags adds the flags needed for authenticating to Service Bus. Returns a function that can be called after the flags have been parsed, which will create the an *azservicebus.Client.

func ConstantlyUpdateQueue

func ConstantlyUpdateQueue(ctx context.Context, adminClient *admin.Client, queue string, updateInterval time.Duration) error

ConstantlyUpdateQueue updates queue, changing the MaxDeliveryCount properly between 11 and 10, every `updateInterval` This will cause Service Bus to issue force-detaches to our links, allowing us to exercise our recovery logic.

func ForceQueueDetach added in v0.3.3

func ForceQueueDetach(ctx context.Context, adminClient *admin.Client, queue string) error

func LoadEnvironment

func LoadEnvironment() error

LoadEnvironment loads an .env file. If the env var `ENV_FILE` exists, we assume the value is a path to an .env file Otherwise we fall back to loading from the current directory.

func MustCreateAutoDeletingQueue

func MustCreateAutoDeletingQueue(sc *StressContext, queueName string, qp *admin.QueueProperties)

MustCreateAutoDeletingQueue creates a queue that will auto-delete 10 minutes after activity has ceased.

func MustCreateSubscriptions

func MustCreateSubscriptions(sc *StressContext, topicName string, subscriptionNames []string) func()

func MustGenerateMessages

func MustGenerateMessages(sc *StressContext, sender *azservicebus.Sender, messageLimit int, numExtraBytes int, stats *Stats)

func NewCtrlCContext

func NewCtrlCContext() (context.Context, context.CancelFunc)

NewCtrlCContext creates a context that cancels if the user hits ctrl+c.

Types

type Stats

type Stats struct {
	Sent     int32
	Received int32
	Errors   int32
	// contains filtered or unexported fields
}

func NewStats

func NewStats(name string) *Stats

func (*Stats) AddError

func (s *Stats) AddError(reason string, err error)

func (*Stats) AddReceived

func (s *Stats) AddReceived(add int32)

func (*Stats) AddSent

func (s *Stats) AddSent(add int32)

func (*Stats) String

func (s *Stats) String() string

type StreamingMessageBatch

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

func NewStreamingMessageBatch

func NewStreamingMessageBatch(ctx context.Context, sender internalBatchSender, stats *Stats) (*StreamingMessageBatch, error)

func (*StreamingMessageBatch) Add

Add appends to the current batch. If it's full it'll send it, allocate a new one.

func (*StreamingMessageBatch) Close

func (sb *StreamingMessageBatch) Close(ctx context.Context) error

Close sends any messages currently held in our batch.

type StressContext

type StressContext struct {
	appinsights.TelemetryClient

	context.Context

	// TestRunID represents the test run and can be used to tie into other container metrics generated within the test cluster.
	TestRunID string

	// Nano is the nanoseconds start time for the stress test run
	Nano string

	// ConnectionString represents the value of the environment variable SERVICEBUS_CONNECTION_STRING.
	ConnectionString string
	// contains filtered or unexported fields
}

StressContext holds onto some common useful state for stress tests, including some simple stats tracking, a telemetry client and a context that represents the lifetime of the test itself (and will be cancelled if the user quits out of the stress)

func MustCreateStressContext

func MustCreateStressContext(testName string) *StressContext

func (*StressContext) Assert added in v0.3.4

func (tracker *StressContext) Assert(condition bool, message string)

func (*StressContext) End

func (sc *StressContext) End()

func (*StressContext) LogIfFailed

func (sc *StressContext) LogIfFailed(message string, err error, stats *Stats)

func (StressContext) NewStat

func (sp StressContext) NewStat(name string) *Stats

NewStat creates a new stat with `name` and adds it to the list of statistics that will be printed and reported regularly.

func (*StressContext) PanicOnError

func (tracker *StressContext) PanicOnError(message string, err error)

PanicOnError logs, sends telemetry and then closes on error

func (StressContext) PrintStats added in v0.3.4

func (sp StressContext) PrintStats()

func (*StressContext) Start

func (sc *StressContext) Start(entityName string, attributes map[string]string)

type TestContext

type TestContext struct {
	*StressContext
	Client *azservicebus.Client
}

func (TestContext) NewStat

func (sp TestContext) NewStat(name string) *Stats

NewStat creates a new stat with `name` and adds it to the list of statistics that will be printed and reported regularly.

func (TestContext) PrintStats added in v0.3.4

func (sp TestContext) PrintStats()

Jump to

Keyboard shortcuts

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