5b63066c2c
* Create helpers which integrate with OpenTelemetry for diagnose collection * Go mod vendor * consul tls checks * draft for storage end to end check * Comments * Update vault/diagnose/helpers.go Co-authored-by: swayne275 <swayne275@gmail.com> * Add unit test/example * tweak output * More comments * add spot check concept * Get unit tests working on Result structs * Fix unit test * Get unit tests working, and make diagnose sessions local rather than global * Comments * Last comments * No need for init * :| * Fix helpers_test * cleaned up chan logic. Tests next. * fix tests * remove a comment * tests * remove a comment * cosmetic changes Co-authored-by: Scott G. Miller <smiller@hashicorp.com> Co-authored-by: swayne275 <swayne275@gmail.com>
62 lines
1.5 KiB
Go
62 lines
1.5 KiB
Go
package diagnose
|
|
|
|
import (
|
|
"context"
|
|
"strings"
|
|
"testing"
|
|
|
|
"github.com/hashicorp/vault/sdk/physical"
|
|
)
|
|
|
|
func TestStorageTimeout(t *testing.T) {
|
|
|
|
testCases := []struct {
|
|
errSubString string
|
|
mb physical.Backend
|
|
}{
|
|
{
|
|
errSubString: timeOutErr + "operation: Put",
|
|
mb: mockStorageBackend{callType: timeoutCallWrite},
|
|
},
|
|
{
|
|
errSubString: timeOutErr + "operation: Get",
|
|
mb: mockStorageBackend{callType: timeoutCallRead},
|
|
},
|
|
{
|
|
errSubString: timeOutErr + "operation: Delete",
|
|
mb: mockStorageBackend{callType: timeoutCallDelete},
|
|
},
|
|
{
|
|
errSubString: storageErrStringWrite,
|
|
mb: mockStorageBackend{callType: errCallWrite},
|
|
},
|
|
{
|
|
errSubString: storageErrStringDelete,
|
|
mb: mockStorageBackend{callType: errCallDelete},
|
|
},
|
|
{
|
|
errSubString: storageErrStringRead,
|
|
mb: mockStorageBackend{callType: errCallRead},
|
|
},
|
|
{
|
|
errSubString: wrongRWValsPrefix,
|
|
mb: mockStorageBackend{callType: badReadCall},
|
|
},
|
|
{
|
|
errSubString: "",
|
|
mb: mockStorageBackend{callType: ""},
|
|
},
|
|
}
|
|
|
|
for _, tc := range testCases {
|
|
outErr := StorageEndToEndLatencyCheck(context.Background(), tc.mb)
|
|
if tc.errSubString == "" && outErr == nil {
|
|
// this is the success case where the Storage Latency check passes
|
|
continue
|
|
}
|
|
if !strings.Contains(outErr.Error(), tc.errSubString) {
|
|
t.Errorf("wrong error: expected %s to be contained in %s", tc.errSubString, outErr)
|
|
}
|
|
}
|
|
}
|