Documentation ¶
Index ¶
- func GetJSONProto(ts TestServerInterface, path string, response proto.Message) error
- func InitTestClusterFactory(impl TestClusterFactory)
- func InitTestServerFactory(impl TestServerFactory)
- func PostJSONProto(ts TestServerInterface, path string, request, response proto.Message) error
- type TestClusterFactory
- type TestClusterInterface
- type TestServerFactory
- type TestServerInterface
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetJSONProto ¶
func GetJSONProto(ts TestServerInterface, path string, response proto.Message) error
GetJSONProto uses the supplied client to GET the URL specified by the parameters and unmarshals the result into response.
func InitTestClusterFactory ¶
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 ¶
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.
func PostJSONProto ¶
func PostJSONProto(ts TestServerInterface, path string, request, response proto.Message) error
PostJSONProto uses the supplied client to POST request to the URL specified by the parameters and unmarshals the result into response.
Types ¶
type TestClusterFactory ¶
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 ¶
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 // StopServer stops a single server. StopServer(idx int) // Stopper retrieves the stopper for this test cluster. Tests should call or // defer the Stop() method on this stopper after starting a test cluster. Stopper() *stop.Stopper }
TestClusterInterface defines TestCluster functionality used by tests.
func StartTestCluster ¶
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 ¶
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 // DistSender returns the DistSender used by the TestServer. DistSender() *kv.DistSender // 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.