-
Notifications
You must be signed in to change notification settings - Fork 145
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(render,find): strip private info from returned errors info
- Loading branch information
Showing
15 changed files
with
782 additions
and
273 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package main | ||
|
||
import ( | ||
"strconv" | ||
"testing" | ||
) | ||
|
||
func Test_resortErr(t *testing.T) { | ||
tests := []struct { | ||
errStr string | ||
want string | ||
}{ | ||
{ | ||
errStr: "b: connection refused\na: connection refused\n", | ||
want: "a: connection refused\nb: connection refused\n", | ||
}, | ||
{ | ||
errStr: "a: connection refused\nb: connection refused\n", | ||
want: "a: connection refused\nb: connection refused\n", | ||
}, | ||
{ | ||
errStr: "", | ||
want: "", | ||
}, | ||
{ | ||
errStr: "\n", | ||
want: "\n", | ||
}, | ||
} | ||
for i, tt := range tests { | ||
t.Run(strconv.Itoa(i), func(t *testing.T) { | ||
if got := resortErr(tt.errStr); got != tt.want { | ||
t.Errorf("resortErr(%q) = %q, want %q", tt.errStr, got, tt.want) | ||
} | ||
}) | ||
} | ||
} |
57 changes: 57 additions & 0 deletions
57
cmd/mockbackend/testcases/connection_refused/carbonapi.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
listen: "localhost:8081" | ||
expvar: | ||
enabled: true | ||
pprofEnabled: false | ||
listen: "" | ||
concurency: 1000 | ||
notFoundStatusCode: 200 | ||
cache: | ||
type: "mem" | ||
size_mb: 0 | ||
defaultTimeoutSec: 60 | ||
cpus: 0 | ||
tz: "" | ||
maxBatchSize: 0 | ||
graphite: | ||
host: "" | ||
interval: "60s" | ||
prefix: "carbon.api" | ||
pattern: "{prefix}.{fqdn}" | ||
idleConnections: 10 | ||
pidFile: "" | ||
upstreams: | ||
buckets: 10 | ||
timeouts: | ||
find: "2s" | ||
render: "5s" | ||
connect: "200ms" | ||
concurrencyLimitPerServer: 0 | ||
keepAliveInterval: "30s" | ||
maxIdleConnsPerHost: 100 | ||
backendsv2: | ||
backends: | ||
- | ||
groupName: "mock-001" | ||
protocol: "auto" | ||
lbMethod: "all" | ||
maxTries: 1 | ||
maxBatchSize: 0 | ||
keepAliveInterval: "10s" | ||
concurrencyLimit: 0 | ||
forceAttemptHTTP2: true | ||
maxIdleConnsPerHost: 1000 | ||
timeouts: | ||
find: "3s" | ||
render: "5s" | ||
connect: "200ms" | ||
servers: | ||
- "http://127.0.0.1:9071" | ||
graphite09compat: false | ||
expireDelaySec: 10 | ||
logger: | ||
- logger: "" | ||
file: "stderr" | ||
level: "debug" | ||
encoding: "console" | ||
encodingTime: "iso8601" | ||
encodingDuration: "seconds" |
72 changes: 72 additions & 0 deletions
72
cmd/mockbackend/testcases/connection_refused/connection_refused.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
version: "v1" | ||
test: | ||
apps: | ||
- name: "carbonapi" | ||
binary: "./carbonapi" | ||
args: | ||
- "-config" | ||
- "./cmd/mockbackend/testcases/connection_refused/carbonapi.yaml" | ||
- "-exact-config" | ||
queries: | ||
- endpoint: "http://127.0.0.1:8081" | ||
type: "GET" | ||
URL: "/render/?target=a&format=json" | ||
expectedResponse: | ||
httpCode: 503 | ||
contentType: "text/plain; charset=utf-8" | ||
errBody: "a: connection refused\n" | ||
errSort: true | ||
- endpoint: "http://127.0.0.1:8081" | ||
type: "GET" | ||
URL: "/render/?target=a&target=b&format=json" | ||
expectedResponse: | ||
httpCode: 503 | ||
contentType: "text/plain; charset=utf-8" | ||
errBody: "a: connection refused\nb: connection refused\n" | ||
errSort: true | ||
- endpoint: "http://127.0.0.1:8081" | ||
type: "GET" | ||
URL: "/metrics/find/?query=a&format=json" | ||
expectedResponse: | ||
httpCode: 503 | ||
contentType: "text/plain; charset=utf-8" | ||
errBody: "connection refused\n" | ||
- endpoint: "http://127.0.0.1:8081" | ||
type: "GET" | ||
URL: "/metrics/find/?query=a&query=b&format=json" | ||
expectedResponse: | ||
httpCode: 503 | ||
contentType: "text/plain; charset=utf-8" | ||
errBody: "connection refused\n" | ||
- endpoint: "http://127.0.0.1:8081" | ||
type: "GET" | ||
URL: "/tags/autoComplete/values?expr=tag2%3Dv1&tag=tag4" | ||
expectedResponse: | ||
httpCode: 200 | ||
contentType: "application/json" | ||
expectedResults: | ||
- tagsAutocompelete: [] | ||
# TODO: query must fail | ||
# httpCode: 503 | ||
# contentType: "text/plain; charset=utf-8" | ||
# errBody: "connection refused\n" | ||
# errSort: true | ||
|
||
listeners: | ||
- address: ":9070" | ||
expressions: | ||
"a": | ||
pathExpression: "a" | ||
data: | ||
- metricName: "a" | ||
values: [0,1,2,2,3] | ||
|
||
# timeout | ||
"c": | ||
pathExpression: "c" | ||
code: 404 | ||
replyDelayMS: 7000 | ||
|
||
"d": | ||
pathExpression: "d" | ||
code: 503 |
Oops, something went wrong.