cockroach: github.com/abhinavdahiya/cockroach/testutils/serverutils Index | Files

package serverutils

import "github.com/abhinavdahiya/cockroach/testutils/serverutils"

Index

Package Files

test_cluster_shim.go test_server_shim.go

func InitTestClusterFactory Uses

func InitTestClusterFactory(impl TestClusterFactory)

InitTestClusterFactory should be called once to provide the implementation of the service. It will be called from a xx_test package that can import the server package.

func InitTestServerFactory Uses

func InitTestServerFactory(impl TestServerFactory)

InitTestServerFactory should be called once to provide the implementation of the service. It will be called from a xx_test package that can import the server package.

type TestClusterFactory Uses

type TestClusterFactory interface {
    // New instantiates a test server.
    StartTestCluster(t testing.TB, numNodes int, args base.TestClusterArgs) TestClusterInterface
}

TestClusterFactory encompasses the actual implementation of the shim service.

type TestClusterInterface Uses

type TestClusterInterface interface {
    NumServers() int

    // Server returns the TestServerInterface corresponding to a specific node.
    Server(idx int) TestServerInterface

    // ServerConn returns a gosql.DB connection to a specific node.
    ServerConn(idx int) *gosql.DB

    Stopper() *stop.Stopper
}

TestClusterInterface defines TestCluster functionality used by tests.

func StartTestCluster Uses

func StartTestCluster(t testing.TB, numNodes int, args base.TestClusterArgs) TestClusterInterface

StartTestCluster starts up a TestCluster made up of numNodes in-memory testing servers. The cluster should be stopped using Stopper().Stop().

type TestServerFactory Uses

type TestServerFactory interface {
    // New instantiates a test server.
    New(params base.TestServerArgs) interface{}
}

TestServerFactory encompasses the actual implementation of the shim service.

type TestServerInterface Uses

type TestServerInterface interface {
    Stopper() *stop.Stopper

    Start(params base.TestServerArgs) error

    // ServingAddr returns the server's address.
    ServingAddr() string

    // KVClient() returns a *client.DB instance for talking to this KV server,
    // as an interface{}.
    KVClient() interface{}

    // KVDB() returns the *kv.DB instance as an interface{}.
    KVDB() interface{}

    // RPCContext returns the rpc context used by the test server.
    RPCContext() *rpc.Context

    // LeaseManager() returns the *sql.LeaseManager as an interface{}.
    LeaseManager() interface{}

    // Gossip returns the gossip used by the TestServer.
    Gossip() *gossip.Gossip

    // Clock returns the clock used by the TestServer.
    Clock() *hlc.Clock

    // AdminURL returns the URL for the admin UI.
    AdminURL() string
    // GetHTTPClient returns an http client connected to the server. It uses the
    // context client TLS config.
    GetHTTPClient() (http.Client, error)

    // MustGetSQLCounter returns the value of a counter metric from the server's
    // SQL Executor. Runs in O(# of metrics) time, which is fine for test code.
    MustGetSQLCounter(name string) int64
    // MustGetSQLNetworkCounter returns the value of a counter metric from the
    // server's SQL server. Runs in O(# of metrics) time, which is fine for test
    // code.
    MustGetSQLNetworkCounter(name string) int64
    // WriteSummaries records summaries of time-series data, which is required for
    // any tests that query server stats.
    WriteSummaries() error
}

TestServerInterface defines test server functionality that tests need; it is implemented by server.TestServer.

func StartServer Uses

func StartServer(t testing.TB, params base.TestServerArgs) (
    TestServerInterface, *gosql.DB, *client.DB,
)

StartServer creates a test server and sets up a gosql DB connection. The server should be stopped by calling server.Stopper().Stop().

func StartServerRaw Uses

func StartServerRaw(args base.TestServerArgs) (TestServerInterface, error)

StartServerRaw creates and starts a TestServer. Generally StartServer() should be used. However this function can be used directly when opening a connection to the server is not desired.

Package serverutils imports 11 packages (graph). Updated 2017-03-13. Refresh now. Tools for package owners. This is a dead-end fork (no commits since the fork).