2021-04-18 15:41:13 -04:00
|
|
|
// Copyright (c) 2015-2021 MinIO, Inc.
|
|
|
|
//
|
|
|
|
// This file is part of MinIO Object Storage stack
|
|
|
|
//
|
|
|
|
// This program is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU Affero General Public License as published by
|
|
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
|
|
// (at your option) any later version.
|
|
|
|
//
|
|
|
|
// This program is distributed in the hope that it will be useful
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU Affero General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU Affero General Public License
|
|
|
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2016-09-28 14:19:07 -04:00
|
|
|
|
|
|
|
package cmd
|
|
|
|
|
|
|
|
import (
|
2020-04-14 20:52:38 -04:00
|
|
|
"context"
|
2017-01-16 20:05:00 -05:00
|
|
|
"reflect"
|
2016-09-28 14:19:07 -04:00
|
|
|
"testing"
|
|
|
|
)
|
|
|
|
|
2017-01-16 20:05:00 -05:00
|
|
|
// Tests initializing new object layer.
|
|
|
|
func TestNewObjectLayer(t *testing.T) {
|
2020-04-14 20:52:38 -04:00
|
|
|
ctx, cancel := context.WithCancel(context.Background())
|
|
|
|
defer cancel()
|
2022-05-30 13:58:37 -04:00
|
|
|
// Tests for ErasureSD object layer.
|
2017-01-16 20:05:00 -05:00
|
|
|
nDisks := 1
|
|
|
|
disks, err := getRandomDisks(nDisks)
|
|
|
|
if err != nil {
|
2022-08-04 19:10:08 -04:00
|
|
|
t.Fatal("Failed to create drives for the backend")
|
2017-01-16 20:05:00 -05:00
|
|
|
}
|
|
|
|
defer removeRoots(disks)
|
|
|
|
|
2023-07-03 12:47:40 -04:00
|
|
|
obj, err := newObjectLayer(ctx, mustGetPoolEndpoints(0, disks...))
|
2017-01-16 20:05:00 -05:00
|
|
|
if err != nil {
|
|
|
|
t.Fatal("Unexpected object layer initialization error", err)
|
|
|
|
}
|
2022-11-01 19:41:01 -04:00
|
|
|
|
|
|
|
_, ok := obj.(*erasureServerPools)
|
2017-01-16 20:05:00 -05:00
|
|
|
if !ok {
|
|
|
|
t.Fatal("Unexpected object layer detected", reflect.TypeOf(obj))
|
|
|
|
}
|
|
|
|
|
2020-06-12 23:04:01 -04:00
|
|
|
// Tests for Erasure object layer initialization.
|
2017-01-16 20:05:00 -05:00
|
|
|
|
|
|
|
// Create temporary backend for the test server.
|
|
|
|
nDisks = 16
|
|
|
|
disks, err = getRandomDisks(nDisks)
|
|
|
|
if err != nil {
|
2022-08-04 19:10:08 -04:00
|
|
|
t.Fatal("Failed to create drives for the backend")
|
2017-01-16 20:05:00 -05:00
|
|
|
}
|
|
|
|
defer removeRoots(disks)
|
|
|
|
|
2023-07-03 12:47:40 -04:00
|
|
|
obj, err = newObjectLayer(ctx, mustGetPoolEndpoints(0, disks...))
|
2017-01-16 20:05:00 -05:00
|
|
|
if err != nil {
|
|
|
|
t.Fatal("Unexpected object layer initialization error", err)
|
|
|
|
}
|
|
|
|
|
2020-12-01 16:50:33 -05:00
|
|
|
_, ok = obj.(*erasureServerPools)
|
2017-01-16 20:05:00 -05:00
|
|
|
if !ok {
|
|
|
|
t.Fatal("Unexpected object layer detected", reflect.TypeOf(obj))
|
|
|
|
}
|
|
|
|
}
|