|
@@ -212,20 +212,21 @@ func TestDSRouteRule(t *testing.T) {
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
Convey("When proxying graphite", func() {
|
|
Convey("When proxying graphite", func() {
|
|
|
|
|
+ setting.BuildVersion = "5.3.0"
|
|
|
plugin := &plugins.DataSourcePlugin{}
|
|
plugin := &plugins.DataSourcePlugin{}
|
|
|
ds := &m.DataSource{Url: "htttp://graphite:8080", Type: m.DS_GRAPHITE}
|
|
ds := &m.DataSource{Url: "htttp://graphite:8080", Type: m.DS_GRAPHITE}
|
|
|
ctx := &m.ReqContext{}
|
|
ctx := &m.ReqContext{}
|
|
|
|
|
|
|
|
proxy := NewDataSourceProxy(ds, plugin, ctx, "/render")
|
|
proxy := NewDataSourceProxy(ds, plugin, ctx, "/render")
|
|
|
|
|
+ req, err := http.NewRequest(http.MethodGet, "http://grafana.com/sub", nil)
|
|
|
|
|
+ So(err, ShouldBeNil)
|
|
|
|
|
|
|
|
- requestURL, _ := url.Parse("http://grafana.com/sub")
|
|
|
|
|
- req := http.Request{URL: requestURL, Header: http.Header{}}
|
|
|
|
|
-
|
|
|
|
|
- proxy.getDirector()(&req)
|
|
|
|
|
|
|
+ proxy.getDirector()(req)
|
|
|
|
|
|
|
|
Convey("Can translate request url and path", func() {
|
|
Convey("Can translate request url and path", func() {
|
|
|
So(req.URL.Host, ShouldEqual, "graphite:8080")
|
|
So(req.URL.Host, ShouldEqual, "graphite:8080")
|
|
|
So(req.URL.Path, ShouldEqual, "/render")
|
|
So(req.URL.Path, ShouldEqual, "/render")
|
|
|
|
|
+ So(req.Header.Get("User-Agent"), ShouldEqual, "Grafana/5.3.0")
|
|
|
})
|
|
})
|
|
|
})
|
|
})
|
|
|
|
|
|
|
@@ -243,10 +244,10 @@ func TestDSRouteRule(t *testing.T) {
|
|
|
ctx := &m.ReqContext{}
|
|
ctx := &m.ReqContext{}
|
|
|
proxy := NewDataSourceProxy(ds, plugin, ctx, "")
|
|
proxy := NewDataSourceProxy(ds, plugin, ctx, "")
|
|
|
|
|
|
|
|
- requestURL, _ := url.Parse("http://grafana.com/sub")
|
|
|
|
|
- req := http.Request{URL: requestURL, Header: http.Header{}}
|
|
|
|
|
|
|
+ req, err := http.NewRequest(http.MethodGet, "http://grafana.com/sub", nil)
|
|
|
|
|
+ So(err, ShouldBeNil)
|
|
|
|
|
|
|
|
- proxy.getDirector()(&req)
|
|
|
|
|
|
|
+ proxy.getDirector()(req)
|
|
|
|
|
|
|
|
Convey("Should add db to url", func() {
|
|
Convey("Should add db to url", func() {
|
|
|
So(req.URL.Path, ShouldEqual, "/db/site/")
|
|
So(req.URL.Path, ShouldEqual, "/db/site/")
|