v.io: v.io/x/ref/test Index | Files | Directories

package test

import "v.io/x/ref/test"

Package test implements initialization for unit and integration tests.

V23Init can be used within test functions as a safe alternative to v23.Init. It sets up the context so that only localhost ports are used for communication.

func TestFoo(t *testing.T) {

ctx, shutdown := test.V23Init()
defer shutdown()
...

}

This package also defines flags for enabling and controlling the Vanadium integration tests in package v.io/x/ref/test/v23test:

--v23.tests - run the integration tests
--v23.tests.shell-on-fail - drop into a debug shell if the test fails

Typical usage is: $ jiri go test . --v23.tests

Note that, like all flags not recognized by the go testing package, the --v23.tests flags must follow the package spec.

Subdirectories provide utilities for unit and integration tests.

The subdirectories are: benchmark - support for writing benchmarks. testutil - utility functions used in tests. security - security-related utility functions used in tests. timekeeper - an implementation of the timekeeper interface for use within

tests.

expect - support for testing the contents of of an input stream (an

io.Reader). v23test.Cmd contains an expect.Session, so this
package is generally not used directly.

v23test - defines Shell, which provides support for spawning and managing

subprocesses with configurable credentials.

Index

Package Files

doc.go init.go init_common.go

Constants

const IntegrationTestsDebugShellOnErrorFlag = "v23.tests.shell-on-fail"
const IntegrationTestsFlag = "v23.tests"
const (
    TestBlessing = "test-blessing"
)

Variables

var IntegrationTestsDebugShellOnError bool
var IntegrationTestsEnabled bool

func TestContext Uses

func TestContext() (*context.T, context.CancelFunc)

TestContext returns a *context.T suitable for use in tests. It sets the context's logger to logger.Global(), and that's it. In particular, it does not call v23.Init().

func V23Init Uses

func V23Init() (*context.T, v23.Shutdown)

V23Init initializes the runtime and sets up the principal with a self-signed TestBlessing. The blessing setup step is skipped if this function is invoked from a v23test.Shell child process, since v23test.Shell passes credentials to its children. NOTE: For tests involving Vanadium RPCs, developers are encouraged to use V23InitWithMounttable, and have their services access each other via the mount table (rather than using endpoint strings).

func V23InitWithMounttable Uses

func V23InitWithMounttable() (*context.T, v23.Shutdown)

V23InitWithMounttable initializes the runtime and: - Sets up the principal with a self-signed TestBlessing - Starts a mounttable and sets the namespace roots appropriately Both these steps are skipped if this function is invoked from a v23test.Shell child process.

Directories

PathSynopsis
basicsPackage basics implements some benchmarks for important basic operations in go.
benchmarkPackage benchmark implements utilities to augment the standard Go testing.Benchmark functionality.
expectPackage expect implements support for checking expectations against a buffered input stream.
goroutines
helloPackage hello defines a simple client and server and uses them in a series of regression tests.
hello/helloclientCommand helloclient is a simple client mainly used in regression tests.
hello/helloserverCommand helloserver is a simple server mainly used in regression tests.
testutilPackage testutil implements utilities for unit and integration tests.
testutil/testsshagent
timekeeperPackage timekeeper implements simulated time against the v.io/x/ref/lib/timekeeper.TimeKeeper interface.
v23testPackage v23test defines Shell, a wrapper around gosh.Shell that provides Vanadium-specific functionality such as credentials management, StartRootMountTable, and StartSyncbase.

Package test imports 15 packages (graph) and is imported by 16 packages. Updated 2020-10-24. Refresh now. Tools for package owners.