Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func InitTestServerFactory ¶
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.
Types ¶
type TestServerFactory ¶
type TestServerFactory interface { // New instantiates a test server. New(params base.TestServerArgs) interface{} }
TestServerFactory encompasses the actual implementation of the shim service.
type TestServerInterface ¶
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 ¶
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 ¶
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.