Skip to content

Commit

Permalink
WIP: more boilerplate
Browse files Browse the repository at this point in the history
  • Loading branch information
bergquist committed Nov 13, 2016
1 parent bd3259d commit 118e2a6
Show file tree
Hide file tree
Showing 3 changed files with 85 additions and 0 deletions.
12 changes: 12 additions & 0 deletions pkg/tsdb/mqe/model_parser.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package mqe

import (
"github.com/grafana/grafana/pkg/components/simplejson"
"github.com/grafana/grafana/pkg/tsdb"
)

type MQEQueryParser struct{}

func (qp *MQEQueryParser) Parse(model *simplejson.Json, dsInfo *tsdb.DataSourceInfo) (*MQEQuery, error) {
return nil, nil
}
67 changes: 67 additions & 0 deletions pkg/tsdb/mqe/model_parser_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
package mqe

import (
"testing"

"github.com/grafana/grafana/pkg/components/simplejson"
"github.com/grafana/grafana/pkg/tsdb"
. "github.com/smartystreets/goconvey/convey"
)

func TestMQEQueryParser(t *testing.T) {
Convey("MQE query parser", t, func() {
parser := &MQEQueryParser{}

dsInfo := &tsdb.DataSourceInfo{
JsonData: simplejson.New(),
}

Convey("can parse simple mqe model", func() {
json := `
{
"apps": [],
"hosts": [
"staples-lab-1"
],
"metric": "$metric_cpu",
"metrics": [
{
"metric": "$metric_cpu"
}
],
"rawQuery": "",
"refId": "A"
}
`
modelJson, err := simplejson.NewJson([]byte(json))
So(err, ShouldBeNil)

res, err := parser.Parse(modelJson, dsInfo)
So(err, ShouldBeNil)
So(res.Interval, ShouldEqual, ">20s")
})

Convey("can parse multi serie mqe model", func() {
json := `
{
"apps": [],
"hosts": [
"staples-lab-1"
],
"metrics": [
{
"metric": "os.cpu.all.active_percentage"
},
{
"metric": "os.disk.sda.io_time"
}
],
"rawQuery": "",
"refId": "A",
"addAppToAlias": true,
"addHostToAlias": true
}
`
})
})
}
6 changes: 6 additions & 0 deletions pkg/tsdb/mqe/types.go
Original file line number Diff line number Diff line change
@@ -1 +1,7 @@
package mqe

type MQEQuery struct {
Metrics []string
Hosts []string
Apps []string
}

0 comments on commit 118e2a6

Please sign in to comment.