Add unit-tests for formatting disks during initialization (#2635)

* Add unit-tests for formatting disks during initialization

- Fixed corresponding code at places where it was deviating from the
  tabular spec.

* Added more test cases and simplified algo

... based on feedback from ``go test -coverprofile``.
This commit is contained in:
Krishnan Parthasarathi
2016-09-08 09:35:13 -07:00
committed by Harshavardhana
parent 182109f0de
commit 66459a4ce0
2 changed files with 167 additions and 8 deletions

View File

@@ -60,7 +60,7 @@ func init() {
| Quorum | | "Heal via minioctl" |
| | Quorum UnFormatted | |
+----------+--------------------------+-----------------------+
| No | | Wait till enough |
| No | | Wait till enough |
| Quorum | _ | nodes are online and |
| | | one of the above |
| | | sections apply |
@@ -121,22 +121,28 @@ func prepForInit(disks []string, sErrs []error, diskCount int) InitActions {
return FormatDisks
}
return WaitForFormatting
} else if (disksUnformatted >= quorum) && (disksUnformatted+disksOffline == diskCount) {
return WaitForAll
} else if disksUnformatted >= quorum {
if disksUnformatted+disksOffline == diskCount {
return WaitForAll
}
// Some disks possibly corrupted.
return WaitForHeal
}
// Already formatted, proceed to initialization of object layer.
if disksFormatted == diskCount {
return InitObjectLayer
} else if disksFormatted >= quorum && disksFormatted+disksOffline == diskCount {
return InitObjectLayer
} else if disksFormatted >= quorum {
// TODO: Print minioctl heal command
return InitObjectLayer
if (disksFormatted+disksOffline == diskCount) ||
(disksFormatted+disksUnformatted == diskCount) {
return InitObjectLayer
}
// Some disks possibly corrupted.
return WaitForHeal
}
// No Quorum.
if disksOffline > quorum {
if disksOffline >= quorum {
return WaitForQuorum
}