testutils

package
v2.5.2 Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2022 License: AGPL-3.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MockStorageModeReadWrite = 0
	MockStorageModeReadOnly  = 1
	MockStorageModeWriteOnly = 2
)

Variables

This section is empty.

Functions

func CreateChunks

func CreateChunks(scfg config.SchemaConfig, startIndex, batchSize int, from model.Time, through model.Time) ([]string, []chunk.Chunk, error)

CreateChunks creates some chunks for testing

func DefaultSchemaConfig

func DefaultSchemaConfig(kind string) config.SchemaConfig

DefaultSchemaConfig returns default schema for use in test fixtures

func DummyChunkFor

func DummyChunkFor(from, through model.Time, metric labels.Labels) chunk.Chunk

func ResetMockStorage

func ResetMockStorage()

func SchemaConfig

func SchemaConfig(store, schema string, from model.Time) config.SchemaConfig

func Setup

func Setup(fixture Fixture, tableName string) (index.Client, chunkclient.Client, io.Closer, error)

Setup a fixture with initial tables

Types

type CloserFunc

type CloserFunc func() error

CloserFunc is to io.Closer as http.HandlerFunc is to http.Handler.

func (CloserFunc) Close

func (f CloserFunc) Close() error

Close implements io.Closer.

type Fixture

type Fixture interface {
	Name() string
	Clients() (index.Client, chunkclient.Client, index.TableClient, config.SchemaConfig, io.Closer, error)
}

Fixture type for per-backend testing.

type MockStorage

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

MockStorage is a fake in-memory StorageClient.

func NewMockStorage

func NewMockStorage() *MockStorage

NewMockStorage creates a new MockStorage.

func (*MockStorage) BatchWrite

func (m *MockStorage) BatchWrite(ctx context.Context, batch index.WriteBatch) error

BatchWrite implements StorageClient.

func (*MockStorage) CreateTable

func (m *MockStorage) CreateTable(_ context.Context, desc config.TableDesc) error

CreateTable implements StorageClient.

func (*MockStorage) DeleteChunk

func (m *MockStorage) DeleteChunk(ctx context.Context, userID, chunkID string) error

DeleteChunk implements StorageClient.

func (*MockStorage) DeleteObject

func (m *MockStorage) DeleteObject(ctx context.Context, objectKey string) error

func (*MockStorage) DeleteTable

func (m *MockStorage) DeleteTable(_ context.Context, name string) error

DeleteTable implements StorageClient.

func (*MockStorage) DescribeTable

func (m *MockStorage) DescribeTable(_ context.Context, name string) (desc config.TableDesc, isActive bool, err error)

DescribeTable implements StorageClient.

func (*MockStorage) GetChunks

func (m *MockStorage) GetChunks(ctx context.Context, chunkSet []chunk.Chunk) ([]chunk.Chunk, error)

GetChunks implements StorageClient.

func (*MockStorage) GetObject

func (m *MockStorage) GetObject(ctx context.Context, objectKey string) (io.ReadCloser, int64, error)

func (*MockStorage) GetObjectCount

func (m *MockStorage) GetObjectCount() int

func (*MockStorage) GetSortedObjectKeys

func (m *MockStorage) GetSortedObjectKeys() []string

func (*MockStorage) IsChunkNotFoundErr

func (m *MockStorage) IsChunkNotFoundErr(err error) bool

func (*MockStorage) IsObjectNotFoundErr

func (m *MockStorage) IsObjectNotFoundErr(err error) bool

func (*MockStorage) List

func (m *MockStorage) List(ctx context.Context, prefix, delimiter string) ([]client.StorageObject, []client.StorageCommonPrefix, error)

List implements chunk.ObjectClient.

func (*MockStorage) ListTables

func (m *MockStorage) ListTables(_ context.Context) ([]string, error)

ListTables implements StorageClient.

func (*MockStorage) NewWriteBatch

func (m *MockStorage) NewWriteBatch() index.WriteBatch

NewWriteBatch implements StorageClient.

func (*MockStorage) PutChunks

func (m *MockStorage) PutChunks(_ context.Context, chunks []chunk.Chunk) error

PutChunks implements StorageClient.

func (*MockStorage) PutObject

func (m *MockStorage) PutObject(ctx context.Context, objectKey string, object io.ReadSeeker) error

func (*MockStorage) QueryPages

func (m *MockStorage) QueryPages(ctx context.Context, queries []index.Query, callback index.QueryPagesCallback) error

QueryPages implements StorageClient.

func (*MockStorage) SetMode

func (m *MockStorage) SetMode(mode MockStorageMode)

func (*MockStorage) Stop

func (*MockStorage) Stop()

Stop doesn't do anything.

func (*MockStorage) UpdateTable

func (m *MockStorage) UpdateTable(_ context.Context, _, desc config.TableDesc) error

UpdateTable implements StorageClient.

type MockStorageMode

type MockStorageMode int

Jump to

Keyboard shortcuts

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