text: /*! grafana - v2.5.0 - 2015-10-28
   * Copyright (c) 2015 Torkel Ödegaard; Licensed Apache-2.0 */
  
  define(["require","exports","../elastic_response","test/lib/common"],function(a,b,c,d){d.describe("ElasticResponse",function(){var a,b,e;d.describe("simple query and count",function(){d.beforeEach(function(){a=[{refId:"A",metrics:[{type:"count",id:"1"}],bucketAggs:[{type:"date_histogram",field:"@timestamp",id:"2"}]}],b={responses:[{aggregations:{2:{buckets:[{doc_count:10,key:1e3},{doc_count:15,key:2e3}]}}}]},e=new c(a,b).getTimeSeries()}),d.it("should return 1 series",function(){d.expect(e.data.length).to.be(1),d.expect(e.data[0].target).to.be("Count"),d.expect(e.data[0].datapoints.length).to.be(2),d.expect(e.data[0].datapoints[0][0]).to.be(10),d.expect(e.data[0].datapoints[0][1]).to.be(1e3)})}),d.describe("simple query count & avg aggregation",function(){var e;d.beforeEach(function(){a=[{refId:"A",metrics:[{type:"count",id:"1"},{type:"avg",field:"value",id:"2"}],bucketAggs:[{type:"date_histogram",field:"@timestamp",id:"3"}]}],b={responses:[{aggregations:{3:{buckets:[{2:{value:88},doc_count:10,key:1e3},{2:{value:99},doc_count:15,key:2e3}]}}}]},e=new c(a,b).getTimeSeries()}),d.it("should return 2 series",function(){d.expect(e.data.length).to.be(2),d.expect(e.data[0].datapoints.length).to.be(2),d.expect(e.data[0].datapoints[0][0]).to.be(10),d.expect(e.data[0].datapoints[0][1]).to.be(1e3),d.expect(e.data[1].target).to.be("Average value"),d.expect(e.data[1].datapoints[0][0]).to.be(88),d.expect(e.data[1].datapoints[1][0]).to.be(99)})}),d.describe("single group by query one metric",function(){var e;d.beforeEach(function(){a=[{refId:"A",metrics:[{type:"count",id:"1"}],bucketAggs:[{type:"terms",field:"host",id:"2"},{type:"date_histogram",field:"@timestamp",id:"3"}]}],b={responses:[{aggregations:{2:{buckets:[{3:{buckets:[{doc_count:1,key:1e3},{doc_count:3,key:2e3}]},doc_count:4,key:"server1"},{3:{buckets:[{doc_count:2,key:1e3},{doc_count:8,key:2e3}]},doc_count:10,key:"server2"}]}}}]},e=new c(a,b).getTimeSeries()}),d.it("should return 2 series",function(){d.expect(e.data.length).to.be(2),d.expect(e.data[0].datapoints.length).to.be(2),d.expect(e.data[0].target).to.be("server1"),d.expect(e.data[1].target).to.be("server2")})}),d.describe("single group by query two metrics",function(){var e;d.beforeEach(function(){a=[{refId:"A",metrics:[{type:"count",id:"1"},{type:"avg",field:"@value",id:"4"}],bucketAggs:[{type:"terms",field:"host",id:"2"},{type:"date_histogram",field:"@timestamp",id:"3"}]}],b={responses:[{aggregations:{2:{buckets:[{3:{buckets:[{4:{value:10},doc_count:1,key:1e3},{4:{value:12},doc_count:3,key:2e3}]},doc_count:4,key:"server1"},{3:{buckets:[{4:{value:20},doc_count:1,key:1e3},{4:{value:32},doc_count:3,key:2e3}]},doc_count:10,key:"server2"}]}}}]},e=new c(a,b).getTimeSeries()}),d.it("should return 2 series",function(){d.expect(e.data.length).to.be(4),d.expect(e.data[0].datapoints.length).to.be(2),d.expect(e.data[0].target).to.be("server1 Count"),d.expect(e.data[1].target).to.be("server1 Average @value"),d.expect(e.data[2].target).to.be("server2 Count"),d.expect(e.data[3].target).to.be("server2 Average @value")})}),d.describe("with percentiles ",function(){var e;d.beforeEach(function(){a=[{refId:"A",metrics:[{type:"percentiles",settings:{percents:[75,90]},id:"1"}],bucketAggs:[{type:"date_histogram",field:"@timestamp",id:"3"}]}],b={responses:[{aggregations:{3:{buckets:[{1:{values:{75:3.3,90:5.5}},doc_count:10,key:1e3},{1:{values:{75:2.3,90:4.5}},doc_count:15,key:2e3}]}}}]},e=new c(a,b).getTimeSeries()}),d.it("should return 2 series",function(){d.expect(e.data.length).to.be(2),d.expect(e.data[0].datapoints.length).to.be(2),d.expect(e.data[0].target).to.be("p75"),d.expect(e.data[1].target).to.be("p90"),d.expect(e.data[0].datapoints[0][0]).to.be(3.3),d.expect(e.data[0].datapoints[0][1]).to.be(1e3),d.expect(e.data[1].datapoints[1][0]).to.be(4.5)})}),d.describe("with extended_stats",function(){var e;d.beforeEach(function(){a=[{refId:"A",metrics:[{type:"extended_stats",meta:{max:!0,std_deviation_bounds_upper:!0},id:"1"}],bucketAggs:[{type:"terms",field:"host",id:"3"},{type:"date_histogram",id:"4"}]}],b={responses:[{aggregations:{3:{buckets:[{key:"server1",4:{buckets:[{1:{max:10.2,min:5.5,std_deviation_bounds:{upper:3,lower:-2}},doc_count:10,key:1e3}]}},{key:"server2",4:{buckets:[{1:{max:10.2,min:5.5,std_deviation_bounds:{upper:3,lower:-2}},doc_count:10,key:1e3}]}}]}}}]},e=new c(a,b).getTimeSeries()}),d.it("should return 4 series",function(){d.expect(e.data.length).to.be(4),d.expect(e.data[0].datapoints.length).to.be(1),d.expect(e.data[0].target).to.be("server1 Max"),d.expect(e.data[1].target).to.be("server1 Std Dev Upper"),d.expect(e.data[0].datapoints[0][0]).to.be(10.2),d.expect(e.data[1].datapoints[0][0]).to.be(3)})}),d.describe("single group by with alias pattern",function(){var e;d.beforeEach(function(){a=[{refId:"A",metrics:[{type:"count",id:"1"}],alias:"{{term @host}} {{metric}} and!",bucketAggs:[{type:"terms",field:"@host",id:"2"},{type:"date_histogram",field:"@timestamp",id:"3"}]}],b={responses:[{aggregations:{2:{buckets:[{3:{buckets:[{doc_count:1,key:1e3},{doc_count:3,key:2e3}]},doc_count:4,key:"server1"},{3:{buckets:[{doc_count:2,key:1e3},{doc_count:8,key:2e3}]},doc_count:10,key:"server2"}]}}}]},e=new c(a,b).getTimeSeries()}),d.it("should return 2 series",function(){d.expect(e.data.length).to.be(2),d.expect(e.data[0].datapoints.length).to.be(2),d.expect(e.data[0].target).to.be("server1 Count and!"),d.expect(e.data[1].target).to.be("server2 Count and!")})}),d.describe("with two filters agg",function(){var e;d.beforeEach(function(){a=[{refId:"A",metrics:[{type:"count",id:"1"}],bucketAggs:[{id:"2",type:"filters",settings:{filters:[{query:"@metric:cpu"},{query:"@metric:logins.count"}]}},{type:"date_histogram",field:"@timestamp",id:"3"}]}],b={responses:[{aggregations:{2:{buckets:{"@metric:cpu":{3:{buckets:[{doc_count:1,key:1e3},{doc_count:3,key:2e3}]}},"@metric:logins.count":{3:{buckets:[{doc_count:2,key:1e3},{doc_count:8,key:2e3}]}}}}}}]},e=new c(a,b).getTimeSeries()}),d.it("should return 2 series",function(){d.expect(e.data.length).to.be(2),d.expect(e.data[0].datapoints.length).to.be(2),d.expect(e.data[0].target).to.be("@metric:cpu"),d.expect(e.data[1].target).to.be("@metric:logins.count")})})})});