From 84a713f07f2b303154e4bc134aedcea6a0b9ef9b Mon Sep 17 00:00:00 2001 From: Can ZHANG Date: Tue, 12 May 2015 18:13:56 +0800 Subject: [PATCH] Use "value" as the field name in graphite Also fix tests. --- cmd/influxd/server_integration_test.go | 8 ++++---- graphite/graphite.go | 2 +- graphite/graphite_test.go | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/cmd/influxd/server_integration_test.go b/cmd/influxd/server_integration_test.go index c9bd2ab3b3..09a676fff6 100644 --- a/cmd/influxd/server_integration_test.go +++ b/cmd/influxd/server_integration_test.go @@ -1797,7 +1797,7 @@ func Test_ServerSingleGraphiteIntegration_Default(t *testing.T) { return } - expected := fmt.Sprintf(`{"results":[{"series":[{"name":"cpu","columns":["time","cpu"],"values":[["%s",23.456]]}]}]}`, now.Format(time.RFC3339Nano)) + expected := fmt.Sprintf(`{"results":[{"series":[{"name":"cpu","columns":["time","value"],"values":[["%s",23.456]]}]}]}`, now.Format(time.RFC3339Nano)) // query and wait for results got, ok, _ := queryAndWait(t, nodes, "graphite", `select * from "graphite"."raw".cpu`, expected, "", graphiteTestTimeout) @@ -1855,7 +1855,7 @@ func Test_ServerSingleGraphiteIntegration_FractionalTime(t *testing.T) { return } - expected := fmt.Sprintf(`{"results":[{"series":[{"name":"cpu","columns":["time","cpu"],"values":[["%s",23.456]]}]}]}`, now.Format(time.RFC3339Nano)) + expected := fmt.Sprintf(`{"results":[{"series":[{"name":"cpu","columns":["time","value"],"values":[["%s",23.456]]}]}]}`, now.Format(time.RFC3339Nano)) // query and wait for results got, ok, _ := queryAndWait(t, nodes, "graphite", `select * from "graphite"."raw".cpu`, expected, "", graphiteTestTimeout) @@ -1912,7 +1912,7 @@ func Test_ServerSingleGraphiteIntegration_ZeroDataPoint(t *testing.T) { return } - expected := fmt.Sprintf(`{"results":[{"series":[{"name":"cpu","columns":["time","cpu"],"values":[["%s",0]]}]}]}`, now.Format(time.RFC3339Nano)) + expected := fmt.Sprintf(`{"results":[{"series":[{"name":"cpu","columns":["time","value"],"values":[["%s",0]]}]}]}`, now.Format(time.RFC3339Nano)) // query and wait for results got, ok, _ := queryAndWait(t, nodes, "graphite", `select * from "graphite"."raw".cpu`, expected, "", graphiteTestTimeout) @@ -1980,7 +1980,7 @@ func Test_ServerSingleGraphiteIntegration_NoDatabase(t *testing.T) { } // Wait for data to show up - expected = fmt.Sprintf(`{"results":[{"series":[{"name":"cpu","columns":["time","cpu"],"values":[["%s",23.456]]}]}]}`, now.Format(time.RFC3339Nano)) + expected = fmt.Sprintf(`{"results":[{"series":[{"name":"cpu","columns":["time","value"],"values":[["%s",23.456]]}]}]}`, now.Format(time.RFC3339Nano)) got, ok, _ = queryAndWait(t, nodes, "graphite", `select * from "graphite"."default".cpu`, expected, "", 2*time.Second) if !ok { t.Errorf(`Test "%s" failed, expected: %s, got: %s`, testName, expected, got) diff --git a/graphite/graphite.go b/graphite/graphite.go index b5aaede342..37bc31a343 100644 --- a/graphite/graphite.go +++ b/graphite/graphite.go @@ -87,7 +87,7 @@ func (p *Parser) Parse(line string) (influxdb.Point, error) { } fieldValues := make(map[string]interface{}) - fieldValues[name] = v + fieldValues["value"] = v // Parse timestamp. unixTime, err := strconv.ParseFloat(fields[2], 64) diff --git a/graphite/graphite_test.go b/graphite/graphite_test.go index c3d36d40e1..4d5f46a91b 100644 --- a/graphite/graphite_test.go +++ b/graphite/graphite_test.go @@ -211,8 +211,8 @@ func Test_DecodeMetric(t *testing.T) { if len(point.Tags) != len(test.tags) { t.Fatalf("tags len mismatch. expected %d, got %d", len(test.tags), len(point.Tags)) } - f := point.Fields[point.Name].(float64) - if point.Fields[point.Name] != f { + f := point.Fields["value"].(float64) + if point.Fields["value"] != f { t.Fatalf("floatValue value mismatch. expected %v, got %v", test.value, f) } if point.Time.UnixNano()/1000000 != test.time.UnixNano()/1000000 {