func (c *cluster) makeClient(nodeIdx int) *client.DB { sender, err := client.NewSender(c.rpcCtx, c.rpcAddr(nodeIdx)) if err != nil { log.Fatalf(context.Background(), "failed to initialize KV client: %s", err) } return client.NewDB(sender) }
func newKVNative(b *testing.B) kvInterface { enableTracing := tracing.Disable() s, _, _ := serverutils.StartServer(b, base.TestServerArgs{}) // TestServer.DB() returns the TxnCoordSender wrapped client. But that isn't // a fair comparison with SQL as we want these client requests to be sent // over the network. sender, err := client.NewSender( rpc.NewContext(&base.Context{ User: security.NodeUser, SSLCA: filepath.Join(security.EmbeddedCertsDir, security.EmbeddedCACert), SSLCert: filepath.Join(security.EmbeddedCertsDir, "node.crt"), SSLCertKey: filepath.Join(security.EmbeddedCertsDir, "node.key"), }, nil, s.Stopper()), s.ServingAddr()) if err != nil { b.Fatal(err) } return &kvNative{ db: client.NewDB(sender), doneFn: func() { s.Stopper().Stop() enableTracing() }, } }
// NewClient implements the Cluster interface. func (f *Farmer) NewClient(t *testing.T, i int) (*client.DB, *stop.Stopper) { stopper := stop.NewStopper() rpcContext := rpc.NewContext(&base.Context{ Insecure: true, User: security.NodeUser, }, nil, stopper) sender, err := client.NewSender(rpcContext, f.Addr(i, base.DefaultPort)) if err != nil { t.Fatal(err) } return client.NewDB(sender), stopper }
func createTestClientForUser(t *testing.T, stopper *stop.Stopper, addr, user string) *client.DB { var ctx base.Context ctx.InitDefaults() ctx.User = user ctx.SSLCA = filepath.Join(security.EmbeddedCertsDir, security.EmbeddedCACert) ctx.SSLCert = filepath.Join(security.EmbeddedCertsDir, fmt.Sprintf("%s.crt", user)) ctx.SSLCertKey = filepath.Join(security.EmbeddedCertsDir, fmt.Sprintf("%s.key", user)) sender, err := client.NewSender(rpc.NewContext(&ctx, nil, stopper), addr) if err != nil { t.Fatal(err) } return client.NewDB(sender) }
// NewClient implements the Cluster interface. func (l *LocalCluster) NewClient(t *testing.T, i int) (*roachClient.DB, *stop.Stopper) { stopper := stop.NewStopper() rpcContext := rpc.NewContext(&base.Context{ User: security.NodeUser, SSLCA: filepath.Join(l.CertsDir, security.EmbeddedCACert), SSLCert: filepath.Join(l.CertsDir, security.EmbeddedNodeCert), SSLCertKey: filepath.Join(l.CertsDir, security.EmbeddedNodeKey), }, nil, stopper) sender, err := roachClient.NewSender(rpcContext, l.Nodes[i].Addr(DefaultTCP).String()) if err != nil { t.Fatal(err) } return roachClient.NewDB(sender), stopper }
func makeDBClient() (*client.DB, *stop.Stopper) { stopper := stop.NewStopper() context := &base.Context{ User: security.NodeUser, SSLCA: baseCtx.SSLCA, SSLCert: baseCtx.SSLCert, SSLCertKey: baseCtx.SSLCertKey, Insecure: baseCtx.Insecure, } sender, err := client.NewSender(rpc.NewContext(context, nil, stopper), baseCtx.Addr) if err != nil { stopper.Stop() panicf("failed to initialize KV client: %s", err) } return client.NewDB(sender), stopper }
func createTestClientForUser( t *testing.T, stopper *stop.Stopper, addr, user string, dbCtx client.DBContext, ) *client.DB { rpcContext := rpc.NewContext(&base.Context{ User: user, SSLCA: filepath.Join(security.EmbeddedCertsDir, security.EmbeddedCACert), SSLCert: filepath.Join(security.EmbeddedCertsDir, fmt.Sprintf("%s.crt", user)), SSLCertKey: filepath.Join(security.EmbeddedCertsDir, fmt.Sprintf("%s.key", user)), }, nil, stopper) sender, err := client.NewSender(rpcContext, addr) if err != nil { t.Fatal(err) } return client.NewDBWithContext(sender, dbCtx) }