mirror of
https://github.com/minio/minio.git
synced 2025-11-10 05:59:43 -05:00
Fix storage class related issues (#5322)
- Add storage class metadata validation for request header - Change storage class header values to be consistent with AWS S3 - Refactor internal method to take only the reqd argument
This commit is contained in:
committed by
Harshavardhana
parent
f25ec31565
commit
545a9e4a82
@@ -152,11 +152,11 @@ func testValidateSSParity(obj ObjectLayer, instanceType string, dirs []string, t
|
||||
}
|
||||
}
|
||||
|
||||
func TestGetDrivesCount(t *testing.T) {
|
||||
ExecObjectLayerTestWithDirs(t, testGetDrivesCount)
|
||||
func TestRedundancyCount(t *testing.T) {
|
||||
ExecObjectLayerTestWithDirs(t, testGetRedundancyCount)
|
||||
}
|
||||
|
||||
func testGetDrivesCount(obj ObjectLayer, instanceType string, dirs []string, t TestErrHandler) {
|
||||
func testGetRedundancyCount(obj ObjectLayer, instanceType string, dirs []string, t TestErrHandler) {
|
||||
// Reset global storage class flags
|
||||
resetGlobalStorageEnvs()
|
||||
xl := obj.(*xlObjects)
|
||||
@@ -183,7 +183,7 @@ func testGetDrivesCount(obj ObjectLayer, instanceType string, dirs []string, t T
|
||||
if tt.name == 5 {
|
||||
globalStandardStorageClass.Parity = 6
|
||||
}
|
||||
data, parity := getDrivesCount(tt.sc, tt.disks)
|
||||
data, parity := getRedundancyCount(tt.sc, len(tt.disks))
|
||||
if data != tt.expectedData {
|
||||
t.Errorf("Test %d, Expected data disks %d, got %d", tt.name, tt.expectedData, data)
|
||||
return
|
||||
@@ -353,3 +353,25 @@ func testObjectQuorumFromMeta(obj ObjectLayer, instanceType string, dirs []strin
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Test isValidStorageClassMeta method with valid and invalid inputs
|
||||
func TestIsValidStorageClassMeta(t *testing.T) {
|
||||
tests := []struct {
|
||||
name int
|
||||
sc string
|
||||
want bool
|
||||
}{
|
||||
{1, "STANDARD", true},
|
||||
{2, "REDUCED_REDUNDANCY", true},
|
||||
{3, "", false},
|
||||
{4, "INVALID", false},
|
||||
{5, "123", false},
|
||||
{6, "MINIO_STORAGE_CLASS_RRS", false},
|
||||
{7, "MINIO_STORAGE_CLASS_STANDARD", false},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
if got := isValidStorageClassMeta(tt.sc); got != tt.want {
|
||||
t.Errorf("Test %d, Expected Storage Class to be %t, got %t", tt.name, tt.want, got)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user