Skip to content

Commit

Permalink
reverting the tests to not use metrics when unnecessary (#10350)
Browse files Browse the repository at this point in the history
  • Loading branch information
HridoyRoy committed Nov 11, 2020
1 parent c745eaf commit 3abc7ee
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 28 deletions.
24 changes: 12 additions & 12 deletions vault/auth_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
)

func TestAuth_ReadOnlyViewDuringMount(t *testing.T) {
c, _, _, _ := TestCoreUnsealedWithMetrics(t)
c, _, _ := TestCoreUnsealed(t)
c.credentialBackends["noop"] = func(ctx context.Context, config *logical.BackendConfig) (logical.Backend, error) {
err := config.StorageView.Put(ctx, &logical.StorageEntry{
Key: "bar",
Expand Down Expand Up @@ -108,7 +108,7 @@ func TestAuthMountMetrics(t *testing.T) {
}

func TestCore_DefaultAuthTable(t *testing.T) {
c, keys, _, _ := TestCoreUnsealedWithMetrics(t)
c, keys, _ := TestCoreUnsealed(t)
verifyDefaultAuthTable(t, c.auth)

// Start a second core with same physical
Expand Down Expand Up @@ -141,7 +141,7 @@ func TestCore_DefaultAuthTable(t *testing.T) {
}

func TestCore_EnableCredential(t *testing.T) {
c, keys, _, _ := TestCoreUnsealedWithMetrics(t)
c, keys, _ := TestCoreUnsealed(t)
c.credentialBackends["noop"] = func(context.Context, *logical.BackendConfig) (logical.Backend, error) {
return &NoopBackend{
BackendType: logical.TypeCredential,
Expand Down Expand Up @@ -200,7 +200,7 @@ func TestCore_EnableCredential(t *testing.T) {
// entries, and that upon reading the entries from both are recombined
// correctly
func TestCore_EnableCredential_Local(t *testing.T) {
c, _, _, _ := TestCoreUnsealedWithMetrics(t)
c, _, _ := TestCoreUnsealed(t)
c.credentialBackends["noop"] = func(context.Context, *logical.BackendConfig) (logical.Backend, error) {
return &NoopBackend{
BackendType: logical.TypeCredential,
Expand Down Expand Up @@ -289,7 +289,7 @@ func TestCore_EnableCredential_Local(t *testing.T) {
}

func TestCore_EnableCredential_twice_409(t *testing.T) {
c, _, _, _ := TestCoreUnsealedWithMetrics(t)
c, _, _ := TestCoreUnsealed(t)
c.credentialBackends["noop"] = func(context.Context, *logical.BackendConfig) (logical.Backend, error) {
return &NoopBackend{
BackendType: logical.TypeCredential,
Expand Down Expand Up @@ -319,7 +319,7 @@ func TestCore_EnableCredential_twice_409(t *testing.T) {
}

func TestCore_EnableCredential_Token(t *testing.T) {
c, _, _, _ := TestCoreUnsealedWithMetrics(t)
c, _, _ := TestCoreUnsealed(t)
me := &MountEntry{
Table: credentialTableType,
Path: "foo",
Expand All @@ -332,7 +332,7 @@ func TestCore_EnableCredential_Token(t *testing.T) {
}

func TestCore_DisableCredential(t *testing.T) {
c, keys, _, _ := TestCoreUnsealedWithMetrics(t)
c, keys, _ := TestCoreUnsealed(t)
c.credentialBackends["noop"] = func(context.Context, *logical.BackendConfig) (logical.Backend, error) {
return &NoopBackend{
BackendType: logical.TypeCredential,
Expand Down Expand Up @@ -393,7 +393,7 @@ func TestCore_DisableCredential(t *testing.T) {
}

func TestCore_DisableCredential_Protected(t *testing.T) {
c, _, _, _ := TestCoreUnsealedWithMetrics(t)
c, _, _ := TestCoreUnsealed(t)
err := c.disableCredential(namespace.RootContext(nil), "token")
if err.Error() != "token credential backend cannot be disabled" {
t.Fatalf("err: %v", err)
Expand All @@ -405,7 +405,7 @@ func TestCore_DisableCredential_Cleanup(t *testing.T) {
Login: []string{"login"},
BackendType: logical.TypeCredential,
}
c, _, _, _ := TestCoreUnsealedWithMetrics(t)
c, _, _ := TestCoreUnsealed(t)
c.credentialBackends["noop"] = func(context.Context, *logical.BackendConfig) (logical.Backend, error) {
return noop, nil
}
Expand Down Expand Up @@ -476,7 +476,7 @@ func TestCore_DisableCredential_Cleanup(t *testing.T) {
}

func TestDefaultAuthTable(t *testing.T) {
c, _, _, _ := TestCoreUnsealedWithMetrics(t)
c, _, _ := TestCoreUnsealed(t)
table := c.defaultAuthTable()
verifyDefaultAuthTable(t, table)
}
Expand Down Expand Up @@ -514,7 +514,7 @@ func TestCore_CredentialInitialize(t *testing.T) {
BackendType: logical.TypeCredential,
}, false}

c, _, _, _ := TestCoreUnsealedWithMetrics(t)
c, _, _ := TestCoreUnsealed(t)
c.credentialBackends["initable"] = func(context.Context, *logical.BackendConfig) (logical.Backend, error) {
return backend, nil
}
Expand All @@ -539,7 +539,7 @@ func TestCore_CredentialInitialize(t *testing.T) {
BackendType: logical.TypeCredential,
}, false}

c, _, _, _ := TestCoreUnsealedWithMetrics(t)
c, _, _ := TestCoreUnsealed(t)
c.credentialBackends["initable"] = func(context.Context, *logical.BackendConfig) (logical.Backend, error) {
return backend, nil
}
Expand Down
32 changes: 16 additions & 16 deletions vault/mount_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (
)

func TestMount_ReadOnlyViewDuringMount(t *testing.T) {
c, _, _, _ := TestCoreUnsealedWithMetrics(t)
c, _, _ := TestCoreUnsealed(t)
c.logicalBackends["noop"] = func(ctx context.Context, config *logical.BackendConfig) (logical.Backend, error) {
err := config.StorageView.Put(ctx, &logical.StorageEntry{
Key: "bar",
Expand Down Expand Up @@ -110,7 +110,7 @@ func TestLogicalMountMetrics(t *testing.T) {
}

func TestCore_DefaultMountTable(t *testing.T) {
c, keys, _, _ := TestCoreUnsealedWithMetrics(t)
c, keys, _ := TestCoreUnsealed(t)
verifyDefaultTable(t, c.mounts, 4)

// Start a second core with same physical
Expand Down Expand Up @@ -142,7 +142,7 @@ func TestCore_DefaultMountTable(t *testing.T) {
}

func TestCore_Mount(t *testing.T) {
c, keys, _, _ := TestCoreUnsealedWithMetrics(t)
c, keys, _ := TestCoreUnsealed(t)
me := &MountEntry{
Table: mountTableType,
Path: "foo",
Expand Down Expand Up @@ -190,7 +190,7 @@ func TestCore_Mount(t *testing.T) {
// entries, and that upon reading the entries from both are recombined
// correctly
func TestCore_Mount_Local(t *testing.T) {
c, _, _, _ := TestCoreUnsealedWithMetrics(t)
c, _, _ := TestCoreUnsealed(t)

c.mounts = &MountTable{
Type: mountTableType,
Expand Down Expand Up @@ -289,7 +289,7 @@ func TestCore_Mount_Local(t *testing.T) {
}

func TestCore_Unmount(t *testing.T) {
c, keys, _, _ := TestCoreUnsealedWithMetrics(t)
c, keys, _ := TestCoreUnsealed(t)
err := c.unmount(namespace.RootContext(nil), "secret")
if err != nil {
t.Fatalf("err: %v", err)
Expand Down Expand Up @@ -335,7 +335,7 @@ func TestCore_Unmount_Cleanup(t *testing.T) {

func testCore_Unmount_Cleanup(t *testing.T, causeFailure bool) {
noop := &NoopBackend{}
c, _, root, _ := TestCoreUnsealedWithMetrics(t)
c, _, root := TestCoreUnsealed(t)
c.logicalBackends["noop"] = func(context.Context, *logical.BackendConfig) (logical.Backend, error) {
return noop, nil
}
Expand Down Expand Up @@ -508,15 +508,15 @@ func TestCore_RemountConcurrent(t *testing.T) {

c2MountMap := map[string]interface{}{}
for _, v := range c2.mounts.Entries {

if _, ok := c2MountMap[v.Path]; ok {
t.Fatalf("duplicated mount path found at %s", v.Path)
t.Fatalf("duplicated mount path found at %s", v.Path)
}
c2MountMap[v.Path] = v
}
}
func TestCore_Remount(t *testing.T) {
c, keys, _, _ := TestCoreUnsealedWithMetrics(t)
c, keys, _ := TestCoreUnsealed(t)
err := c.remount(namespace.RootContext(nil), "secret", "foo", true)
if err != nil {
t.Fatalf("err: %v", err)
Expand Down Expand Up @@ -568,7 +568,7 @@ func TestCore_Remount(t *testing.T) {

func TestCore_Remount_Cleanup(t *testing.T) {
noop := &NoopBackend{}
c, _, root, _ := TestCoreUnsealedWithMetrics(t)
c, _, root := TestCoreUnsealed(t)
c.logicalBackends["noop"] = func(context.Context, *logical.BackendConfig) (logical.Backend, error) {
return noop, nil
}
Expand Down Expand Up @@ -652,21 +652,21 @@ func TestCore_Remount_Cleanup(t *testing.T) {
}

func TestCore_Remount_Protected(t *testing.T) {
c, _, _, _ := TestCoreUnsealedWithMetrics(t)
c, _, _ := TestCoreUnsealed(t)
err := c.remount(namespace.RootContext(nil), "sys", "foo", true)
if err.Error() != `cannot remount "sys/"` {
t.Fatalf("err: %v", err)
}
}

func TestDefaultMountTable(t *testing.T) {
c, _, _, _ := TestCoreUnsealedWithMetrics(t)
c, _, _ := TestCoreUnsealed(t)
table := c.defaultMountTable()
verifyDefaultTable(t, table, 3)
}

func TestCore_MountTable_UpgradeToTyped(t *testing.T) {
c, _, _, _ := TestCoreUnsealedWithMetrics(t)
c, _, _ := TestCoreUnsealed(t)

c.auditBackends["noop"] = func(ctx context.Context, config *audit.BackendConfig) (audit.Backend, error) {
return &NoopAudit{
Expand Down Expand Up @@ -868,7 +868,7 @@ func verifyDefaultTable(t *testing.T, table *MountTable, expected int) {
}

func TestSingletonMountTableFunc(t *testing.T) {
c, _, _, _ := TestCoreUnsealedWithMetrics(t)
c, _, _ := TestCoreUnsealed(t)

mounts, auth := c.singletonMountTables()

Expand Down Expand Up @@ -901,7 +901,7 @@ func TestCore_MountInitialize(t *testing.T) {
BackendType: logical.TypeLogical,
}, false}

c, _, _, _ := TestCoreUnsealedWithMetrics(t)
c, _, _ := TestCoreUnsealed(t)
c.logicalBackends["initable"] = func(context.Context, *logical.BackendConfig) (logical.Backend, error) {
return backend, nil
}
Expand All @@ -926,7 +926,7 @@ func TestCore_MountInitialize(t *testing.T) {
BackendType: logical.TypeLogical,
}, false}

c, _, _, _ := TestCoreUnsealedWithMetrics(t)
c, _, _ := TestCoreUnsealed(t)
c.logicalBackends["initable"] = func(context.Context, *logical.BackendConfig) (logical.Backend, error) {
return backend, nil
}
Expand Down

0 comments on commit 3abc7ee

Please sign in to comment.