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


Golang serverutils.TestServerInterface類代碼示例

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


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

示例1: checkCounterGE

func checkCounterGE(
	t *testing.T, s serverutils.TestServerInterface, key string, e int64,
) {
	if a := s.MustGetSQLCounter(key); a < e {
		t.Error(errors.Errorf("stat %s: expected: actual %d >= %d", key, a, e))
	}
}
開發者ID:CubeLite,項目名稱:cockroach,代碼行數:7,代碼來源:metric_util_test.go

示例2: checkCounterGE

func checkCounterGE(
	t *testing.T, s serverutils.TestServerInterface, meta metric.Metadata, e int64,
) {
	if a := s.MustGetSQLCounter(meta.Name); a < e {
		t.Error(errors.Errorf("stat %s: expected: actual %d >= %d", meta.Name, a, e))
	}
}
開發者ID:yaojingguo,項目名稱:cockroach,代碼行數:7,代碼來源:metric_util_test.go

示例3: apiPost

// apiPost issues a POST to the provided server using the given API path and
// request, marshalling the result into response.
func apiPost(s serverutils.TestServerInterface, path string, request, response proto.Message) error {
	apiPath := apiEndpoint + path
	client, err := s.GetHTTPClient()
	if err != nil {
		return err
	}
	return util.PostJSON(client, s.AdminURL()+apiPath, request, response)
}
開發者ID:CubeLite,項目名稱:cockroach,代碼行數:10,代碼來源:admin_test.go

示例4: 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(key); err != nil {
			// Don't leak server goroutines.
			t.Fatal(err)
		}
	}

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

示例5: 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(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(key, "value"); err != nil {
			t.Fatal(err)
		}
	}
	return db
}
開發者ID:YuleiXiao,項目名稱:cockroach,代碼行數:19,代碼來源:dist_sender_server_test.go

示例6: getRequestReader

// getRequestReader returns the io.ReadCloser from a get request to the test
// server with the given path. The returned closer should be closed by the
// caller.
func getRequestReader(t *testing.T, ts serverutils.TestServerInterface, path string) io.ReadCloser {
	httpClient, err := ts.GetHTTPClient()
	if err != nil {
		t.Fatal(err)
	}

	url := ts.AdminURL() + path
	for r := retry.Start(retryOptions); r.Next(); {
		req, err := http.NewRequest("GET", url, nil)
		if err != nil {
			t.Fatal(err)
		}
		req.Header.Set(util.AcceptHeader, util.JSONContentType)
		resp, err := httpClient.Do(req)
		if err != nil {
			log.Infof("could not GET %s - %s", url, err)
			continue
		}
		if resp.StatusCode != http.StatusOK {
			body, err := ioutil.ReadAll(resp.Body)
			if err != nil {
				log.Infof("could not read body for %s - %s", url, err)
				continue
			}
			log.Infof("could not GET %s - statuscode: %d - body: %s", url, resp.StatusCode, body)
			continue
		}
		returnedContentType := resp.Header.Get(util.ContentTypeHeader)
		if returnedContentType != util.JSONContentType {
			log.Infof("unexpected content type: %v", returnedContentType)
			continue
		}
		log.Infof("OK response from %s", url)
		return resp.Body
	}
	t.Fatalf("There was an error retrieving %s", url)
	return nil
}
開發者ID:CubeLite,項目名稱:cockroach,代碼行數:41,代碼來源:status_test.go

示例7: checkSQLNetworkMetrics

// checkSQLNetworkMetrics returns the server's pgwire bytesIn/bytesOut and an
// error if the bytesIn/bytesOut don't satisfy the given minimums and maximums.
func checkSQLNetworkMetrics(
	s serverutils.TestServerInterface,
	minBytesIn, minBytesOut, maxBytesIn, maxBytesOut int64,
) (int64, int64, error) {
	if err := s.WriteSummaries(); err != nil {
		return -1, -1, err
	}

	bytesIn := s.MustGetSQLNetworkCounter("bytesin")
	bytesOut := s.MustGetSQLNetworkCounter("bytesout")
	if a, min := bytesIn, minBytesIn; a < min {
		return bytesIn, bytesOut, errors.Errorf("bytesin %d < expected min %d", a, min)
	}
	if a, min := bytesOut, minBytesOut; a < min {
		return bytesIn, bytesOut, errors.Errorf("bytesout %d < expected min %d", a, min)
	}
	if a, max := bytesIn, maxBytesIn; a > max {
		return bytesIn, bytesOut, errors.Errorf("bytesin %d > expected max %d", a, max)
	}
	if a, max := bytesOut, maxBytesOut; a > max {
		return bytesIn, bytesOut, errors.Errorf("bytesout %d > expected max %d", a, max)
	}
	return bytesIn, bytesOut, nil
}
開發者ID:CubeLite,項目名稱:cockroach,代碼行數:26,代碼來源:pgwire_test.go

示例8: debugURL

// debugURL returns the root debug URL.
func debugURL(s serverutils.TestServerInterface) string {
	return s.AdminURL() + debugEndpoint
}
開發者ID:CubeLite,項目名稱:cockroach,代碼行數:4,代碼來源:admin_test.go


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