本文整理汇总了Golang中github.com/influxdb/telegraf/testutil.MockBatchPoints函数的典型用法代码示例。如果您正苦于以下问题:Golang MockBatchPoints函数的具体用法?Golang MockBatchPoints怎么用?Golang MockBatchPoints使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了MockBatchPoints函数的17个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: TestWrite
func TestWrite(t *testing.T) {
if testing.Short() {
t.Skip("Skipping integration test in short mode")
}
o := &OpenTSDB{
Host: testutil.GetLocalHost(),
Port: 4242,
Prefix: "prefix.test.",
}
// Verify that we can connect to the OpenTSDB instance
err := o.Connect()
require.NoError(t, err)
// Verify that we can successfully write data to OpenTSDB
err = o.Write(testutil.MockBatchPoints().Points())
require.NoError(t, err)
// Verify postive and negative test cases of writing data
bp := testutil.MockBatchPoints()
bp.AddPoint(testutil.TestPoint(float64(1.0), "justametric.float"))
bp.AddPoint(testutil.TestPoint(int64(123456789), "justametric.int"))
bp.AddPoint(testutil.TestPoint(uint64(123456789012345), "justametric.uint"))
bp.AddPoint(testutil.TestPoint("Lorem Ipsum", "justametric.string"))
bp.AddPoint(testutil.TestPoint(float64(42.0), "justametric.anotherfloat"))
err = o.Write(bp.Points())
require.NoError(t, err)
}
开发者ID:timjwright,项目名称:telegraf,代码行数:31,代码来源:opentsdb_test.go
示例2: TestBadStatusCode
func TestBadStatusCode(t *testing.T) {
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(http.StatusServiceUnavailable)
json.NewEncoder(w).Encode(`{
"errors": {
"system": [
"The API is currently down for maintenance. It'll be back shortly."
]
}
}`)
}))
defer ts.Close()
l := NewLibrato(ts.URL)
l.ApiUser = "[email protected]"
l.ApiToken = "123456"
err := l.Connect()
require.NoError(t, err)
err = l.Write(testutil.MockBatchPoints().Points())
if err == nil {
t.Errorf("error expected but none returned")
} else {
require.EqualError(t, fmt.Errorf("received bad status code, 503\n"), err.Error())
}
}
开发者ID:d4devops,项目名称:telegraf,代码行数:25,代码来源:librato_test.go
示例3: TestFormatMetric
func TestFormatMetric(t *testing.T) {
if testing.Short() {
t.Skip("Skipping integration test in short mode")
}
k := &KinesisOutput{
Format: "string",
}
p := testutil.MockBatchPoints().Points()[0]
valid_string := "test1,tag1=value1 value=1 1257894000000000000"
func_string, err := FormatMetric(k, p)
if func_string != valid_string {
t.Error("Expected ", valid_string)
}
require.NoError(t, err)
k = &KinesisOutput{
Format: "custom",
}
valid_custom := "test1,map[tag1:value1],test1,tag1=value1 value=1 1257894000000000000"
func_custom, err := FormatMetric(k, p)
if func_custom != valid_custom {
t.Error("Expected ", valid_custom)
}
require.NoError(t, err)
}
开发者ID:timjwright,项目名称:telegraf,代码行数:31,代码来源:kinesis_test.go
示例4: TestUDPInflux
func TestUDPInflux(t *testing.T) {
i := InfluxDB{
URLs: []string{"udp://localhost:8089"},
}
err := i.Connect()
require.NoError(t, err)
err = i.Write(testutil.MockBatchPoints().Points())
require.NoError(t, err)
}
开发者ID:timjwright,项目名称:telegraf,代码行数:10,代码来源:influxdb_test.go
示例5: TestUriOverride
func TestUriOverride(t *testing.T) {
a := &Amon{
ServerKey: fakeServerKey,
AmonInstance: fakeAmonInstance,
}
err := a.Connect()
require.NoError(t, err)
err = a.Write(testutil.MockBatchPoints().Points())
require.NoError(t, err)
}
开发者ID:rzagabe,项目名称:telegraf,代码行数:11,代码来源:amon_test.go
示例6: TestUriOverride
func TestUriOverride(t *testing.T) {
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(http.StatusOK)
}))
defer ts.Close()
l := NewLibrato(ts.URL)
l.ApiUser = "[email protected]"
l.ApiToken = "123456"
err := l.Connect()
require.NoError(t, err)
err = l.Write(testutil.MockBatchPoints().Points())
require.NoError(t, err)
}
开发者ID:d4devops,项目名称:telegraf,代码行数:14,代码来源:librato_test.go
示例7: TestUriOverride
func TestUriOverride(t *testing.T) {
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(http.StatusOK)
json.NewEncoder(w).Encode(`{"status":"ok"}`)
}))
defer ts.Close()
d := NewDatadog(ts.URL)
d.Apikey = "123456"
err := d.Connect()
require.NoError(t, err)
err = d.Write(testutil.MockBatchPoints())
require.NoError(t, err)
}
开发者ID:nibosho,项目名称:telegraf,代码行数:14,代码来源:datadog_test.go
示例8: TestWrite
func TestWrite(t *testing.T) {
if testing.Short() {
t.Skip("Skipping integration test in short mode")
}
o := &OpenTSDB{
Host: testutil.GetLocalHost(),
Port: 24242,
Prefix: "prefix.test.",
}
// Verify that we can connect to the OpenTSDB instance
err := o.Connect()
require.NoError(t, err)
// Verify that we can successfully write data to OpenTSDB
err = o.Write(testutil.MockBatchPoints().Points())
require.NoError(t, err)
// Verify postive and negative test cases of writing data
bp := testutil.MockBatchPoints()
tags := make(map[string]string)
bp.AddPoint(client.NewPoint("justametric.float", tags,
map[string]interface{}{"value": float64(1.0)}))
bp.AddPoint(client.NewPoint("justametric.int", tags,
map[string]interface{}{"value": int64(123456789)}))
bp.AddPoint(client.NewPoint("justametric.uint", tags,
map[string]interface{}{"value": uint64(123456789012345)}))
bp.AddPoint(client.NewPoint("justametric.string", tags,
map[string]interface{}{"value": "Lorem Ipsum"}))
bp.AddPoint(client.NewPoint("justametric.anotherfloat", tags,
map[string]interface{}{"value": float64(42.0)}))
err = o.Write(bp.Points())
require.NoError(t, err)
}
开发者ID:palkan,项目名称:telegraf,代码行数:37,代码来源:opentsdb_test.go
示例9: TestWrite
func TestWrite(t *testing.T) {
if testing.Short() {
t.Skip("Skipping integration test in short mode")
}
o := &OpenTSDB{
Host: testutil.GetLocalHost(),
Port: 24242,
Prefix: "prefix.test.",
}
// Verify that we can connect to the OpenTSDB instance
err := o.Connect()
require.NoError(t, err)
// Verify that we can successfully write data to OpenTSDB
err = o.Write(testutil.MockBatchPoints())
require.NoError(t, err)
// Verify postive and negative test cases of writing data
var bp client.BatchPoints
bp.Time = time.Now()
bp.Tags = map[string]string{"testkey": "testvalue"}
bp.Points = []client.Point{
{
Measurement: "justametric.float",
Fields: map[string]interface{}{"value": float64(1.0)},
},
{
Measurement: "justametric.int",
Fields: map[string]interface{}{"value": int64(123456789)},
},
{
Measurement: "justametric.uint",
Fields: map[string]interface{}{"value": uint64(123456789012345)},
},
{
Measurement: "justametric.string",
Fields: map[string]interface{}{"value": "Lorem Ipsum"},
},
{
Measurement: "justametric.anotherfloat",
Fields: map[string]interface{}{"value": float64(42.0)},
},
}
err = o.Write(bp)
require.NoError(t, err)
}
开发者ID:nibosho,项目名称:telegraf,代码行数:49,代码来源:opentsdb_test.go
示例10: TestUriOverride
func TestUriOverride(t *testing.T) {
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(http.StatusOK)
json.NewEncoder(w).Encode(`{"status":"ok"}`)
}))
defer ts.Close()
a := &Amon{
ServerKey: fakeServerKey,
AmonInstance: fakeAmonInstance,
}
err := a.Connect()
require.NoError(t, err)
err = a.Write(testutil.MockBatchPoints().Points())
require.NoError(t, err)
}
开发者ID:jp2007,项目名称:telegraf,代码行数:17,代码来源:amon_test.go
示例11: TestHTTPInflux
func TestHTTPInflux(t *testing.T) {
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(http.StatusOK)
w.Header().Set("Content-Type", "application/json")
fmt.Fprintln(w, `{"results":[{}]}`)
}))
defer ts.Close()
i := InfluxDB{
URLs: []string{ts.URL},
}
err := i.Connect()
require.NoError(t, err)
err = i.Write(testutil.MockBatchPoints().Points())
require.NoError(t, err)
}
开发者ID:timjwright,项目名称:telegraf,代码行数:17,代码来源:influxdb_test.go
示例12: TestConnectAndWrite
func TestConnectAndWrite(t *testing.T) {
if testing.Short() {
t.Skip("Skipping integration test in short mode")
}
url := testutil.GetLocalHost() + ":5555"
r := &Riemann{
URL: url,
Transport: "tcp",
}
err := r.Connect()
require.NoError(t, err)
err = r.Write(testutil.MockBatchPoints().Points())
require.NoError(t, err)
}
开发者ID:timjwright,项目名称:telegraf,代码行数:18,代码来源:riemann_test.go
示例13: TestConnectAndWrite
func TestConnectAndWrite(t *testing.T) {
if testing.Short() {
t.Skip("Skipping integration test in short mode")
}
var url = testutil.GetLocalHost() + ":1883"
m := &MQTT{
Servers: []string{url},
}
// Verify that we can connect to the MQTT broker
err := m.Connect()
require.NoError(t, err)
// Verify that we can successfully write data to the mqtt broker
err = m.Write(testutil.MockBatchPoints().Points())
require.NoError(t, err)
}
开发者ID:timjwright,项目名称:telegraf,代码行数:18,代码来源:mqtt_test.go
示例14: TestConnectAndWrite
func TestConnectAndWrite(t *testing.T) {
if testing.Short() {
t.Skip("Skipping integration test in short mode")
}
var url = "amqp://" + testutil.GetLocalHost() + ":5672/"
q := &AMQP{
URL: url,
Exchange: "telegraf_test",
}
// Verify that we can connect to the AMQP broker
err := q.Connect()
require.NoError(t, err)
// Verify that we can successfully write data to the amqp broker
err = q.Write(testutil.MockBatchPoints().Points())
require.NoError(t, err)
}
开发者ID:timjwright,项目名称:telegraf,代码行数:19,代码来源:amqp_test.go
示例15: TestConnectAndWrite
func TestConnectAndWrite(t *testing.T) {
if testing.Short() {
t.Skip("Skipping integration test in short mode")
}
server := []string{testutil.GetLocalHost() + ":4150"}
n := &NSQ{
Server: server[0],
Topic: "telegraf",
}
// Verify that we can connect to the NSQ daemon
err := n.Connect()
require.NoError(t, err)
// Verify that we can successfully write data to the NSQ daemon
err = n.Write(testutil.MockBatchPoints().Points())
require.NoError(t, err)
}
开发者ID:timjwright,项目名称:telegraf,代码行数:19,代码来源:nsq_test.go
示例16: TestConnectAndWrite
func TestConnectAndWrite(t *testing.T) {
if testing.Short() {
t.Skip("Skipping integration test in short mode")
}
brokers := []string{testutil.GetLocalHost() + ":9092"}
k := &Kafka{
Brokers: brokers,
Topic: "Test",
}
// Verify that we can connect to the Kafka broker
err := k.Connect()
require.NoError(t, err)
// Verify that we can successfully write data to the kafka broker
err = k.Write(testutil.MockBatchPoints().Points())
require.NoError(t, err)
}
开发者ID:timjwright,项目名称:telegraf,代码行数:19,代码来源:kafka_test.go
示例17: TestBadStatusCode
func TestBadStatusCode(t *testing.T) {
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(http.StatusInternalServerError)
json.NewEncoder(w).Encode(`{ 'errors': [
'Something bad happened to the server.',
'Your query made the server very sad.'
]
}`)
}))
defer ts.Close()
d := NewDatadog(ts.URL)
d.Apikey = "123456"
err := d.Connect()
require.NoError(t, err)
err = d.Write(testutil.MockBatchPoints())
if err == nil {
t.Errorf("error expected but none returned")
} else {
require.EqualError(t, fmt.Errorf("received bad status code, 500\n"), err.Error())
}
}
开发者ID:nibosho,项目名称:telegraf,代码行数:22,代码来源:datadog_test.go
注:本文中的github.com/influxdb/telegraf/testutil.MockBatchPoints函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论