reverting the tests to not use metrics when unnecessary (#10350)

This commit is contained in:
Hridoy Roy 2020-11-11 15:35:09 -08:00 committed by GitHub
parent d511cef5df
commit c5aa1c715f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 28 additions and 28 deletions

View File

@ -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",
@ -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
@ -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,
@ -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,
@ -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,
@ -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",
@ -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,
@ -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)
@ -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
}
@ -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)
}
@ -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
}
@ -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
}

View File

@ -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",
@ -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
@ -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",
@ -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,
@ -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)
@ -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
}
@ -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)
@ -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
}
@ -652,7 +652,7 @@ 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)
@ -660,13 +660,13 @@ func TestCore_Remount_Protected(t *testing.T) {
}
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{
@ -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()
@ -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
}
@ -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
}