2021-04-18 19:41:13 +00: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 18:19:07 +00:00
|
|
|
|
|
|
|
package cmd
|
|
|
|
|
|
|
|
import (
|
2020-04-15 00:52:38 +00:00
|
|
|
"context"
|
2017-01-17 01:05:00 +00:00
|
|
|
"reflect"
|
2016-09-28 18:19:07 +00:00
|
|
|
"testing"
|
|
|
|
)
|
|
|
|
|
2017-01-17 01:05:00 +00:00
|
|
|
// Tests initializing new object layer.
|
|
|
|
func TestNewObjectLayer(t *testing.T) {
|
2020-04-15 00:52:38 +00:00
|
|
|
ctx, cancel := context.WithCancel(context.Background())
|
|
|
|
defer cancel()
|
2022-05-30 17:58:37 +00:00
|
|
|
// Tests for ErasureSD object layer.
|
2017-01-17 01:05:00 +00:00
|
|
|
nDisks := 1
|
|
|
|
disks, err := getRandomDisks(nDisks)
|
|
|
|
if err != nil {
|
2022-08-04 23:10:08 +00:00
|
|
|
t.Fatal("Failed to create drives for the backend")
|
2017-01-17 01:05:00 +00:00
|
|
|
}
|
|
|
|
defer removeRoots(disks)
|
|
|
|
|
2023-07-03 16:47:40 +00:00
|
|
|
obj, err := newObjectLayer(ctx, mustGetPoolEndpoints(0, disks...))
|
2017-01-17 01:05:00 +00:00
|
|
|
if err != nil {
|
|
|
|
t.Fatal("Unexpected object layer initialization error", err)
|
|
|
|
}
|
2022-11-01 23:41:01 +00:00
|
|
|
|
|
|
|
_, ok := obj.(*erasureServerPools)
|
2017-01-17 01:05:00 +00:00
|
|
|
if !ok {
|
|
|
|
t.Fatal("Unexpected object layer detected", reflect.TypeOf(obj))
|
|
|
|
}
|
|
|
|
|
2020-06-13 03:04:01 +00:00
|
|
|
// Tests for Erasure object layer initialization.
|
2017-01-17 01:05:00 +00:00
|
|
|
|
|
|
|
// Create temporary backend for the test server.
|
|
|
|
nDisks = 16
|
|
|
|
disks, err = getRandomDisks(nDisks)
|
|
|
|
if err != nil {
|
2022-08-04 23:10:08 +00:00
|
|
|
t.Fatal("Failed to create drives for the backend")
|
2017-01-17 01:05:00 +00:00
|
|
|
}
|
|
|
|
defer removeRoots(disks)
|
|
|
|
|
2023-07-03 16:47:40 +00:00
|
|
|
obj, err = newObjectLayer(ctx, mustGetPoolEndpoints(0, disks...))
|
2017-01-17 01:05:00 +00:00
|
|
|
if err != nil {
|
|
|
|
t.Fatal("Unexpected object layer initialization error", err)
|
|
|
|
}
|
|
|
|
|
2020-12-01 21:50:33 +00:00
|
|
|
_, ok = obj.(*erasureServerPools)
|
2017-01-17 01:05:00 +00:00
|
|
|
if !ok {
|
|
|
|
t.Fatal("Unexpected object layer detected", reflect.TypeOf(obj))
|
|
|
|
}
|
|
|
|
}
|