mirror of
https://github.com/minio/minio.git
synced 2024-12-25 06:35:56 -05:00
8b8be2695f
Currently we have IOPs of these patterns ``` [OS] os.Mkdir play.min.io:9000 /disk1 2.718µs [OS] os.Mkdir play.min.io:9000 /disk1/data 2.406µs [OS] os.Mkdir play.min.io:9000 /disk1/data/.minio.sys 4.068µs [OS] os.Mkdir play.min.io:9000 /disk1/data/.minio.sys/tmp 2.843µs [OS] os.Mkdir play.min.io:9000 /disk1/data/.minio.sys/tmp/d89c8ceb-f8d1-4cc6-b483-280f87c4719f 20.152µs ``` It can be seen that we can save quite Nx levels such as if your drive is mounted at `/disk1/minio` you can simply skip sending an `Mkdir /disk1/` and `Mkdir /disk1/minio`. Since they are expected to exist already, this PR adds a way for us to ignore all paths upto the mount or a directory which ever has been provided to MinIO setup.
75 lines
3.1 KiB
Go
75 lines
3.1 KiB
Go
// 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/>.
|
|
|
|
package cmd
|
|
|
|
import (
|
|
"testing"
|
|
)
|
|
|
|
// Tests - mkdirAll()
|
|
func TestOSMkdirAll(t *testing.T) {
|
|
// create xlStorage test setup
|
|
_, path, err := newXLStorageTestSetup(t)
|
|
if err != nil {
|
|
t.Fatalf("Unable to create xlStorage test setup, %s", err)
|
|
}
|
|
|
|
if err = mkdirAll("", 0o777, ""); err != errInvalidArgument {
|
|
t.Fatal("Unexpected error", err)
|
|
}
|
|
|
|
if err = mkdirAll(pathJoin(path, "my-obj-del-0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001"), 0o777, ""); err != errFileNameTooLong {
|
|
t.Fatal("Unexpected error", err)
|
|
}
|
|
|
|
if err = mkdirAll(pathJoin(path, "success-vol", "success-object"), 0o777, ""); err != nil {
|
|
t.Fatal("Unexpected error", err)
|
|
}
|
|
}
|
|
|
|
// Tests - renameAll()
|
|
func TestOSRenameAll(t *testing.T) {
|
|
// create xlStorage test setup
|
|
_, path, err := newXLStorageTestSetup(t)
|
|
if err != nil {
|
|
t.Fatalf("Unable to create xlStorage test setup, %s", err)
|
|
}
|
|
|
|
if err = mkdirAll(pathJoin(path, "testvolume1"), 0o777, ""); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if err = renameAll("", "foo", ""); err != errInvalidArgument {
|
|
t.Fatal(err)
|
|
}
|
|
if err = renameAll("foo", "", ""); err != errInvalidArgument {
|
|
t.Fatal(err)
|
|
}
|
|
if err = renameAll(pathJoin(path, "testvolume1"), pathJoin(path, "testvolume2"), ""); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if err = renameAll(pathJoin(path, "testvolume1"), pathJoin(path, "testvolume2"), ""); err != errFileNotFound {
|
|
t.Fatal(err)
|
|
}
|
|
if err = renameAll(pathJoin(path, "my-obj-del-0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001"), pathJoin(path, "testvolume2"), ""); err != errFileNameTooLong {
|
|
t.Fatal("Unexpected error", err)
|
|
}
|
|
if err = renameAll(pathJoin(path, "testvolume1"), pathJoin(path, "my-obj-del-0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001"), ""); err != errFileNameTooLong {
|
|
t.Fatal("Unexpected error", err)
|
|
}
|
|
}
|