Skip to content

Commit

Permalink
refactor(storagetest): remove duplicate batched store interface (#4227)
Browse files Browse the repository at this point in the history
  • Loading branch information
mrekucci authored Jul 14, 2023
1 parent 0b9182f commit f0fa793
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 13 deletions.
10 changes: 2 additions & 8 deletions pkg/storage/storagetest/batch.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,7 @@ import (
"github.com/google/go-cmp/cmp"
)

// BatchedStore is a store that provides batch operations.
type BatchedStore interface {
storage.Store
storage.Batcher
}

func TestBatchedStore(t *testing.T, bs BatchedStore) {
func TestBatchedStore(t *testing.T, bs storage.BatchedStore) {
item := &obj1{Id: "id", SomeInt: 1, Buf: []byte("data")}

t.Run("duplicates are rejected", func(t *testing.T) {
Expand Down Expand Up @@ -100,7 +94,7 @@ func TestBatchedStore(t *testing.T, bs BatchedStore) {
if err := batch.Commit(); err != nil {
t.Fatalf("Commit(): unexpected error: %v", err)
}
if err := batch.Commit(); err == nil { // TODO: replace with sentinel error.
if err := batch.Commit(); err == nil {
t.Fatal("Commit(): expected error; have none")
}
})
Expand Down
10 changes: 5 additions & 5 deletions pkg/storage/storagetest/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -851,7 +851,7 @@ func BenchmarkStore(b *testing.B, s storage.Store) {

// BenchmarkBatchedStore provides a benchmark suite for the
// storage.BatchedStore. Only the Write and Delete methods are tested.
func BenchmarkBatchedStore(b *testing.B, bs BatchedStore) {
func BenchmarkBatchedStore(b *testing.B, bs storage.BatchedStore) {
b.Run("WriteInBatches", func(b *testing.B) {
BenchmarkWriteInBatches(b, bs)
})
Expand Down Expand Up @@ -946,7 +946,7 @@ func BenchmarkWriteSequential(b *testing.B, db storage.Store) {
doWrite(b, db, g)
}

func BenchmarkWriteInBatches(b *testing.B, bs BatchedStore) {
func BenchmarkWriteInBatches(b *testing.B, bs storage.BatchedStore) {
g := newSequentialEntryGenerator(b.N)
batch, _ := bs.Batch(context.Background())
resetBenchmark(b)
Expand All @@ -965,7 +965,7 @@ func BenchmarkWriteInBatches(b *testing.B, bs BatchedStore) {
}
}

func BenchmarkWriteInFixedSizeBatches(b *testing.B, bs BatchedStore) {
func BenchmarkWriteInFixedSizeBatches(b *testing.B, bs storage.BatchedStore) {
g := newSequentialEntryGenerator(b.N)
writer := newBatchDBWriter(bs)
resetBenchmark(b)
Expand Down Expand Up @@ -1016,7 +1016,7 @@ func BenchmarkDeleteSequential(b *testing.B, db storage.Store) {
doDelete(b, db, g)
}

func BenchmarkDeleteInBatches(b *testing.B, bs BatchedStore) {
func BenchmarkDeleteInBatches(b *testing.B, bs storage.BatchedStore) {
g := newSequentialEntryGenerator(b.N)
doWrite(b, bs, g)
resetBenchmark(b)
Expand All @@ -1034,7 +1034,7 @@ func BenchmarkDeleteInBatches(b *testing.B, bs BatchedStore) {
}
}

func BenchmarkDeleteInFixedSizeBatches(b *testing.B, bs BatchedStore) {
func BenchmarkDeleteInFixedSizeBatches(b *testing.B, bs storage.BatchedStore) {
g := newSequentialEntryGenerator(b.N)
doWrite(b, bs, g)
resetBenchmark(b)
Expand Down

0 comments on commit f0fa793

Please sign in to comment.