mmrtesting

package module
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: May 15, 2024 License: MIT Imports: 13 Imported by: 1

Documentation

Index

Constants

View Source
const (
	ValueBytes       = 32
	V1MMRPrefix      = "v1/mmrs"
	V1MMRBlobNameFmt = "%016d.log"
)

XXX: TODO TenantMassifPrefix duplicated here to avoid import cycle. refactor

View Source
const (
	DefaultGeneratorTenantIdentity = "tenant/0684984b-654d-4301-ad10-a508126e187d"
)

Variables

This section is empty.

Functions

func HashWriteUint64

func HashWriteUint64(hasher hash.Hash, value uint64)

Types

type AddLeafArgs

type AddLeafArgs struct {
	Id    uint64
	AppId []byte
	Value []byte
	LogId []byte
}

AddLeafArgs is the return value of all LeafGenerator implementations. It carries just enough to successfully call AddLeafEntry on a MassifContext The leaf generator is free to decide on appropriate values

type LeafGenerator

type LeafGenerator func(tenantIdentity string, base, i uint64) AddLeafArgs

type TestCallCounter

type TestCallCounter struct {
	MethodCalls map[string]int
}

func (*TestCallCounter) IncMethodCall

func (r *TestCallCounter) IncMethodCall(name string) int

func (*TestCallCounter) MethodCallCount

func (r *TestCallCounter) MethodCallCount(name string) int

func (*TestCallCounter) Reset

func (r *TestCallCounter) Reset()

type TestConfig

type TestConfig struct {
	// We seed the RNG of the provided StartTimeMS. It is normal to force it to
	// some fixed value so that the generated data is the same from run to run.
	StartTimeMS     int64
	EventRate       int
	TestLabelPrefix string
	TenantIdentity  string // can be ""
	Container       string // can be "" defaults to TestLablePrefix
	DebugLevel      string // defaults to INFO
}

type TestContext

type TestContext struct {
	Log    logger.Logger
	Storer *azblob.Storer
	T      *testing.T
	Cfg    TestConfig
}

func NewTestContext

func NewTestContext(t *testing.T, cfg TestConfig) TestContext

func (*TestContext) DeleteBlobsByPrefix

func (c *TestContext) DeleteBlobsByPrefix(blobPrefixPath string)

func (*TestContext) GetLog

func (c *TestContext) GetLog() logger.Logger

func (*TestContext) GetStorer

func (c *TestContext) GetStorer() *azblob.Storer

func (*TestContext) NewStorer

func (c *TestContext) NewStorer() *azblob.Storer

type TestGenerator

type TestGenerator struct {
	Cfg TestGeneratorConfig
	T   *testing.T

	StartTime time.Time
	LastTime  time.Time
	// contains filtered or unexported fields
}

Create random values of various sorts for testing. Seeded so that from run to run the values can be the same. Intended for white box tests that benefit from a large volume of synthetic data.

func NewTestGenerator

func NewTestGenerator(t *testing.T, seed int64, cfg TestGeneratorConfig, leafGenerator LeafGenerator) TestGenerator

NewTestGenerator creates a deterministic, but random looking, test data generator. Given the same seed, the series of data generated on different runs is identical. This means that we generate valid values for things like uuid based identities and simulated time stamps, but the log telemetry from successive runs will be usefuly stable.

func (*TestGenerator) Float32

func (g *TestGenerator) Float32() float32

func (*TestGenerator) GenerateLeafBatch

func (g *TestGenerator) GenerateLeafBatch(tenantIdentity string, base, count uint64, gf LeafGenerator) []AddLeafArgs

func (*TestGenerator) GenerateNumberedLeafBatch

func (g *TestGenerator) GenerateNumberedLeafBatch(tenantIdentity string, base, count uint64) []AddLeafArgs

func (*TestGenerator) Intn

func (g *TestGenerator) Intn(n int) int

func (*TestGenerator) MultiWordString

func (g *TestGenerator) MultiWordString(count int) string

func (*TestGenerator) NewRandomUUID

func (g *TestGenerator) NewRandomUUID() (uuid.UUID, error)

func (*TestGenerator) NewRandomUUIDString

func (g *TestGenerator) NewRandomUUIDString(t *testing.T) string

func (*TestGenerator) NewTenantIdentity

func (g *TestGenerator) NewTenantIdentity() string

func (*TestGenerator) PadWithLeafEntries

func (c *TestGenerator) PadWithLeafEntries(data []byte, n int) []byte

func (*TestGenerator) PadWithNumberedLeaves

func (c *TestGenerator) PadWithNumberedLeaves(data []byte, first, n int) []byte

func (*TestGenerator) SinceJitter

func (g *TestGenerator) SinceJitter(lastTime time.Time) time.Time

func (*TestGenerator) SinceLastJitter

func (g *TestGenerator) SinceLastJitter(noUpdate ...bool) time.Time

func (*TestGenerator) WordList

func (g *TestGenerator) WordList(count int) []string

WordList returns a list of random words selected from the table

type TestGeneratorConfig

type TestGeneratorConfig struct {
	StartTimeMS     int64
	EventRate       int // generate events, with jitter, as though they are arriving at roughly this rate / sec
	TenantIdentity  string
	TestLabelPrefix string
}

type TestSendCallCounter

type TestSendCallCounter struct {
	TestCallCounter
}

func (*TestSendCallCounter) Close

func (*TestSendCallCounter) GetAZClient

func (s *TestSendCallCounter) GetAZClient() azbus.AZClient

func (*TestSendCallCounter) Open

func (s *TestSendCallCounter) Open() error

func (*TestSendCallCounter) Send

func (*TestSendCallCounter) String

func (s *TestSendCallCounter) String() string

Jump to

Keyboard shortcuts

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