MCPcopy Create free account
hub / github.com/ContentSquare/chproxy / TestReverseProxy_ServeHTTPConcurrent

Function TestReverseProxy_ServeHTTPConcurrent

proxy_test.go:933–962  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

931}
932
933func TestReverseProxy_ServeHTTPConcurrent(t *testing.T) {
934 addr, err := url.Parse(fakeServer.URL)
935 if err != nil {
936 t.Fatalf("unexpected error: %s", err)
937 }
938 goodCfg.Clusters[0].Nodes = []string{addr.Host}
939 proxy, err := newConfiguredProxy(goodCfg)
940 if err != nil {
941 t.Fatalf("unexpected error: %s", err)
942 }
943 t.Run("parallel requests", func(t *testing.T) {
944 f := func() {
945 req := httptest.NewRequest("GET", fmt.Sprintf("%s/fast", fakeServer.URL), nil)
946 makeCustomRequest(proxy, req)
947 }
948 if err := testConcurrent(f, 500); err != nil {
949 t.Fatalf("concurrent test err: %s", err)
950 }
951 })
952 t.Run("parallel requests with config reloading", func(t *testing.T) {
953 f := func() {
954 proxy.applyConfig(newConfig())
955 req := httptest.NewRequest("GET", fmt.Sprintf("%s/fast", fakeServer.URL), nil)
956 makeCustomRequest(proxy, req)
957 }
958 if err := testConcurrent(f, 100); err != nil {
959 t.Fatalf("concurrent test err: %s", err)
960 }
961 })
962}
963
964func TestReverseProxy_ServeHTTP2(t *testing.T) {
965 testCases := []struct {

Callers

nothing calls this directly

Calls 5

newConfiguredProxyFunction · 0.85
makeCustomRequestFunction · 0.85
testConcurrentFunction · 0.85
newConfigFunction · 0.85
applyConfigMethod · 0.80

Tested by

no test coverage detected