Diagnose Storage Panic Bugfixes (#11923)

* partial

* fix raft panics and ensure checks are skipped if storage isnt initialized

* cleanup directories

* newline

* typo in nil check

* another nil check
This commit is contained in:
Hridoy Roy
2021-06-24 09:56:38 -07:00
committed by GitHub
parent 7b437de597
commit 25346e824e
6 changed files with 56 additions and 17 deletions

View File

@@ -6,6 +6,7 @@ import (
"context"
"fmt"
"io/ioutil"
"os"
"strings"
"testing"
@@ -176,12 +177,11 @@ func TestOperatorDiagnoseCommand_Run(t *testing.T) {
[]*diagnose.Result{
{
Name: "storage",
Status: diagnose.ErrorStatus,
Status: diagnose.WarningStatus,
Children: []*diagnose.Result{
{
Name: "create-storage-backend",
Status: diagnose.ErrorStatus,
Message: "failed to open bolt file",
Name: "create-storage-backend",
Status: diagnose.OkStatus,
},
{
Name: "raft folder permission checks",
@@ -190,8 +190,8 @@ func TestOperatorDiagnoseCommand_Run(t *testing.T) {
},
{
Name: "raft quorum",
Status: diagnose.ErrorStatus,
Message: "could not determine quorum status",
Status: diagnose.WarningStatus,
Message: "even number of voters found",
},
},
},
@@ -378,6 +378,26 @@ func TestOperatorDiagnoseCommand_Run(t *testing.T) {
},
},
},
{
"diagnose_raft_no_folder_backend",
[]string{
"-config", "./server/test-fixtures/diagnose_raft_no_bolt_folder.hcl",
},
[]*diagnose.Result{
{
Name: "storage",
Status: diagnose.ErrorStatus,
Message: "Diagnose could not initialize storage backend.",
Children: []*diagnose.Result{
{
Name: "create-storage-backend",
Status: diagnose.ErrorStatus,
Message: "no such file or directory",
},
},
},
},
},
}
t.Run("validations", func(t *testing.T) {
@@ -459,5 +479,9 @@ func compareResult(exp *diagnose.Result, act *diagnose.Result) error {
return compareResults(exp.Children, act.Children)
}
// Remove raft file if it exists
os.Remove("./server/test-fixtures/vault.db")
os.RemoveAll("./server/test-fixtures/raft")
return nil
}