TestRunQuerySuccessOnce function statResponseWriter's statusCode will be StatusOK after executeWithRetry, the query has been proxied The execution will succeeded without retry
(t *testing.T)
| 79 | // TestRunQuerySuccessOnce function statResponseWriter's statusCode will be StatusOK after executeWithRetry, the query has been proxied |
| 80 | // The execution will succeeded without retry |
| 81 | func 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 |
nothing calls this directly
no test coverage detected