test

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2023 License: BSD-3-Clause Imports: 15 Imported by: 12

Documentation

Overview

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. sectestdata - data used in security tests such as certificates and keys. 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

Constants

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

Constants for use in tests.

Variables

View Source
var (
	IntegrationTestsEnabled           bool
	IntegrationTestsDebugShellOnError bool
)

Variables set by flags registered by this package's init function, namely for IntegrationTestsFlag and IntegrationTestsDebugShellOnErrorFlag respectively.

Functions

func TestContext

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

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

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.

Types

This section is empty.

Directories

Path Synopsis
Package basics implements some benchmarks for important basic operations in go.
Package basics implements some benchmarks for important basic operations in go.
Package benchmark implements utilities to augment the standard Go testing.Benchmark functionality.
Package benchmark implements utilities to augment the standard Go testing.Benchmark functionality.
Package compatibility provides support for compatibility testing between different versions of vanadium.
Package compatibility provides support for compatibility testing between different versions of vanadium.
Package expect implements support for checking expectations against a buffered input stream.
Package expect implements support for checking expectations against a buffered input stream.
Package hello defines a simple client and server and uses them in a series of regression tests.
Package hello defines a simple client and server and uses them in a series of regression tests.
helloclient
Command helloclient is a simple client mainly used in regression tests.
Command helloclient is a simple client mainly used in regression tests.
helloserver
Command helloserver is a simple server mainly used in regression tests.
Command helloserver is a simple server mainly used in regression tests.
Package testutil implements utilities for unit and integration tests.
Package testutil implements utilities for unit and integration tests.
Package timekeeper implements simulated time against the v.io/x/ref/lib/timekeeper.TimeKeeper interface.
Package timekeeper implements simulated time against the v.io/x/ref/lib/timekeeper.TimeKeeper interface.
Package v23test defines Shell, a wrapper around gosh.Shell that provides Vanadium-specific functionality such as credentials management, StartRootMountTable, and StartSyncbase.
Package v23test defines Shell, a wrapper around gosh.Shell that provides Vanadium-specific functionality such as credentials management, StartRootMountTable, and StartSyncbase.

Jump to

Keyboard shortcuts

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