server: Add more elaborate startup messages. (#2731)

These messages based on our prep stage during XL
and prints more informative message regarding
drive information.

This change also does a much needed refactoring.
This commit is contained in:
Harshavardhana
2016-10-05 12:48:07 -07:00
committed by GitHub
parent 63a7ca1af0
commit 6494b77d41
61 changed files with 1505 additions and 1340 deletions

View File

@@ -16,10 +16,7 @@
package cmd
import (
"runtime"
"testing"
)
import "testing"
func (action InitActions) String() string {
switch action {
@@ -41,43 +38,8 @@ func (action InitActions) String() string {
return "Unknown"
}
}
func TestPrepForInit(t *testing.T) {
var disks []string
if runtime.GOOS == "windows" {
disks = []string{
`c:\mnt\disk1`,
`c:\mnt\disk2`,
`c:\mnt\disk3`,
`c:\mnt\disk4`,
`c:\mnt\disk5`,
`c:\mnt\disk6`,
`c:\mnt\disk7`,
`c:\mnt\disk8`,
}
} else {
disks = []string{
"/mnt/disk1",
"/mnt/disk2",
"/mnt/disk3",
"/mnt/disk4",
"/mnt/disk5",
"/mnt/disk6",
"/mnt/disk7",
"/mnt/disk8",
}
}
// Building up disks that resolve to localhost and remote w.r.t isLocalStorage().
var (
disksLocal []string
disksRemote []string
)
for i := range disks {
disksLocal = append(disksLocal, "localhost:"+disks[i])
}
// Using 4.4.4.4 as a known non-local address.
for i := range disks {
disksRemote = append(disksRemote, "4.4.4.4:"+disks[i])
}
func TestPrepForInitXL(t *testing.T) {
// All disks are unformatted, a fresh setup.
allUnformatted := []error{
errUnformattedDisk, errUnformattedDisk, errUnformattedDisk, errUnformattedDisk,
@@ -120,32 +82,32 @@ func TestPrepForInit(t *testing.T) {
testCases := []struct {
// Params for prepForInit().
disks []string
firstDisk bool
errs []error
diskCount int
action InitActions
}{
// Local disks.
{disksLocal, allFormatted, 8, InitObjectLayer},
{disksLocal, quorumFormatted, 8, InitObjectLayer},
{disksLocal, allUnformatted, 8, FormatDisks},
{disksLocal, quorumUnformatted, 8, WaitForAll},
{disksLocal, quorumUnformattedSomeCorrupted, 8, WaitForHeal},
{disksLocal, noQuourm, 8, WaitForQuorum},
{disksLocal, minorityCorrupted, 8, WaitForHeal},
{disksLocal, majorityCorrupted, 8, Abort},
{true, allFormatted, 8, InitObjectLayer},
{true, quorumFormatted, 8, InitObjectLayer},
{true, allUnformatted, 8, FormatDisks},
{true, quorumUnformatted, 8, WaitForAll},
{true, quorumUnformattedSomeCorrupted, 8, Abort},
{true, noQuourm, 8, WaitForQuorum},
{true, minorityCorrupted, 8, WaitForHeal},
{true, majorityCorrupted, 8, Abort},
// Remote disks.
{disksRemote, allFormatted, 8, InitObjectLayer},
{disksRemote, quorumFormatted, 8, InitObjectLayer},
{disksRemote, allUnformatted, 8, WaitForFormatting},
{disksRemote, quorumUnformatted, 8, WaitForAll},
{disksRemote, quorumUnformattedSomeCorrupted, 8, WaitForHeal},
{disksRemote, noQuourm, 8, WaitForQuorum},
{disksRemote, minorityCorrupted, 8, WaitForHeal},
{disksRemote, majorityCorrupted, 8, Abort},
{false, allFormatted, 8, InitObjectLayer},
{false, quorumFormatted, 8, InitObjectLayer},
{false, allUnformatted, 8, WaitForFormatting},
{false, quorumUnformatted, 8, WaitForAll},
{false, quorumUnformattedSomeCorrupted, 8, Abort},
{false, noQuourm, 8, WaitForQuorum},
{false, minorityCorrupted, 8, WaitForHeal},
{false, majorityCorrupted, 8, Abort},
}
for i, test := range testCases {
actual := prepForInit(test.disks, test.errs, test.diskCount)
actual := prepForInitXL(test.firstDisk, test.errs, test.diskCount)
if actual != test.action {
t.Errorf("Test %d expected %s but receieved %s\n", i+1, test.action, actual)
}