本文整理匯總了Golang中github.com/cockroachdb/cockroach/pkg/acceptance/terrafarm.Farmer類的典型用法代碼示例。如果您正苦於以下問題:Golang Farmer類的具體用法?Golang Farmer怎麽用?Golang Farmer使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了Farmer類的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: queryCount
// queryCount returns the total SQL queries executed by the cluster.
func (cl continuousLoadTest) queryCount(f *terrafarm.Farmer) (float64, error) {
var client http.Client
var resp status.NodeStatus
host := f.Hostname(0)
if err := httputil.GetJSON(client, "http://"+host+":8080/_status/nodes/local", &resp); err != nil {
return 0, err
}
count, ok := resp.Metrics["sql.query.count"]
if !ok {
return 0, errors.New("couldn't find SQL query count metric")
}
return count, nil
}
示例2: startLoad
func (cl continuousLoadTest) startLoad(f *terrafarm.Farmer) error {
if *flagCLTWriters > len(f.Nodes()) {
return errors.Errorf("writers (%d) > nodes (%d)", *flagCLTWriters, len(f.Nodes()))
}
// We may have to retry restarting the load generators, because CockroachDB
// might have been started too recently to start accepting connections.
started := make(map[int]bool)
return util.RetryForDuration(10*time.Second, func() error {
for i := 0; i < *flagCLTWriters; i++ {
if !started[i] {
if err := f.Start(i, cl.Process); err != nil {
return err
}
}
}
return nil
})
}
示例3: assert
// assert fails the test if CockroachDB or the load generators are down.
func (cl continuousLoadTest) assert(t *testing.T, f *terrafarm.Farmer) {
f.Assert(t)
for _, host := range f.Nodes()[0:*flagCLTWriters] {
f.AssertState(t, host, cl.Process, "RUNNING")
}
}