@@ -33,6 +33,10 @@ func TestNewGateway(t *testing.T) {
33
33
URL : "http://localhost:9003" ,
34
34
Paths : nil ,
35
35
},
36
+ Ruler : Upstream {
37
+ URL : "http://localhost:9004" ,
38
+ Paths : nil ,
39
+ },
36
40
}
37
41
38
42
gw , err := New (& config , srv )
@@ -49,6 +53,7 @@ func TestStartGateway(t *testing.T) {
49
53
distributorServer := httptest .NewServer (http .HandlerFunc (func (w http.ResponseWriter , r * http.Request ) {}))
50
54
frontendServer := httptest .NewServer (http .HandlerFunc (func (w http.ResponseWriter , r * http.Request ) {}))
51
55
alertmanagerServer := httptest .NewServer (http .HandlerFunc (func (w http.ResponseWriter , r * http.Request ) {}))
56
+ rulerServer := httptest .NewServer (http .HandlerFunc (func (w http.ResponseWriter , r * http.Request ) {}))
52
57
53
58
timeouts := Upstream {
54
59
HTTPClientTimeout : 20 * time .Second ,
@@ -104,6 +109,15 @@ func TestStartGateway(t *testing.T) {
104
109
HTTPClientResponseHeaderTimeout : timeouts .HTTPClientResponseHeaderTimeout * time .Second ,
105
110
DNSRefreshInterval : timeouts .DNSRefreshInterval ,
106
111
},
112
+ Ruler : Upstream {
113
+ URL : rulerServer .URL ,
114
+ Paths : nil ,
115
+ HTTPClientTimeout : timeouts .HTTPClientTimeout ,
116
+ HTTPClientDialerTimeout : timeouts .HTTPClientDialerTimeout * time .Second ,
117
+ HTTPClientTLSHandshakeTimeout : timeouts .HTTPClientTLSHandshakeTimeout * time .Second ,
118
+ HTTPClientResponseHeaderTimeout : timeouts .HTTPClientResponseHeaderTimeout * time .Second ,
119
+ DNSRefreshInterval : timeouts .DNSRefreshInterval ,
120
+ },
107
121
},
108
122
authHeader : "Basic " + base64 .StdEncoding .EncodeToString ([]byte ("username:password" )),
109
123
paths : []string {
@@ -130,6 +144,11 @@ func TestStartGateway(t *testing.T) {
130
144
"/alertmanager/" ,
131
145
"/api/v1/alerts" ,
132
146
"/multitenant_alertmanager/delete_tenant_config" ,
147
+ "/prometheus/api/v1/rules" ,
148
+ "/api/prom/api/v1/rules" ,
149
+ "/prometheus/api/v1/alerts" ,
150
+ "/api/prom/api/v1/alerts" ,
151
+ "/api/v1/rules/" ,
133
152
},
134
153
expectedStatus : http .StatusOK ,
135
154
},
@@ -177,11 +196,23 @@ func TestStartGateway(t *testing.T) {
177
196
HTTPClientResponseHeaderTimeout : timeouts .HTTPClientResponseHeaderTimeout * time .Second ,
178
197
DNSRefreshInterval : timeouts .DNSRefreshInterval ,
179
198
},
199
+ Ruler : Upstream {
200
+ URL : rulerServer .URL ,
201
+ Paths : []string {
202
+ "/test/ruler" ,
203
+ },
204
+ HTTPClientTimeout : timeouts .HTTPClientTimeout ,
205
+ HTTPClientDialerTimeout : timeouts .HTTPClientDialerTimeout * time .Second ,
206
+ HTTPClientTLSHandshakeTimeout : timeouts .HTTPClientTLSHandshakeTimeout * time .Second ,
207
+ HTTPClientResponseHeaderTimeout : timeouts .HTTPClientResponseHeaderTimeout * time .Second ,
208
+ DNSRefreshInterval : timeouts .DNSRefreshInterval ,
209
+ },
180
210
},
181
211
paths : []string {
182
212
"/test/distributor" ,
183
213
"/test/frontend" ,
184
214
"/test/alertmanager" ,
215
+ "/test/ruler" ,
185
216
},
186
217
authHeader : "Basic " + base64 .StdEncoding .EncodeToString ([]byte ("username:password" )),
187
218
expectedStatus : http .StatusOK ,
@@ -215,6 +246,17 @@ func TestStartGateway(t *testing.T) {
215
246
HTTPClientResponseHeaderTimeout : timeouts .HTTPClientResponseHeaderTimeout ,
216
247
DNSRefreshInterval : timeouts .DNSRefreshInterval ,
217
248
},
249
+ Ruler : Upstream {
250
+ URL : rulerServer .URL ,
251
+ Paths : []string {
252
+ "/test/ruler" ,
253
+ },
254
+ HTTPClientTimeout : timeouts .HTTPClientTimeout ,
255
+ HTTPClientDialerTimeout : timeouts .HTTPClientDialerTimeout * time .Second ,
256
+ HTTPClientTLSHandshakeTimeout : timeouts .HTTPClientTLSHandshakeTimeout * time .Second ,
257
+ HTTPClientResponseHeaderTimeout : timeouts .HTTPClientResponseHeaderTimeout * time .Second ,
258
+ DNSRefreshInterval : timeouts .DNSRefreshInterval ,
259
+ },
218
260
},
219
261
paths : []string {
220
262
"/not/found" ,
@@ -250,6 +292,24 @@ func TestStartGateway(t *testing.T) {
250
292
},
251
293
expectedErr : errors .New ("invalid URL scheme:" ),
252
294
},
295
+ {
296
+ name : "invalid ruler proxy" ,
297
+ config : & Config {
298
+ Distributor : Upstream {
299
+ URL : distributorServer .URL ,
300
+ Paths : []string {},
301
+ },
302
+ QueryFrontend : Upstream {
303
+ URL : frontendServer .URL ,
304
+ Paths : []string {},
305
+ },
306
+ Alertmanager : Upstream {
307
+ URL : alertmanagerServer .URL ,
308
+ Paths : []string {},
309
+ },
310
+ },
311
+ expectedErr : errors .New ("invalid URL scheme:" ),
312
+ },
253
313
}
254
314
255
315
for _ , tc := range testCases {
0 commit comments