Skip to content

Commit

Permalink
update createBackendWithStorage, and similar functions, to use testin…
Browse files Browse the repository at this point in the history
…g.TB to be usable both by benchs and tests
  • Loading branch information
dysosmus committed Jun 9, 2020
1 parent 40719ca commit 6341b24
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 21 deletions.
8 changes: 4 additions & 4 deletions builtin/logical/transit/backend_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const (
testPlaintext = "the quick brown fox"
)

func createBackendWithStorage(t *testing.T) (*backend, logical.Storage) {
func createBackendWithStorage(t testing.TB) (*backend, logical.Storage) {
config := logical.TestBackendConfig()
config.StorageView = &logical.InmemStorage{}

Expand All @@ -42,7 +42,7 @@ func createBackendWithStorage(t *testing.T) (*backend, logical.Storage) {
return b, config.StorageView
}

func createBackendWithSysView(t *testing.T) (*backend, logical.Storage) {
func createBackendWithSysView(t testing.TB) (*backend, logical.Storage) {
sysView := logical.TestSystemView()
storage := &logical.InmemStorage{}

Expand All @@ -64,7 +64,7 @@ func createBackendWithSysView(t *testing.T) (*backend, logical.Storage) {
return b, storage
}

func createBackendWithSysViewWithStorage(t *testing.T, s logical.Storage) *backend {
func createBackendWithSysViewWithStorage(t testing.TB, s logical.Storage) *backend {
sysView := logical.TestSystemView()

conf := &logical.BackendConfig{
Expand All @@ -85,7 +85,7 @@ func createBackendWithSysViewWithStorage(t *testing.T, s logical.Storage) *backe
return b
}

func createBackendWithForceNoCacheWithSysViewWithStorage(t *testing.T, s logical.Storage) *backend {
func createBackendWithForceNoCacheWithSysViewWithStorage(t testing.TB, s logical.Storage) *backend {
sysView := logical.TestSystemView()
sysView.CachingDisabledVal = true

Expand Down
17 changes: 1 addition & 16 deletions builtin/logical/transit/path_decrypt_bench_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,6 @@ import (
"github.com/hashicorp/vault/sdk/logical"
)

func createBenchBackendWithStorage(b *testing.B) (*backend, logical.Storage) {
config := logical.TestBackendConfig()
config.StorageView = &logical.InmemStorage{}

backend, _ := Backend(context.Background(), config)
if b == nil {
b.Fatalf("failed to create backend")
}
err := backend.Backend.Setup(context.Background(), config)
if err != nil {
b.Fatal(err)
}
return backend, config.StorageView
}

func BenchmarkTransit_BatchDecryption1(b *testing.B) {
BTransit_BatchDecryption(b, 1)
}
Expand Down Expand Up @@ -52,7 +37,7 @@ func BTransit_BatchDecryption(b *testing.B, bsize int) {
var resp *logical.Response
var err error

backend, s := createBenchBackendWithStorage(b)
backend, s := createBackendWithStorage(b)

batchEncryptionInput := make([]interface{}, 0, bsize)
for i := 0; i < bsize; i++ {
Expand Down
2 changes: 1 addition & 1 deletion builtin/logical/transit/path_encrypt_bench_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func BTransit_BatchEncryption(b *testing.B, bsize int) {
var resp *logical.Response
var err error

backend, s := createBenchBackendWithStorage(b)
backend, s := createBackendWithStorage(b)

batchEncryptionInput := make([]interface{}, 0, bsize)
for i := 0; i < bsize; i++ {
Expand Down

0 comments on commit 6341b24

Please sign in to comment.