@@ -28,7 +28,7 @@ describe('PrometheusMetricFindQuery', function() {
28
28
data : [ "value1" , "value2" , "value3" ]
29
29
} ;
30
30
ctx . $httpBackend . expect ( 'GET' , 'proxied/api/v1/label/resource/values' ) . respond ( response ) ;
31
- var pm = new PrometheusMetricFindQuery ( ctx . ds , 'label_values(resource)' ) ;
31
+ var pm = new PrometheusMetricFindQuery ( ctx . ds , 'label_values(resource)' , ctx . timeSrv ) ;
32
32
pm . process ( ) . then ( function ( data ) { results = data ; } ) ;
33
33
ctx . $httpBackend . flush ( ) ;
34
34
ctx . $rootScope . $apply ( ) ;
@@ -43,13 +43,22 @@ describe('PrometheusMetricFindQuery', function() {
43
43
{ __name__ : "metric" , resource : "value3" }
44
44
]
45
45
} ;
46
- ctx . $httpBackend . expect ( 'GET' , ' proxied/api/v1/series?match[ ]=metric' ) . respond ( response ) ;
47
- var pm = new PrometheusMetricFindQuery ( ctx . ds , 'label_values(metric, resource)' ) ;
46
+ ctx . $httpBackend . expect ( 'GET' , / p r o x i e d \ /a p i \ /v 1 \ /s e r i e s \ ?m a t c h \[ \ ]= m e t r i c & s t a r t = . * & e n d = . * / ) . respond ( response ) ;
47
+ var pm = new PrometheusMetricFindQuery ( ctx . ds , 'label_values(metric, resource)' , ctx . timeSrv ) ;
48
48
pm . process ( ) . then ( function ( data ) { results = data ; } ) ;
49
49
ctx . $httpBackend . flush ( ) ;
50
50
ctx . $rootScope . $apply ( ) ;
51
51
expect ( results . length ) . to . be ( 3 ) ;
52
52
} ) ;
53
+ it ( 'label_values(metric, resource) should pass correct time' , function ( ) {
54
+ ctx . timeSrv . setTime ( { from : moment . utc ( '2011-01-01' ) , to : moment . utc ( '2015-01-01' ) } ) ;
55
+ ctx . $httpBackend . expect ( 'GET' ,
56
+ / p r o x i e d \/ a p i \/ v 1 \/ s e r i e s \? m a t c h \[ \] = m e t r i c & s t a r t = 1 2 9 3 8 4 0 0 0 0 & e n d = 1 4 2 0 0 7 0 4 0 0 / ) . respond ( response ) ;
57
+ var pm = new PrometheusMetricFindQuery ( ctx . ds , 'label_values(metric, resource)' , ctx . timeSrv ) ;
58
+ pm . process ( ) . then ( function ( data ) { results = data ; } ) ;
59
+ ctx . $httpBackend . flush ( ) ;
60
+ ctx . $rootScope . $apply ( ) ;
61
+ } ) ;
53
62
it ( 'label_values(metric{label1="foo", label2="bar", label3="baz"}, resource) should generate series query' , function ( ) {
54
63
response = {
55
64
status : "success" ,
@@ -59,8 +68,8 @@ describe('PrometheusMetricFindQuery', function() {
59
68
{ __name__ : "metric" , resource : "value3" }
60
69
]
61
70
} ;
62
- ctx . $httpBackend . expect ( 'GET' , ' proxied/api/v1/series?match[ ]=metric' ) . respond ( response ) ;
63
- var pm = new PrometheusMetricFindQuery ( ctx . ds , 'label_values(metric, resource)' ) ;
71
+ ctx . $httpBackend . expect ( 'GET' , / p r o x i e d \ /a p i \ /v 1 \ /s e r i e s \ ?m a t c h \[ \ ]= m e t r i c & s t a r t = . * & e n d = . * / ) . respond ( response ) ;
72
+ var pm = new PrometheusMetricFindQuery ( ctx . ds , 'label_values(metric, resource)' , ctx . timeSrv ) ;
64
73
pm . process ( ) . then ( function ( data ) { results = data ; } ) ;
65
74
ctx . $httpBackend . flush ( ) ;
66
75
ctx . $rootScope . $apply ( ) ;
@@ -72,7 +81,7 @@ describe('PrometheusMetricFindQuery', function() {
72
81
data : [ "metric1" , "metric2" , "metric3" , "nomatch" ]
73
82
} ;
74
83
ctx . $httpBackend . expect ( 'GET' , 'proxied/api/v1/label/__name__/values' ) . respond ( response ) ;
75
- var pm = new PrometheusMetricFindQuery ( ctx . ds , 'metrics(metric.*)' ) ;
84
+ var pm = new PrometheusMetricFindQuery ( ctx . ds , 'metrics(metric.*)' , ctx . timeSrv ) ;
76
85
pm . process ( ) . then ( function ( data ) { results = data ; } ) ;
77
86
ctx . $httpBackend . flush ( ) ;
78
87
ctx . $rootScope . $apply ( ) ;
@@ -90,7 +99,7 @@ describe('PrometheusMetricFindQuery', function() {
90
99
}
91
100
} ;
92
101
ctx . $httpBackend . expect ( 'GET' , / p r o x i e d \/ a p i \/ v 1 \/ q u e r y \? q u e r y = m e t r i c & t i m e = .* / ) . respond ( response ) ;
93
- var pm = new PrometheusMetricFindQuery ( ctx . ds , 'query_result(metric)' ) ;
102
+ var pm = new PrometheusMetricFindQuery ( ctx . ds , 'query_result(metric)' , ctx . timeSrv ) ;
94
103
pm . process ( ) . then ( function ( data ) { results = data ; } ) ;
95
104
ctx . $httpBackend . flush ( ) ;
96
105
ctx . $rootScope . $apply ( ) ;
0 commit comments