luci: go.chromium.org/luci/logdog/appengine/coordinator/coordinatorTest Index | Files

package coordinatorTest

import "go.chromium.org/luci/logdog/appengine/coordinator/coordinatorTest"

Index

Package Files

archival.go context.go flag.go gs.go logStream.go service.go storage.go

Constants

const AllAccessProject = "proj-foo"

AllAccessProject is the project name that can be used to get a full-access project (i.e. unauthenticated users have both R and W permissions).

func TestSecret Uses

func TestSecret() types.PrefixSecret

TestSecret returns a testing types.StreamPrefix.

func WithProjectNamespace Uses

func WithProjectNamespace(c context.Context, proj types.ProjectName, f func(context.Context))

WithProjectNamespace runs f in proj's namespace, bypassing authentication checks.

type ArchivalPublisher Uses

type ArchivalPublisher struct {
    sync.Mutex

    // Err, if not nil, is the error returned by Publish.
    Err error
    // contains filtered or unexported fields
}

ArchivalPublisher is a testing implementation of a coordinator.ArchivalPublisher. It records which archival tasks were scheduled and offers accessors to facilitate test assertions.

func (*ArchivalPublisher) Clear Uses

func (ap *ArchivalPublisher) Clear()

Clear clears recorded tasks.

func (*ArchivalPublisher) Close Uses

func (ap *ArchivalPublisher) Close() error

func (*ArchivalPublisher) Hashes Uses

func (ap *ArchivalPublisher) Hashes() []string

Hashes returns a sorted list of the stream hashes that have had archival tasks submitted.

func (*ArchivalPublisher) NewPublishIndex Uses

func (ap *ArchivalPublisher) NewPublishIndex() uint64

NewPublishIndex implements coordinator.ArchivalPublisher.

func (*ArchivalPublisher) Publish Uses

func (ap *ArchivalPublisher) Publish(c context.Context, at *logdog.ArchiveTask) error

Publish implements coordinator.ArchivalPublisher.

func (*ArchivalPublisher) Tasks Uses

func (ap *ArchivalPublisher) Tasks() []*logdog.ArchiveTask

Tasks returns the dispatched archival tasks in the order in which they were dispatched.

type ArchivalStorage Uses

type ArchivalStorage struct {
    // Storage is the base (archive) Storage instance.
    storage.Storage

    // Opts is the set of archival options that the Storage was instantiated with.
    Opts archive.Options
    // contains filtered or unexported fields
}

ArchivalStorage is a bound GSClient-backed Storage instance.

func (*ArchivalStorage) Close Uses

func (st *ArchivalStorage) Close()

Close implements storage.Storage.

func (*ArchivalStorage) GetSignedURLs Uses

func (st *ArchivalStorage) GetSignedURLs(c context.Context, req *coordinator.URLSigningRequest) (
    *coordinator.URLSigningResponse, error)

GetSignedURLs implements coordinator.SigningStorage.

type BigTableStorage Uses

type BigTableStorage struct {
    // Testing is the base in-memory BigTable instance that is backing this
    // Storage.
    bigtable.Testing
    // contains filtered or unexported fields
}

BigTableStorage is a bound BigTable-backed Storage instance.

func (*BigTableStorage) Close Uses

func (st *BigTableStorage) Close()

Close implements storage.Storage.

func (*BigTableStorage) Config Uses

func (st *BigTableStorage) Config(context.Context, storage.Config) error

Config implements storage.Storage.

func (*BigTableStorage) GetSignedURLs Uses

func (st *BigTableStorage) GetSignedURLs(context.Context, *coordinator.URLSigningRequest) (
    *coordinator.URLSigningResponse, error)

GetSignedURLs implements coordinator.Storage.

type Environment Uses

type Environment struct {
    // Tumble is the Tumble testing instance.
    Tumble tumble.Testing

    // Clock is the installed test clock instance.
    Clock testclock.TestClock

    // AuthState is the fake authentication state.
    AuthState authtest.FakeState

    // Config is the luci-config configuration map that is installed.
    Config map[config.Set]memory.Files

    // Services is the set of installed Coordinator services.
    Services Services

    // BigTable in-memory testing instance.
    BigTable bigtable.Testing
    // GSClient is the test GSClient instance installed (by default) into
    // Services.
    GSClient GSClient

    // ArchivalPublisher is the test ArchivalPublisher instance installed (by
    // default) into Services.
    ArchivalPublisher ArchivalPublisher

    // StorageCache is the default storage cache instance.
    StorageCache StorageCache
}

Environment contains all of the testing facilities that are installed into the Context.

func Install Uses

func Install(useRealIndex bool) (context.Context, *Environment)

Install creates a testing Context and installs common test facilities into it, returning the Environment to which they're bound.

If useRealIndex is true, this will attempt to load the 'index.yaml' file for logdog (but this is loaded from a relative path, so is only really good for the 'coordinator' package). Otherwise this will turn on datastore's automatic indexing functionality.

func (*Environment) ClearCoordinatorConfig Uses

func (e *Environment) ClearCoordinatorConfig(c context.Context)

ClearCoordinatorConfig removes the Coordinator configuration entry, simulating a missing config.

func (*Environment) IterateTumbleAll Uses

func (e *Environment) IterateTumbleAll(c context.Context)

IterateTumbleAll iterates all Tumble instances across all namespaces.

func (*Environment) JoinGroup Uses

func (e *Environment) JoinGroup(g string)

JoinGroup adds the named group the to the list of groups for the current identity.

func (*Environment) LeaveAllGroups Uses

func (e *Environment) LeaveAllGroups()

LeaveAllGroups clears all auth groups that the user is currently a member of.

func (*Environment) LogIn Uses

func (e *Environment) LogIn()

LogIn installs an testing identity into the testing auth state.

func (*Environment) ModProjectConfig Uses

func (e *Environment) ModProjectConfig(c context.Context, proj types.ProjectName, fn func(*svcconfig.ProjectConfig))

ModProjectConfig loads the current configuration for the named project, invokes the callback with its contents, and writes the result back to config.

func (*Environment) ModServiceConfig Uses

func (e *Environment) ModServiceConfig(c context.Context, fn func(*svcconfig.Config))

ModServiceConfig loads the current service configuration, invokes the callback with its contents, and writes the result back to config.

type GSClient Uses

type GSClient map[gs.Path][]byte

GSClient is a testing Google Storage client implementation.

func (GSClient) Attrs Uses

func (c GSClient) Attrs(path gs.Path) (*storage.ObjectAttrs, error)

Attrs implements gs.Client.

func (GSClient) Close Uses

func (c GSClient) Close() error

Close implements gs.Client.

func (GSClient) Delete Uses

func (c GSClient) Delete(gs.Path) error

Delete implements gs.Client.

func (GSClient) Get Uses

func (c GSClient) Get(path gs.Path) []byte

Get retrieves the data at the specific path.

func (GSClient) NewReader Uses

func (c GSClient) NewReader(path gs.Path, offset int64, length int64) (io.ReadCloser, error)

NewReader implements gs.Client.

func (GSClient) NewWriter Uses

func (c GSClient) NewWriter(gs.Path) (gs.Writer, error)

NewWriter implements gs.Client.

func (GSClient) Put Uses

func (c GSClient) Put(path gs.Path, d []byte)

Put sets the data at a given path.

func (GSClient) Rename Uses

func (c GSClient) Rename(gs.Path, gs.Path) error

Rename implements gs.Client.

type Services Uses

type Services struct {
    // C, if not nil, will be used to get the return values for Config, overriding
    // local static members.
    C   func() (*config.Config, error)

    // PC, if not nil, will be used to get the return values for ProjectConfig,
    // overriding local static members.
    PC  func() (*svcconfig.ProjectConfig, error)

    // Storage returns an intermediate storage instance for use by this service.
    //
    // The caller must close the returned instance if successful.
    //
    // By default, this will return a *BigTableStorage instance bound to the
    // Environment's BigTable instance if the stream is not archived, and an
    // *ArchivalStorage instance bound to this Environment's GSClient instance
    // if the stream is archived.
    ST  func(*coordinator.LogStreamState) (coordinator.SigningStorage, error)

    // ArchivalPublisher returns an ArchivalPublisher instance.
    AP  func() (coordinator.ArchivalPublisher, error)
}

Services is a testing stub for a coordinator.Services instance that allows the user to configure the various services that are returned.

func (*Services) ArchivalPublisher Uses

func (s *Services) ArchivalPublisher(context.Context) (coordinator.ArchivalPublisher, error)

ArchivalPublisher implements coordinator.Services.

func (*Services) Config Uses

func (s *Services) Config(c context.Context) (*config.Config, error)

Config implements coordinator.Services.

func (*Services) ProjectConfig Uses

func (s *Services) ProjectConfig(c context.Context, project types.ProjectName) (*svcconfig.ProjectConfig, error)

ProjectConfig implements coordinator.Services.

func (*Services) StorageForStream Uses

func (s *Services) StorageForStream(c context.Context, lst *coordinator.LogStreamState) (coordinator.SigningStorage, error)

StorageForStream implements coordinator.Services.

type StorageCache Uses

type StorageCache struct {
    Base storage.Cache
    // contains filtered or unexported fields
}

StorageCache wraps the default storage cache instance, adding tracking information that is useful for testing.

func (*StorageCache) Clear Uses

func (sc *StorageCache) Clear()

Clear clears the stats for this cache instance.

func (*StorageCache) Get Uses

func (sc *StorageCache) Get(c context.Context, key storage.CacheKey) ([]byte, bool)

Get implements storage.Cache.

func (*StorageCache) Put Uses

func (sc *StorageCache) Put(c context.Context, key storage.CacheKey, v []byte, exp time.Duration)

Put implements storage.Cache.

func (*StorageCache) Stats Uses

func (sc *StorageCache) Stats() StorageCacheStats

Stats returns the stats for this cache instance.

type StorageCacheStats Uses

type StorageCacheStats struct {
    Puts   int
    Hits   int
    Misses int
}

StorageCacheStats expose stats for a StorageCache instance.

type TestStream Uses

type TestStream struct {
    // Project is the project name for this stream.
    Project types.ProjectName
    // Path is the path of this stream.
    Path types.StreamPath

    // Desc is the log stream descriptor.
    Desc *logpb.LogStreamDescriptor

    // Prefix is the Coordinator LogPrefix entity.
    Prefix *coordinator.LogPrefix
    // Prefix is the Coordinator LogStreamState entity.
    State *coordinator.LogStreamState
    // Prefix is the Coordinator LogStream entity.
    Stream *coordinator.LogStream
}

TestStream returns a testing stream.

func MakeStream Uses

func MakeStream(c context.Context, project types.ProjectName, path types.StreamPath) *TestStream

MakeStream builds a new TestStream with the supplied parameters.

func (*TestStream) DescBytes Uses

func (ts *TestStream) DescBytes() []byte

DescBytes returns the marshalled descriptor bytes.

func (*TestStream) Get Uses

func (ts *TestStream) Get(c context.Context) (err error)

Get reloads all of the entities for this TestStream.

func (*TestStream) LogEntry Uses

func (ts *TestStream) LogEntry(c context.Context, i int) *logpb.LogEntry

LogEntry generates a generic testing log entry for this stream with the specific log stream index.

func (*TestStream) Put Uses

func (ts *TestStream) Put(c context.Context) (err error)

Put adds all of the entities for this TestStream to the datastore.

func (*TestStream) Reload Uses

func (ts *TestStream) Reload(c context.Context)

Reload loads derived fields from their base fields.

func (*TestStream) WithProjectNamespace Uses

func (ts *TestStream) WithProjectNamespace(c context.Context, f func(context.Context))

WithProjectNamespace runs f in proj's namespace, bypassing authentication checks.

Package coordinatorTest imports 47 packages (graph) and is imported by 2 packages. Updated 2018-12-17. Refresh now. Tools for package owners.