From 7a516402624ccb838c1a63594a94cf1948d2df61 Mon Sep 17 00:00:00 2001 From: Alexander Neumann Date: Sat, 13 May 2017 21:56:18 +0200 Subject: [PATCH] rest: Add benchmarks --- src/restic/backend/rest/rest_test.go | 53 ++++++++++++++++++---------- 1 file changed, 34 insertions(+), 19 deletions(-) diff --git a/src/restic/backend/rest/rest_test.go b/src/restic/backend/rest/rest_test.go index e8ed57646..d951eea05 100644 --- a/src/restic/backend/rest/rest_test.go +++ b/src/restic/backend/rest/rest_test.go @@ -60,23 +60,8 @@ func runRESTServer(ctx context.Context, t testing.TB, dir string) func() { } } -func TestBackendREST(t *testing.T) { - defer func() { - if t.Skipped() { - SkipDisallowed(t, "restic/backend/rest.TestBackendREST") - } - }() - - ctx, cancel := context.WithCancel(context.Background()) - defer cancel() - - dir, cleanup := TempDir(t) - defer cleanup() - - cleanup = runRESTServer(ctx, t, dir) - defer cleanup() - - suite := test.Suite{ +func newTestSuite(ctx context.Context, t testing.TB) *test.Suite { + return &test.Suite{ // NewConfig returns a config for a new temporary backend that will be used in tests. NewConfig: func() (interface{}, error) { dir, err := ioutil.TempDir(TestTempDir, "restic-test-rest-") @@ -114,6 +99,36 @@ func TestBackendREST(t *testing.T) { return nil }, } - - suite.RunTests(t) +} + +func TestBackendREST(t *testing.T) { + defer func() { + if t.Skipped() { + SkipDisallowed(t, "restic/backend/rest.TestBackendREST") + } + }() + + ctx, cancel := context.WithCancel(context.Background()) + defer cancel() + + dir, cleanup := TempDir(t) + defer cleanup() + + cleanup = runRESTServer(ctx, t, dir) + defer cleanup() + + newTestSuite(ctx, t).RunTests(t) +} + +func BenchmarkBackendREST(t *testing.B) { + ctx, cancel := context.WithCancel(context.Background()) + defer cancel() + + dir, cleanup := TempDir(t) + defer cleanup() + + cleanup = runRESTServer(ctx, t, dir) + defer cleanup() + + newTestSuite(ctx, t).RunBenchmarks(t) }