test

package
v5.1.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Dec 11, 2019 License: BSD-3-Clause, BSD-3-Clause, BSD-3-Clause Imports: 20 Imported by: 0

README

KBFS Test

This directory houses the test harness required to execute the KBFS test language as well as the individual tests.

Libkbfs tests: go test

Fuse tests (linux, os x): go test -tags fuse

Dokan tests (windows): go test -tags dokan

Documentation

Overview

Package test is a test framework for KBFS

Index

Constants

View Source
const (
	// CtxOpID is the display name for the unique operation test ID tag.
	CtxOpID = "TID"

	// CtxOpUser is the display name for the user tag.
	CtxOpUser = "User"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type CtxTagKey

type CtxTagKey int

CtxTagKey is the type used for unique context tags

const (
	// CtxIDKey is the type of the tag for unique operation IDs.
	CtxIDKey CtxTagKey = iota

	// CtxUserKey is the type of the user tag.
	CtxUserKey
)

type Engine

type Engine interface {
	// Name returns the name of the engine.
	Name() string
	// InitTest is called by the test harness to initialize user
	// instances and set up the configuration of the test.
	// blockChange indicates the maximum size of each data block.
	// blockChangeSize indicates the maximum size the list of block
	// changes can be in each MD update, before it is written to a
	// dedicated data block instead. If blockSize or blockChangeSize
	// are zero, the engine defaults are used. bwKBps indicates a
	// bandwidth constraint to simulate to the server in kilobytes per
	// second; if zero, the engine defaults are used.  opTimeout
	// specifies a per-operation timeout; if it is more than the
	// default engine timeout, or if it is zero, it has no effect.
	InitTest(ver kbfsmd.MetadataVer, blockSize int64,
		blockChangeSize int64, batchSize int, bwKBps int,
		opTimeout time.Duration, users []kbname.NormalizedUsername,
		teams, implicitTeams teamMap, clock libkbfs.Clock,
		journal bool) map[kbname.NormalizedUsername]User
	// GetUID is called by the test harness to retrieve a user instance's UID.
	GetUID(u User) keybase1.UID
	// GetFavorites returns the set of all public or private
	// favorites, based on the given bool.
	GetFavorites(u User, t tlf.Type) (map[string]bool, error)
	// GetRootDir is called by the test harness to get a handle to a TLF from the given user's
	// perspective
	GetRootDir(u User, tlfName string, t tlf.Type, expectedCanonicalTlfName string) (dir Node, err error)
	// GetRootDirAtRevision is called by the test harness to get a
	// handle to an archived TLF from the given user's perspective, at
	// a given revision.
	GetRootDirAtRevision(
		u User, tlfName string, t tlf.Type, rev kbfsmd.Revision,
		expectedCanonicalTlfName string) (dir Node, err error)
	// GetRootDirAtTimeString is called by the test harness to get a
	// handle to an archived TLF from the given user's perspective, at
	// a given time.
	GetRootDirAtTimeString(
		u User, tlfName string, t tlf.Type, timeString string,
		expectedCanonicalTlfName string) (dir Node, err error)
	// GetRootDirAtRelTimeString is called by the test harness to get
	// a handle to an archived TLF from the given user's perspective,
	// at a given relative time from now.
	GetRootDirAtRelTimeString(
		u User, tlfName string, t tlf.Type, relTimeString string,
		expectedCanonicalTlfName string) (dir Node, err error)
	// CreateDir is called by the test harness to create a directory relative to the passed
	// parent directory for the given user.
	CreateDir(u User, parentDir Node, name string) (dir Node, err error)
	// CreateFile is called by the test harness to create a file in the given directory as
	// the given user.
	CreateFile(u User, parentDir Node, name string) (file Node, err error)
	// CreateFileExcl is called by the test harness to exclusively write to the given file as the given user.
	CreateFileExcl(u User, parentDir Node, name string) (file Node, err error)
	// CreateLink is called by the test harness to create a symlink in the given directory as
	// the given user.
	CreateLink(u User, parentDir Node, fromName string, toPath string) (err error)
	// WriteFile is called by the test harness to write to the given file as the given user.
	WriteFile(u User, file Node, data []byte, off int64, sync bool) (err error)
	// TruncateFile is called by the test harness to truncate the given file as the given user, to the given size.
	TruncateFile(u User, file Node, size uint64, sync bool) (err error)
	// RemoveDir is called by the test harness as the given user to remove a subdirectory.
	RemoveDir(u User, dir Node, name string) (err error)
	// RemoveEntry is called by the test harness as the given user to remove a directory entry.
	RemoveEntry(u User, dir Node, name string) (err error)
	// Rename is called by the test harness as the given user to rename a node.
	Rename(u User, srcDir Node, srcName string, dstDir Node, dstName string) (err error)
	// ReadFile is called by the test harness to read from the given file as the given user.
	ReadFile(u User, file Node, off int64, bs []byte) (length int, err error)
	// Lookup is called by the test harness to return a node in the given directory by
	// its name for the given user. In the case of a symlink the symPath will be set and
	// the node will be nil.
	Lookup(u User, parentDir Node, name string) (file Node, symPath string, err error)
	// GetDirChildrenTypes is called by the test harness as the given user to return a map of child nodes
	// and their type names.
	GetDirChildrenTypes(u User, parentDir Node) (children map[string]string, err error)
	// SetEx is called by the test harness as the given user to set/unset the executable bit on the
	// given file.
	SetEx(u User, file Node, ex bool) (err error)
	// SetMtime is called by the test harness as the given user to
	// set the mtime on the given file.
	SetMtime(u User, file Node, mtime time.Time) (err error)
	// GetMtime is called by the test harness as the given user to get
	// the mtime of the given file.
	GetMtime(u User, file Node) (mtime time.Time, err error)
	// GetPrevResions is called by the test harness as the given user
	// to get the previous revisions of the given file.
	GetPrevRevisions(u User, file Node) (revs data.PrevRevisions, err error)
	// SyncAll is called by the test harness as the given user to
	// flush all writes buffered in memory to disk.
	SyncAll(u User, tlfName string, t tlf.Type) (err error)

	// DisableUpdatesForTesting is called by the test harness as
	// the given user to disable updates to trigger conflict
	// conditions.
	DisableUpdatesForTesting(u User, tlfName string, t tlf.Type) (err error)
	//MakeNaïveStaller returns a NaïveStaller associated with user u for
	//stalling BlockOps or MDOps.
	MakeNaïveStaller(u User) *libkbfs.NaïveStaller
	// ReenableUpdates is called by the test harness as the given
	// user to resume updates if previously disabled for testing.
	ReenableUpdates(u User, tlfName string, t tlf.Type) (err error)
	// SyncFromServer is called by the test harness as the given user
	// to actively retrieve new metadata for a folder.
	SyncFromServer(u User, tlfName string, t tlf.Type) (err error)
	// ForceQuotaReclamation starts quota reclamation by the given
	// user in the TLF corresponding to the given node.
	ForceQuotaReclamation(u User, tlfName string, t tlf.Type) (err error)
	// AddNewAssertion makes newAssertion, which should be a
	// single assertion that doesn't already resolve to anything,
	// resolve to the same UID as oldAssertion, which should be an
	// arbitrary assertion that does already resolve to something.
	// It only applies to the given user.
	AddNewAssertion(u User, oldAssertion, newAssertion string) (err error)
	// ChangeTeamName renames a team.
	ChangeTeamName(u User, oldName, newName string) (err error)
	// Rekey rekeys the given TLF under the given user.
	Rekey(u User, tlfName string, t tlf.Type) (err error)
	// EnableJournal is called by the test harness as the given
	// user to enable journaling.
	EnableJournal(u User, tlfName string, t tlf.Type) (err error)
	// PauseJournal is called by the test harness as the given
	// user to pause journaling.
	PauseJournal(u User, tlfName string, t tlf.Type) (err error)
	// ResumeJournal is called by the test harness as the given
	// user to resume journaling.
	ResumeJournal(u User, tlfName string, t tlf.Type) (err error)
	// FlushJournal is called by the test harness as the given
	// user to wait for the journal to flush, if enabled.
	FlushJournal(u User, tlfName string, t tlf.Type) (err error)
	// UnflushedPaths called by the test harness to find out which
	// paths haven't yet been flushed from the journal.
	UnflushedPaths(u User, tlfName string, t tlf.Type) (
		paths []string, err error)
	// UserEditHistory called by the test harness to get the edit
	// history for the given user.
	UserEditHistory(u User) (history []keybase1.FSFolderEditHistory, err error)
	// DirtyPaths called by the test harness to find out which
	// paths haven't yet been flushed out of memory.
	DirtyPaths(u User, tlfName string, t tlf.Type) (paths []string, err error)
	// TogglePrefetch is called by the test harness as the given user to toggle
	// whether prefetching should be enabled
	TogglePrefetch(u User, enable bool) error
	// ForceConflict can force a stuck conflict in the given TLF.
	ForceConflict(u User, tlfName string, t tlf.Type) (err error)
	// ClearConflicts can clear the conflicts in a TLF by moving the
	// conflict view out of the way.
	ClearConflicts(u User, tlfName string, t tlf.Type) (err error)
	// Shutdown is called by the test harness when it is done with the
	// given user.
	Shutdown(u User) error
}

Engine is the interface to the filesystem to be used by the test harness. It may wrap libkbfs directly or it may wrap other users of libkbfs (e.g., libfuse).

type LibKBFS

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

LibKBFS implements the Engine interface for direct test harness usage of libkbfs.

func (*LibKBFS) AddNewAssertion

func (k *LibKBFS) AddNewAssertion(u User, oldAssertion, newAssertion string) error

AddNewAssertion implements the Engine interface.

func (*LibKBFS) ChangeTeamName

func (k *LibKBFS) ChangeTeamName(u User, oldName, newName string) error

ChangeTeamName implements the Engine interface.

func (*LibKBFS) ClearConflicts

func (k *LibKBFS) ClearConflicts(u User, tlfName string, t tlf.Type) error

ClearConflicts implements the Engine interface.

func (*LibKBFS) CreateDir

func (k *LibKBFS) CreateDir(u User, parentDir Node, name string) (dir Node, err error)

CreateDir implements the Engine interface.

func (*LibKBFS) CreateFile

func (k *LibKBFS) CreateFile(u User, parentDir Node, name string) (file Node, err error)

CreateFile implements the Engine interface.

func (*LibKBFS) CreateFileExcl

func (k *LibKBFS) CreateFileExcl(u User, parentDir Node, name string) (file Node, err error)

CreateFileExcl implements the Engine interface.

func (k *LibKBFS) CreateLink(
	u User, parentDir Node, fromName, toPath string) (err error)

CreateLink implements the Engine interface.

func (*LibKBFS) DirtyPaths

func (k *LibKBFS) DirtyPaths(u User, tlfName string, t tlf.Type) (
	[]string, error)

DirtyPaths implements the Engine interface.

func (*LibKBFS) DisableUpdatesForTesting

func (k *LibKBFS) DisableUpdatesForTesting(u User, tlfName string, t tlf.Type) (err error)

DisableUpdatesForTesting implements the Engine interface.

func (*LibKBFS) EnableJournal

func (k *LibKBFS) EnableJournal(u User, tlfName string, t tlf.Type) error

EnableJournal implements the Engine interface.

func (*LibKBFS) FlushJournal

func (k *LibKBFS) FlushJournal(u User, tlfName string, t tlf.Type) error

FlushJournal implements the Engine interface.

func (*LibKBFS) ForceConflict

func (k *LibKBFS) ForceConflict(u User, tlfName string, t tlf.Type) error

ForceConflict implements the Engine interface.

func (*LibKBFS) ForceQuotaReclamation

func (k *LibKBFS) ForceQuotaReclamation(u User, tlfName string, t tlf.Type) (err error)

ForceQuotaReclamation implements the Engine interface.

func (*LibKBFS) GetDirChildrenTypes

func (k *LibKBFS) GetDirChildrenTypes(u User, parentDir Node) (childrenTypes map[string]string, err error)

GetDirChildrenTypes implements the Engine interface.

func (*LibKBFS) GetFavorites

func (k *LibKBFS) GetFavorites(u User, t tlf.Type) (map[string]bool, error)

GetFavorites implements the Engine interface.

func (*LibKBFS) GetMtime

func (k *LibKBFS) GetMtime(u User, file Node) (mtime time.Time, err error)

GetMtime implements the Engine interface.

func (*LibKBFS) GetPrevRevisions

func (k *LibKBFS) GetPrevRevisions(u User, file Node) (
	revs data.PrevRevisions, err error)

GetPrevRevisions implements the Engine interface.

func (*LibKBFS) GetRootDir

func (k *LibKBFS) GetRootDir(
	u User, tlfName string, t tlf.Type, expectedCanonicalTlfName string) (
	dir Node, err error)

GetRootDir implements the Engine interface.

func (*LibKBFS) GetRootDirAtRelTimeString

func (k *LibKBFS) GetRootDirAtRelTimeString(
	u User, tlfName string, t tlf.Type, relTimeString string,
	expectedCanonicalTlfName string) (dir Node, err error)

GetRootDirAtRelTimeString implements the Engine interface.

func (*LibKBFS) GetRootDirAtRevision

func (k *LibKBFS) GetRootDirAtRevision(
	u User, tlfName string, t tlf.Type, rev kbfsmd.Revision,
	expectedCanonicalTlfName string) (dir Node, err error)

GetRootDirAtRevision implements the Engine interface.

func (*LibKBFS) GetRootDirAtTimeString

func (k *LibKBFS) GetRootDirAtTimeString(
	u User, tlfName string, t tlf.Type, timeString string,
	expectedCanonicalTlfName string) (dir Node, err error)

GetRootDirAtTimeString implements the Engine interface.

func (*LibKBFS) GetUID

func (k *LibKBFS) GetUID(u User) (uid keybase1.UID)

GetUID implements the Engine interface.

func (*LibKBFS) InitTest

func (k *LibKBFS) InitTest(ver kbfsmd.MetadataVer,
	blockSize int64, blockChangeSize int64, batchSize int, bwKBps int,
	opTimeout time.Duration, users []kbname.NormalizedUsername,
	teams, implicitTeams teamMap, clock libkbfs.Clock,
	journal bool) map[kbname.NormalizedUsername]User

InitTest implements the Engine interface.

func (*LibKBFS) Lookup

func (k *LibKBFS) Lookup(u User, parentDir Node, name string) (file Node, symPath string, err error)

Lookup implements the Engine interface.

func (*LibKBFS) MakeNaïveStaller

func (*LibKBFS) MakeNaïveStaller(u User) *libkbfs.NaïveStaller

MakeNaïveStaller implements the Engine interface.

func (*LibKBFS) Name

func (k *LibKBFS) Name() string

Name returns the name of the Engine.

func (*LibKBFS) PauseJournal

func (k *LibKBFS) PauseJournal(u User, tlfName string, t tlf.Type) error

PauseJournal implements the Engine interface.

func (*LibKBFS) ReadFile

func (k *LibKBFS) ReadFile(u User, file Node, off int64, buf []byte) (length int, err error)

ReadFile implements the Engine interface.

func (*LibKBFS) ReenableUpdates

func (k *LibKBFS) ReenableUpdates(u User, tlfName string, t tlf.Type) error

ReenableUpdates implements the Engine interface.

func (*LibKBFS) Rekey

func (k *LibKBFS) Rekey(u User, tlfName string, t tlf.Type) error

Rekey implements the Engine interface.

func (*LibKBFS) RemoveDir

func (k *LibKBFS) RemoveDir(u User, dir Node, name string) (err error)

RemoveDir implements the Engine interface.

func (*LibKBFS) RemoveEntry

func (k *LibKBFS) RemoveEntry(u User, dir Node, name string) (err error)

RemoveEntry implements the Engine interface.

func (*LibKBFS) Rename

func (k *LibKBFS) Rename(u User, srcDir Node, srcName string,
	dstDir Node, dstName string) (err error)

Rename implements the Engine interface.

func (*LibKBFS) ResumeJournal

func (k *LibKBFS) ResumeJournal(u User, tlfName string, t tlf.Type) error

ResumeJournal implements the Engine interface.

func (*LibKBFS) SetEx

func (k *LibKBFS) SetEx(u User, file Node, ex bool) (err error)

SetEx implements the Engine interface.

func (*LibKBFS) SetMtime

func (k *LibKBFS) SetMtime(u User, file Node, mtime time.Time) (err error)

SetMtime implements the Engine interface.

func (*LibKBFS) Shutdown

func (k *LibKBFS) Shutdown(u User) error

Shutdown implements the Engine interface.

func (*LibKBFS) SyncAll

func (k *LibKBFS) SyncAll(
	u User, tlfName string, t tlf.Type) (err error)

SyncAll implements the Engine interface.

func (*LibKBFS) SyncFromServer

func (k *LibKBFS) SyncFromServer(u User, tlfName string, t tlf.Type) (err error)

SyncFromServer implements the Engine interface.

func (*LibKBFS) TogglePrefetch

func (k *LibKBFS) TogglePrefetch(u User, enable bool) error

TogglePrefetch implements the Engine interface.

func (*LibKBFS) TruncateFile

func (k *LibKBFS) TruncateFile(u User, file Node, size uint64, sync bool) (err error)

TruncateFile implements the Engine interface.

func (*LibKBFS) UnflushedPaths

func (k *LibKBFS) UnflushedPaths(u User, tlfName string, t tlf.Type) (
	[]string, error)

UnflushedPaths implements the Engine interface.

func (*LibKBFS) UserEditHistory

func (k *LibKBFS) UserEditHistory(u User) (
	[]keybase1.FSFolderEditHistory, error)

UserEditHistory implements the Engine interface.

func (*LibKBFS) WriteFile

func (k *LibKBFS) WriteFile(u User, file Node, data []byte, off int64, sync bool) (err error)

WriteFile implements the Engine interface.

type Node

type Node interface{}

Node is an implementation-defined object which acts as a handle to a particular filesystem node.

type User

type User interface{}

User is an implementation-defined object which acts as a handle to a particular user.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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