當前位置: 首頁>>代碼示例>>Golang>>正文


Golang TestServerInterface.ServingAddr方法代碼示例

本文整理匯總了Golang中github.com/cockroachdb/cockroach/pkg/testutils/serverutils.TestServerInterface.ServingAddr方法的典型用法代碼示例。如果您正苦於以下問題:Golang TestServerInterface.ServingAddr方法的具體用法?Golang TestServerInterface.ServingAddr怎麽用?Golang TestServerInterface.ServingAddr使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在github.com/cockroachdb/cockroach/pkg/testutils/serverutils.TestServerInterface的用法示例。


在下文中一共展示了TestServerInterface.ServingAddr方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: setupMultipleRanges

// setupMultipleRanges creates a test server and splits the
// key range at the given keys. Returns the test server and client.
// The caller is responsible for stopping the server and
// closing the client.
func setupMultipleRanges(
	t *testing.T, ts serverutils.TestServerInterface, splitAt ...string,
) *client.DB {
	db := createTestClient(t, ts.Stopper(), ts.ServingAddr())

	// Split the keyspace at the given keys.
	for _, key := range splitAt {
		if err := db.AdminSplit(context.TODO(), key); err != nil {
			// Don't leak server goroutines.
			t.Fatal(err)
		}
	}

	return db
}
開發者ID:knz,項目名稱:cockroach,代碼行數:19,代碼來源:dist_sender_server_test.go

示例2: createTestClientForUser

func createTestClientForUser(
	t *testing.T, s serverutils.TestServerInterface, user string, dbCtx client.DBContext,
) *client.DB {
	rpcContext := rpc.NewContext(log.AmbientContext{}, &base.Config{
		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)),
	}, s.Clock(), s.Stopper())
	conn, err := rpcContext.GRPCDial(s.ServingAddr())
	if err != nil {
		t.Fatal(err)
	}
	return client.NewDBWithContext(client.NewSender(conn), dbCtx)
}
開發者ID:hvaara,項目名稱:cockroach,代碼行數:15,代碼來源:client_test.go

示例3: initReverseScanTestEnv

func initReverseScanTestEnv(s serverutils.TestServerInterface, t *testing.T) *client.DB {
	db := createTestClient(t, s.Stopper(), s.ServingAddr())

	// Set up multiple ranges:
	// ["", "b"),["b", "e") ,["e", "g") and ["g", "\xff\xff").
	for _, key := range []string{"b", "e", "g"} {
		// Split the keyspace at the given key.
		if err := db.AdminSplit(context.TODO(), key); err != nil {
			t.Fatal(err)
		}
	}
	// Write keys before, at, and after the split key.
	for _, key := range []string{"a", "b", "c", "d", "e", "f", "g", "h"} {
		if err := db.Put(context.TODO(), key, "value"); err != nil {
			t.Fatal(err)
		}
	}
	return db
}
開發者ID:knz,項目名稱:cockroach,代碼行數:19,代碼來源:dist_sender_server_test.go

示例4: createTestClientForUser

func createTestClientForUser(
	t *testing.T, s serverutils.TestServerInterface, user string,
) *client.DB {
	var ctx base.Config
	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))
	conn, err := rpc.NewContext(log.AmbientContext{}, &ctx, s.Clock(), s.Stopper()).GRPCDial(s.ServingAddr())
	if err != nil {
		t.Fatal(err)
	}
	return client.NewDB(client.NewSender(conn))
}
開發者ID:hvaara,項目名稱:cockroach,代碼行數:15,代碼來源:db_test.go


注:本文中的github.com/cockroachdb/cockroach/pkg/testutils/serverutils.TestServerInterface.ServingAddr方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。