testutils

package
v1.6.2-0...-b66c343 Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2024 License: AGPL-3.0 Imports: 23 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 InMemoryObjectClient

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

func NewInMemoryObjectClient

func NewInMemoryObjectClient() *InMemoryObjectClient

func (*InMemoryObjectClient) DeleteObject

func (m *InMemoryObjectClient) DeleteObject(_ context.Context, objectKey string) error

DeleteObject implements client.ObjectClient.

func (*InMemoryObjectClient) GetObject

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

GetObject implements client.ObjectClient.

func (*InMemoryObjectClient) Internals

func (m *InMemoryObjectClient) Internals() map[string][]byte

func (*InMemoryObjectClient) IsObjectNotFoundErr

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

IsObjectNotFoundErr implements client.ObjectClient.

func (*InMemoryObjectClient) IsRetryableErr

func (m *InMemoryObjectClient) IsRetryableErr(error) bool

IsRetryableErr implements client.ObjectClient.

func (*InMemoryObjectClient) List

List implements chunk.ObjectClient.

func (*InMemoryObjectClient) ObjectExists

func (m *InMemoryObjectClient) ObjectExists(_ context.Context, objectKey string) (bool, error)

ObjectExists implments client.ObjectClient

func (*InMemoryObjectClient) PutObject

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

PutObject implements client.ObjectClient.

func (*InMemoryObjectClient) Stop

func (*InMemoryObjectClient) Stop()

Stop implements client.ObjectClient

type MockStorage

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

MockStorage is a fake in-memory StorageClient.

func NewMockStorage

func NewMockStorage() *MockStorage

NewMockStorage creates a mock storage singleton MockStorage implements the interfaces client.ObjectClient, index.Client, index.TableClient, and storage.SchemaConfigProvider

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) 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) GetObjectCount

func (m *MockStorage) GetObjectCount() int

func (*MockStorage) GetSchemaConfigs

func (m *MockStorage) GetSchemaConfigs() []config.PeriodConfig

func (*MockStorage) GetSortedObjectKeys

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

func (*MockStorage) IsChunkNotFoundErr

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

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) 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