forked from thanos-io/objstore
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy paths3_e2e_test.go
54 lines (44 loc) · 1.47 KB
/
s3_e2e_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
// Copyright (c) The Thanos Authors.
// Licensed under the Apache License 2.0.
package s3_test
import (
"bytes"
"context"
"strings"
"testing"
"github.com/efficientgo/e2e"
"github.com/efficientgo/tools/core/pkg/testutil"
"github.com/go-kit/log"
"github.com/thanos-io/objstore/providers/s3"
"github.com/thanos-io/objstore/test/e2e/e2ethanos"
)
// Regression benchmark for https://github.com/thanos-io/thanos/issues/3917 and https://github.com/thanos-io/thanos/issues/3967.
// $ export ver=v1 && go test ./pkg/objstore/s3/... -run '^$' -bench '^BenchmarkUpload' -benchtime 5s -count 5 \
// -memprofile=${ver}.mem.pprof -cpuprofile=${ver}.cpu.pprof | tee ${ver}.txt .
func BenchmarkUpload(b *testing.B) {
b.ReportAllocs()
ctx := context.Background()
e, err := e2e.NewDockerEnvironment("e2e_bench_mino_client", e2e.WithLogger(log.NewNopLogger()))
testutil.Ok(b, err)
b.Cleanup(e2ethanos.CleanScenario(b, e))
const bucket = "benchmark"
m := e2ethanos.NewMinio(e, "benchmark", bucket)
testutil.Ok(b, e2e.StartAndWaitReady(m))
bkt, err := s3.NewBucketWithConfig(
log.NewNopLogger(),
e2ethanos.NewS3Config(bucket, m.Endpoint("https"), m.Dir()),
"test-feed",
)
testutil.Ok(b, err)
buf := bytes.Buffer{}
buf.Grow(1028 * 1028 * 100) // 100MB.
word := "abcdefghij"
for i := 0; i < buf.Cap()/len(word); i++ {
_, _ = buf.WriteString(word)
}
str := buf.String()
b.ResetTimer()
for i := 0; i < b.N; i++ {
testutil.Ok(b, bkt.Upload(ctx, "test", strings.NewReader(str)))
}
}