@@ -22,11 +22,15 @@ func TestNewGateway(t *testing.T) {
22
22
23
23
config := Config {
24
24
Distributor : Upstream {
25
- URL : "http://localhost:8000 " ,
25
+ URL : "http://localhost:9001 " ,
26
26
Paths : nil ,
27
27
},
28
28
QueryFrontend : Upstream {
29
- URL : "http://localhost:9000" ,
29
+ URL : "http://localhost:9002" ,
30
+ Paths : nil ,
31
+ },
32
+ Alertmanager : Upstream {
33
+ URL : "http://localhost:9003" ,
30
34
Paths : nil ,
31
35
},
32
36
}
@@ -44,6 +48,7 @@ func TestStartGateway(t *testing.T) {
44
48
45
49
distributorServer := httptest .NewServer (http .HandlerFunc (func (w http.ResponseWriter , r * http.Request ) {}))
46
50
frontendServer := httptest .NewServer (http .HandlerFunc (func (w http.ResponseWriter , r * http.Request ) {}))
51
+ alertmanagerServer := httptest .NewServer (http .HandlerFunc (func (w http.ResponseWriter , r * http.Request ) {}))
47
52
48
53
timeouts := Upstream {
49
54
HTTPClientTimeout : 20 * time .Second ,
@@ -90,6 +95,15 @@ func TestStartGateway(t *testing.T) {
90
95
HTTPClientResponseHeaderTimeout : timeouts .HTTPClientResponseHeaderTimeout * time .Second ,
91
96
DNSRefreshInterval : timeouts .DNSRefreshInterval ,
92
97
},
98
+ Alertmanager : Upstream {
99
+ URL : alertmanagerServer .URL ,
100
+ Paths : nil ,
101
+ HTTPClientTimeout : timeouts .HTTPClientTimeout ,
102
+ HTTPClientDialerTimeout : timeouts .HTTPClientDialerTimeout * time .Second ,
103
+ HTTPClientTLSHandshakeTimeout : timeouts .HTTPClientTLSHandshakeTimeout * time .Second ,
104
+ HTTPClientResponseHeaderTimeout : timeouts .HTTPClientResponseHeaderTimeout * time .Second ,
105
+ DNSRefreshInterval : timeouts .DNSRefreshInterval ,
106
+ },
93
107
},
94
108
authHeader : "Basic " + base64 .StdEncoding .EncodeToString ([]byte ("username:password" )),
95
109
paths : []string {
@@ -113,6 +127,9 @@ func TestStartGateway(t *testing.T) {
113
127
"/api/prom/api/v1/read" ,
114
128
"/prometheus/api/v1/status/buildinfo" ,
115
129
"/api/prom/api/v1/status/buildinfo" ,
130
+ "/alertmanager/" ,
131
+ "/api/v1/alerts" ,
132
+ "/multitenant_alertmanager/delete_tenant_config" ,
116
133
},
117
134
expectedStatus : http .StatusOK ,
118
135
},
@@ -149,10 +166,22 @@ func TestStartGateway(t *testing.T) {
149
166
HTTPClientResponseHeaderTimeout : timeouts .HTTPClientResponseHeaderTimeout * time .Second ,
150
167
DNSRefreshInterval : timeouts .DNSRefreshInterval ,
151
168
},
169
+ Alertmanager : Upstream {
170
+ URL : alertmanagerServer .URL ,
171
+ Paths : []string {
172
+ "/test/alertmanager" ,
173
+ },
174
+ HTTPClientTimeout : timeouts .HTTPClientTimeout ,
175
+ HTTPClientDialerTimeout : timeouts .HTTPClientDialerTimeout * time .Second ,
176
+ HTTPClientTLSHandshakeTimeout : timeouts .HTTPClientTLSHandshakeTimeout * time .Second ,
177
+ HTTPClientResponseHeaderTimeout : timeouts .HTTPClientResponseHeaderTimeout * time .Second ,
178
+ DNSRefreshInterval : timeouts .DNSRefreshInterval ,
179
+ },
152
180
},
153
181
paths : []string {
154
182
"/test/distributor" ,
155
183
"/test/frontend" ,
184
+ "/test/alertmanager" ,
156
185
},
157
186
authHeader : "Basic " + base64 .StdEncoding .EncodeToString ([]byte ("username:password" )),
158
187
expectedStatus : http .StatusOK ,
@@ -176,6 +205,16 @@ func TestStartGateway(t *testing.T) {
176
205
HTTPClientResponseHeaderTimeout : timeouts .HTTPClientResponseHeaderTimeout ,
177
206
DNSRefreshInterval : timeouts .DNSRefreshInterval ,
178
207
},
208
+ Alertmanager : Upstream {
209
+ URL : alertmanagerServer .URL ,
210
+ Paths : []string {
211
+ "/test/alertmanager" ,
212
+ },
213
+ HTTPClientDialerTimeout : timeouts .HTTPClientDialerTimeout ,
214
+ HTTPClientTLSHandshakeTimeout : timeouts .HTTPClientTLSHandshakeTimeout ,
215
+ HTTPClientResponseHeaderTimeout : timeouts .HTTPClientResponseHeaderTimeout ,
216
+ DNSRefreshInterval : timeouts .DNSRefreshInterval ,
217
+ },
179
218
},
180
219
paths : []string {
181
220
"/not/found" ,
@@ -197,6 +236,20 @@ func TestStartGateway(t *testing.T) {
197
236
},
198
237
expectedErr : errors .New ("invalid URL scheme:" ),
199
238
},
239
+ {
240
+ name : "invalid alertmanager proxy" ,
241
+ config : & Config {
242
+ Distributor : Upstream {
243
+ URL : distributorServer .URL ,
244
+ Paths : []string {},
245
+ },
246
+ QueryFrontend : Upstream {
247
+ URL : frontendServer .URL ,
248
+ Paths : []string {},
249
+ },
250
+ },
251
+ expectedErr : errors .New ("invalid URL scheme:" ),
252
+ },
200
253
}
201
254
202
255
for _ , tc := range testCases {
0 commit comments