From fc8e9c6572e5858e0ee4c33ad5acb321db5020fb Mon Sep 17 00:00:00 2001 From: Egon Elbre Date: Thu, 6 Dec 2018 14:32:21 +0200 Subject: [PATCH] Move irreparabledb under datarepair (#764) --- pkg/datarepair/checker/checker.go | 2 +- pkg/datarepair/checker/checker_test.go | 2 +- pkg/datarepair/checker/config.go | 2 +- pkg/{ => datarepair}/irreparabledb/dbx/gen.go | 0 .../irreparabledb/dbx/irreparabledb.dbx | 0 .../irreparabledb/dbx/irreparabledb.dbx.go | 0 .../dbx/irreparabledb.dbx.postgres.sql | 0 .../dbx/irreparabledb.dbx.sqlite3.sql | 0 .../irreparabledb/irreparabledb.go | 9 +++++++-- .../irreparabledb/irreparabledb_test.go | 18 ++++++++++-------- pkg/irreparabledb/common.go | 11 ----------- 11 files changed, 20 insertions(+), 24 deletions(-) rename pkg/{ => datarepair}/irreparabledb/dbx/gen.go (100%) rename pkg/{ => datarepair}/irreparabledb/dbx/irreparabledb.dbx (100%) rename pkg/{ => datarepair}/irreparabledb/dbx/irreparabledb.dbx.go (100%) rename pkg/{ => datarepair}/irreparabledb/dbx/irreparabledb.dbx.postgres.sql (100%) rename pkg/{ => datarepair}/irreparabledb/dbx/irreparabledb.dbx.sqlite3.sql (100%) rename pkg/{ => datarepair}/irreparabledb/irreparabledb.go (93%) rename pkg/{ => datarepair}/irreparabledb/irreparabledb_test.go (79%) delete mode 100644 pkg/irreparabledb/common.go diff --git a/pkg/datarepair/checker/checker.go b/pkg/datarepair/checker/checker.go index 17a2fcb65..6a12d0903 100644 --- a/pkg/datarepair/checker/checker.go +++ b/pkg/datarepair/checker/checker.go @@ -10,8 +10,8 @@ import ( "github.com/gogo/protobuf/proto" "go.uber.org/zap" + "storj.io/storj/pkg/datarepair/irreparabledb" "storj.io/storj/pkg/datarepair/queue" - "storj.io/storj/pkg/irreparabledb" "storj.io/storj/pkg/pb" "storj.io/storj/pkg/pointerdb" "storj.io/storj/pkg/storj" diff --git a/pkg/datarepair/checker/checker_test.go b/pkg/datarepair/checker/checker_test.go index a9c2219f7..f11b1d695 100644 --- a/pkg/datarepair/checker/checker_test.go +++ b/pkg/datarepair/checker/checker_test.go @@ -17,8 +17,8 @@ import ( "storj.io/storj/internal/teststorj" "storj.io/storj/pkg/auth" + "storj.io/storj/pkg/datarepair/irreparabledb" "storj.io/storj/pkg/datarepair/queue" - "storj.io/storj/pkg/irreparabledb" "storj.io/storj/pkg/overlay" "storj.io/storj/pkg/overlay/mocks" "storj.io/storj/pkg/pb" diff --git a/pkg/datarepair/checker/config.go b/pkg/datarepair/checker/config.go index 30beb785b..afe2fadd6 100644 --- a/pkg/datarepair/checker/config.go +++ b/pkg/datarepair/checker/config.go @@ -9,8 +9,8 @@ import ( "go.uber.org/zap" + "storj.io/storj/pkg/datarepair/irreparabledb" "storj.io/storj/pkg/datarepair/queue" - "storj.io/storj/pkg/irreparabledb" "storj.io/storj/pkg/overlay" mock "storj.io/storj/pkg/overlay/mocks" "storj.io/storj/pkg/pb" diff --git a/pkg/irreparabledb/dbx/gen.go b/pkg/datarepair/irreparabledb/dbx/gen.go similarity index 100% rename from pkg/irreparabledb/dbx/gen.go rename to pkg/datarepair/irreparabledb/dbx/gen.go diff --git a/pkg/irreparabledb/dbx/irreparabledb.dbx b/pkg/datarepair/irreparabledb/dbx/irreparabledb.dbx similarity index 100% rename from pkg/irreparabledb/dbx/irreparabledb.dbx rename to pkg/datarepair/irreparabledb/dbx/irreparabledb.dbx diff --git a/pkg/irreparabledb/dbx/irreparabledb.dbx.go b/pkg/datarepair/irreparabledb/dbx/irreparabledb.dbx.go similarity index 100% rename from pkg/irreparabledb/dbx/irreparabledb.dbx.go rename to pkg/datarepair/irreparabledb/dbx/irreparabledb.dbx.go diff --git a/pkg/irreparabledb/dbx/irreparabledb.dbx.postgres.sql b/pkg/datarepair/irreparabledb/dbx/irreparabledb.dbx.postgres.sql similarity index 100% rename from pkg/irreparabledb/dbx/irreparabledb.dbx.postgres.sql rename to pkg/datarepair/irreparabledb/dbx/irreparabledb.dbx.postgres.sql diff --git a/pkg/irreparabledb/dbx/irreparabledb.dbx.sqlite3.sql b/pkg/datarepair/irreparabledb/dbx/irreparabledb.dbx.sqlite3.sql similarity index 100% rename from pkg/irreparabledb/dbx/irreparabledb.dbx.sqlite3.sql rename to pkg/datarepair/irreparabledb/dbx/irreparabledb.dbx.sqlite3.sql diff --git a/pkg/irreparabledb/irreparabledb.go b/pkg/datarepair/irreparabledb/irreparabledb.go similarity index 93% rename from pkg/irreparabledb/irreparabledb.go rename to pkg/datarepair/irreparabledb/irreparabledb.go index b9d9252c5..96cd157cf 100644 --- a/pkg/irreparabledb/irreparabledb.go +++ b/pkg/datarepair/irreparabledb/irreparabledb.go @@ -6,11 +6,16 @@ package irreparabledb import ( "context" + "github.com/zeebo/errs" + "storj.io/storj/internal/migrate" - dbx "storj.io/storj/pkg/irreparabledb/dbx" + dbx "storj.io/storj/pkg/datarepair/irreparabledb/dbx" "storj.io/storj/pkg/utils" ) +// Error is the default irreparabledb errs class +var Error = errs.Class("irreparabledb error") + // Database implements the irreparable RPC service type Database struct { db *dbx.DB @@ -109,7 +114,7 @@ func (db *Database) Delete(ctx context.Context, segmentPath []byte) (err error) return err } -// Close close db connection +// Close close db connection func (db *Database) Close() (err error) { return db.db.Close() } diff --git a/pkg/irreparabledb/irreparabledb_test.go b/pkg/datarepair/irreparabledb/irreparabledb_test.go similarity index 79% rename from pkg/irreparabledb/irreparabledb_test.go rename to pkg/datarepair/irreparabledb/irreparabledb_test.go index 40d5db193..4d840a910 100644 --- a/pkg/irreparabledb/irreparabledb_test.go +++ b/pkg/datarepair/irreparabledb/irreparabledb_test.go @@ -1,7 +1,7 @@ // Copyright (C) 2018 Storj Labs, Inc. // See LICENSE for copying information. -package irreparabledb +package irreparabledb_test import ( "context" @@ -11,11 +11,13 @@ import ( "time" "github.com/stretchr/testify/assert" + "storj.io/storj/internal/testcontext" + "storj.io/storj/pkg/datarepair/irreparabledb" ) const ( - // this connstring is expected to work under the storj-test docker-compose instance + // postgres connstring that works with docker-compose defaultPostgresConn = "postgres://storj:storj-pass@test-postgres/teststorj?sslmode=disable" ) @@ -32,11 +34,11 @@ func TestPostgres(t *testing.T) { defer ctx.Cleanup() // creating in-memory db and opening connection - irrdb, err := New(*testPostgres) + irrdb, err := irreparabledb.New(*testPostgres) if err != nil { t.Fatal(err) } - defer ctx.Check(irrdb.db.Close) + defer ctx.Check(irrdb.Close) testDatabase(ctx, t, irrdb) } @@ -46,18 +48,18 @@ func TestSqlite3(t *testing.T) { defer ctx.Cleanup() // creating in-memory db and opening connection - irrdb, err := New("sqlite3://file::memory:?mode=memory&cache=shared") + irrdb, err := irreparabledb.New("sqlite3://file::memory:?mode=memory&cache=shared") if err != nil { t.Fatal(err) } - defer ctx.Check(irrdb.db.Close) + defer ctx.Check(irrdb.Close) testDatabase(ctx, t, irrdb) } -func testDatabase(ctx context.Context, t *testing.T, irrdb *Database) { +func testDatabase(ctx context.Context, t *testing.T, irrdb *irreparabledb.Database) { //testing variables - segmentInfo := &RemoteSegmentInfo{ + segmentInfo := &irreparabledb.RemoteSegmentInfo{ EncryptedSegmentPath: []byte("IamSegmentkeyinfo"), EncryptedSegmentDetail: []byte("IamSegmentdetailinfo"), LostPiecesCount: int64(10), diff --git a/pkg/irreparabledb/common.go b/pkg/irreparabledb/common.go deleted file mode 100644 index 2fa4686a3..000000000 --- a/pkg/irreparabledb/common.go +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright (C) 2018 Storj Labs, Inc. -// See LICENSE for copying information. - -package irreparabledb - -import ( - "github.com/zeebo/errs" -) - -// Error is the default boltdb errs class -var Error = errs.Class("irreparabaledb error")