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

Function TestQuerySuccessOnce

proxyretry_test.go:81–118  ·  view source on GitHub ↗

TestRunQuerySuccessOnce function statResponseWriter's statusCode will be StatusOK after executeWithRetry, the query has been proxied The execution will succeeded without retry

(t *testing.T)

Source from the content-addressed store, hash-verified

79// TestRunQuerySuccessOnce function statResponseWriter's statusCode will be StatusOK after executeWithRetry, the query has been proxied
80// The execution will succeeded without retry
81func TestQuerySuccessOnce(t *testing.T) {
82 body := "foo query"
83
84 req := newRequest("http://localhost:8090", body)
85
86 mhs := &mockHosts{
87 t: t,
88 b: body,
89 hs: []string{"localhost:8080", "localhost:8090"},
90 }
91
92 s := newMockScope(mhs.hs)
93
94 srw := mockStatRW(s)
95
96 mrw := &mockResponseWriterWithCode{
97 statusCode: 0,
98 }
99
100 retryNum := 1
101
102 _, err := executeWithRetry(
103 context.Background(),
104 s,
105 retryNum,
106 mhs.mockReverseProxy,
107 mrw,
108 srw,
109 req,
110 func(f float64) {},
111 func(l prometheus.Labels) {},
112 )
113 if err != nil {
114 t.Errorf("The execution with retry failed, %v", err)
115 }
116 assert.Equal(t, mhs.hst, []string{mhs.hs[1]})
117 assert.Equal(t, srw.statusCode, 200)
118}
119
120// TestQueryWithRetrySuccess function statResponseWriter's statusCode will be StatusOK after executeWithRetry, the query has been proxied
121// The execution will succeeded after retry

Callers

nothing calls this directly

Calls 4

newRequestFunction · 0.85
newMockScopeFunction · 0.85
mockStatRWFunction · 0.85
executeWithRetryFunction · 0.85

Tested by

no test coverage detected