mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
devenv: add slow reverse proxy (#16943)
this can be useful when testing timeouts etc in the dataproxy ref #16923
This commit is contained in:
parent
17ce1273ca
commit
b426ff5292
@ -13,6 +13,11 @@ datasources:
|
|||||||
access: proxy
|
access: proxy
|
||||||
url: http://localhost:9090
|
url: http://localhost:9090
|
||||||
|
|
||||||
|
- name: gdev-slow-prometheus
|
||||||
|
type: prometheus
|
||||||
|
access: proxy
|
||||||
|
url: http://localhost:3011
|
||||||
|
|
||||||
- name: gdev-testdata
|
- name: gdev-testdata
|
||||||
type: testdata
|
type: testdata
|
||||||
isDefault: true
|
isDefault: true
|
||||||
|
7
devenv/docker/blocks/slow_proxy/Dockerfile
Normal file
7
devenv/docker/blocks/slow_proxy/Dockerfile
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
|
||||||
|
FROM golang:latest
|
||||||
|
ADD main.go /
|
||||||
|
WORKDIR /
|
||||||
|
RUN go build -o main .
|
||||||
|
EXPOSE 3011
|
||||||
|
ENTRYPOINT ["/main"]
|
7
devenv/docker/blocks/slow_proxy/docker-compose.yaml
Normal file
7
devenv/docker/blocks/slow_proxy/docker-compose.yaml
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
slow_proxy:
|
||||||
|
build: docker/blocks/slow_proxy
|
||||||
|
network_mode: host
|
||||||
|
ports:
|
||||||
|
- "3011:3011"
|
||||||
|
environment:
|
||||||
|
ORIGIN_SERVER: "http://localhost:9090/"
|
31
devenv/docker/blocks/slow_proxy/main.go
Normal file
31
devenv/docker/blocks/slow_proxy/main.go
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"log"
|
||||||
|
"net/http"
|
||||||
|
"net/http/httputil"
|
||||||
|
"net/url"
|
||||||
|
"os"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
origin := os.Getenv("ORIGIN_SERVER")
|
||||||
|
if origin == "" {
|
||||||
|
origin = "http://localhost:9090/"
|
||||||
|
}
|
||||||
|
|
||||||
|
sleep := time.Minute
|
||||||
|
|
||||||
|
originURL, _ := url.Parse(origin)
|
||||||
|
proxy := httputil.NewSingleHostReverseProxy(originURL)
|
||||||
|
|
||||||
|
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
fmt.Printf("sleeping for %s then proxying request: %s", sleep.String(), r.RequestURI)
|
||||||
|
<-time.After(sleep)
|
||||||
|
proxy.ServeHTTP(w, r)
|
||||||
|
})
|
||||||
|
|
||||||
|
log.Fatal(http.ListenAndServe(":3011", nil))
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user