mirror of
https://github.com/minio/minio.git
synced 2025-02-04 02:15:59 -05:00
Fix posix tests for SimpleCI (#7328)
This commit is contained in:
parent
c0a1369b73
commit
12eb71828b
@ -34,7 +34,7 @@ USER ci
|
|||||||
RUN for d in $(go list ./... | grep -v browser); do go test -v -race --timeout 15m "$d"; done
|
RUN for d in $(go list ./... | grep -v browser); do go test -v -race --timeout 15m "$d"; done
|
||||||
RUN make verifiers
|
RUN make verifiers
|
||||||
RUN make crosscompile
|
RUN make crosscompile
|
||||||
RUN make coverage || true
|
RUN make coverage
|
||||||
RUN make verify
|
RUN make verify
|
||||||
|
|
||||||
#-------------------------------------------------------------
|
#-------------------------------------------------------------
|
||||||
|
@ -20,6 +20,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
|
"path"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"runtime"
|
"runtime"
|
||||||
"sort"
|
"sort"
|
||||||
@ -33,15 +34,27 @@ func TestReadDirFail(t *testing.T) {
|
|||||||
t.Fatalf("expected = %s, got: %s", errFileNotFound, err)
|
t.Fatalf("expected = %s, got: %s", errFileNotFound, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
file := path.Join(os.TempDir(), "issue")
|
||||||
|
if err := ioutil.WriteFile(file, []byte(""), 0644); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
defer os.RemoveAll(file)
|
||||||
|
|
||||||
// Check if file is given.
|
// Check if file is given.
|
||||||
if _, err := readDir("/etc/issue/mydir"); err != errFileNotFound {
|
if _, err := readDir(path.Join(file, "mydir")); err != errFileNotFound {
|
||||||
t.Fatalf("expected = %s, got: %s", errFileNotFound, err)
|
t.Fatalf("expected = %s, got: %s", errFileNotFound, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Only valid for linux.
|
// Only valid for linux.
|
||||||
if runtime.GOOS == "linux" {
|
if runtime.GOOS == "linux" {
|
||||||
|
permDir := path.Join(os.TempDir(), "perm-dir")
|
||||||
|
if err := os.MkdirAll(permDir, os.FileMode(0200)); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
defer os.RemoveAll(permDir)
|
||||||
|
|
||||||
// Check if permission denied.
|
// Check if permission denied.
|
||||||
if _, err := readDir("/proc/1/fd"); err == nil {
|
if _, err := readDir(permDir); err == nil {
|
||||||
t.Fatalf("expected = an error, got: nil")
|
t.Fatalf("expected = an error, got: nil")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1069,70 +1069,53 @@ func TestPosixReadFile(t *testing.T) {
|
|||||||
volume, "path/to/my/object", 0, 5,
|
volume, "path/to/my/object", 0, 5,
|
||||||
[]byte("hello"), nil,
|
[]byte("hello"), nil,
|
||||||
},
|
},
|
||||||
// One path segment length is 255 chars long. - 3
|
// Object is a directory. - 3
|
||||||
{
|
|
||||||
volume, "path/to/my/object000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001",
|
|
||||||
0, 5, []byte("hello"), nil},
|
|
||||||
// Whole path is 1024 characters long, success case. - 4
|
|
||||||
{
|
|
||||||
volume, "level0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001/level0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002/level0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003/object000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001",
|
|
||||||
0, 5, []byte("hello"),
|
|
||||||
func() error {
|
|
||||||
// On darwin HFS does not support > 1024 characters.
|
|
||||||
if runtime.GOOS == "darwin" {
|
|
||||||
return errFileNameTooLong
|
|
||||||
}
|
|
||||||
// On all other platforms return success.
|
|
||||||
return nil
|
|
||||||
}(),
|
|
||||||
},
|
|
||||||
// Object is a directory. - 5
|
|
||||||
{
|
{
|
||||||
volume, "object-as-dir",
|
volume, "object-as-dir",
|
||||||
0, 5, nil, errIsNotRegular},
|
0, 5, nil, errIsNotRegular},
|
||||||
// One path segment length is > 255 chars long. - 6
|
// One path segment length is > 255 chars long. - 4
|
||||||
{
|
{
|
||||||
volume, "path/to/my/object0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001",
|
volume, "path/to/my/object0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001",
|
||||||
0, 5, nil, errFileNameTooLong},
|
0, 5, nil, errFileNameTooLong},
|
||||||
// Path length is > 1024 chars long. - 7
|
// Path length is > 1024 chars long. - 5
|
||||||
{
|
{
|
||||||
volume, "level0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001/level0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002/level0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003/object000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001",
|
volume, "level0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001/level0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002/level0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003/object000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001",
|
||||||
0, 5, nil, errFileNameTooLong},
|
0, 5, nil, errFileNameTooLong},
|
||||||
// Buffer size greater than object size. - 8
|
// Buffer size greater than object size. - 6
|
||||||
{
|
{
|
||||||
volume, "myobject", 0, 16,
|
volume, "myobject", 0, 16,
|
||||||
[]byte("hello, world"),
|
[]byte("hello, world"),
|
||||||
io.ErrUnexpectedEOF,
|
io.ErrUnexpectedEOF,
|
||||||
},
|
},
|
||||||
// Reading from an offset success. - 9
|
// Reading from an offset success. - 7
|
||||||
{
|
{
|
||||||
volume, "myobject", 7, 5,
|
volume, "myobject", 7, 5,
|
||||||
[]byte("world"), nil,
|
[]byte("world"), nil,
|
||||||
},
|
},
|
||||||
// Reading from an object but buffer size greater. - 10
|
// Reading from an object but buffer size greater. - 8
|
||||||
{
|
{
|
||||||
volume, "myobject",
|
volume, "myobject",
|
||||||
7, 8,
|
7, 8,
|
||||||
[]byte("world"),
|
[]byte("world"),
|
||||||
io.ErrUnexpectedEOF,
|
io.ErrUnexpectedEOF,
|
||||||
},
|
},
|
||||||
// Seeking ahead returns io.EOF. - 11
|
// Seeking ahead returns io.EOF. - 9
|
||||||
{
|
{
|
||||||
volume, "myobject", 14, 1, nil, io.EOF,
|
volume, "myobject", 14, 1, nil, io.EOF,
|
||||||
},
|
},
|
||||||
// Empty volume name. - 12
|
// Empty volume name. - 10
|
||||||
{
|
{
|
||||||
"", "myobject", 14, 1, nil, errVolumeNotFound,
|
"", "myobject", 14, 1, nil, errVolumeNotFound,
|
||||||
},
|
},
|
||||||
// Empty filename name. - 13
|
// Empty filename name. - 11
|
||||||
{
|
{
|
||||||
volume, "", 14, 1, nil, errIsNotRegular,
|
volume, "", 14, 1, nil, errIsNotRegular,
|
||||||
},
|
},
|
||||||
// Non existent volume name - 14.
|
// Non existent volume name - 12
|
||||||
{
|
{
|
||||||
"abcd", "", 14, 1, nil, errVolumeNotFound,
|
"abcd", "", 14, 1, nil, errVolumeNotFound,
|
||||||
},
|
},
|
||||||
// Non existent filename - 15.
|
// Non existent filename - 13
|
||||||
{
|
{
|
||||||
volume, "abcd", 14, 1, nil, errFileNotFound,
|
volume, "abcd", 14, 1, nil, errFileNotFound,
|
||||||
},
|
},
|
||||||
@ -1361,8 +1344,7 @@ func TestPosixAppendFile(t *testing.T) {
|
|||||||
{"myobject", nil},
|
{"myobject", nil},
|
||||||
// TestPosix to use same path of previously created file.
|
// TestPosix to use same path of previously created file.
|
||||||
{"path/to/my/testobject", nil},
|
{"path/to/my/testobject", nil},
|
||||||
// One path segment length is 255 chars long.
|
// TestPosix to use object is a directory now.
|
||||||
{"path/to/my/object000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001", nil},
|
|
||||||
{"object-as-dir", errIsNotRegular},
|
{"object-as-dir", errIsNotRegular},
|
||||||
// path segment uses previously uploaded object.
|
// path segment uses previously uploaded object.
|
||||||
{"myobject/testobject", errFileAccessDenied},
|
{"myobject/testobject", errFileAccessDenied},
|
||||||
@ -1372,17 +1354,6 @@ func TestPosixAppendFile(t *testing.T) {
|
|||||||
{"level0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001/level0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002/level0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003/object000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001", errFileNameTooLong},
|
{"level0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001/level0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002/level0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003/object000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001", errFileNameTooLong},
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add path length > 1024 test specially as OS X system does not support 1024 long path.
|
|
||||||
err = errFileNameTooLong
|
|
||||||
if runtime.GOOS != "darwin" {
|
|
||||||
err = nil
|
|
||||||
}
|
|
||||||
// path length is 1024 chars long.
|
|
||||||
testCases = append(testCases, struct {
|
|
||||||
fileName string
|
|
||||||
expectedErr error
|
|
||||||
}{"level0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001/level0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002/level0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003/object000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001", err})
|
|
||||||
|
|
||||||
for i, testCase := range testCases {
|
for i, testCase := range testCases {
|
||||||
if err = posixStorage.AppendFile("success-vol", testCase.fileName, []byte("hello, world")); err != testCase.expectedErr {
|
if err = posixStorage.AppendFile("success-vol", testCase.fileName, []byte("hello, world")); err != testCase.expectedErr {
|
||||||
t.Errorf("Case: %d, expected: %s, got: %s", i+1, testCase.expectedErr, err)
|
t.Errorf("Case: %d, expected: %s, got: %s", i+1, testCase.expectedErr, err)
|
||||||
|
@ -23,6 +23,7 @@ import (
|
|||||||
"net/http/httptest"
|
"net/http/httptest"
|
||||||
"os"
|
"os"
|
||||||
"runtime"
|
"runtime"
|
||||||
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
@ -82,13 +83,19 @@ func TestReleaseTagToNFromTimeConversion(t *testing.T) {
|
|||||||
func TestDownloadURL(t *testing.T) {
|
func TestDownloadURL(t *testing.T) {
|
||||||
minioVersion1 := releaseTimeToReleaseTag(UTCNow())
|
minioVersion1 := releaseTimeToReleaseTag(UTCNow())
|
||||||
durl := getDownloadURL(minioVersion1)
|
durl := getDownloadURL(minioVersion1)
|
||||||
if runtime.GOOS == "windows" {
|
if IsDocker() {
|
||||||
if durl != minioReleaseURL+"minio.exe" {
|
if durl != "docker pull minio/minio:"+minioVersion1 {
|
||||||
t.Errorf("Expected %s, got %s", minioReleaseURL+"minio.exe", durl)
|
t.Errorf("Expected %s, got %s", "docker pull minio/minio:"+minioVersion1, durl)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if durl != minioReleaseURL+"minio" {
|
if runtime.GOOS == "windows" {
|
||||||
t.Errorf("Expected %s, got %s", minioReleaseURL+"minio", durl)
|
if durl != minioReleaseURL+"minio.exe" {
|
||||||
|
t.Errorf("Expected %s, got %s", minioReleaseURL+"minio.exe", durl)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if durl != minioReleaseURL+"minio" {
|
||||||
|
t.Errorf("Expected %s, got %s", minioReleaseURL+"minio", durl)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -141,8 +148,12 @@ func TestUserAgent(t *testing.T) {
|
|||||||
os.Setenv("MARATHON_APP_LABEL_DCOS_PACKAGE_VERSION", "mesos-1111")
|
os.Setenv("MARATHON_APP_LABEL_DCOS_PACKAGE_VERSION", "mesos-1111")
|
||||||
}
|
}
|
||||||
str := getUserAgent(testCase.mode)
|
str := getUserAgent(testCase.mode)
|
||||||
if str != testCase.expectedStr {
|
expectedStr := testCase.expectedStr
|
||||||
t.Errorf("Test %d: expected: %s, got: %s", i+1, testCase.expectedStr, str)
|
if IsDocker() {
|
||||||
|
expectedStr = strings.Replace(expectedStr, "; source", "; docker; source", -1)
|
||||||
|
}
|
||||||
|
if str != expectedStr {
|
||||||
|
t.Errorf("Test %d: expected: %s, got: %s", i+1, expectedStr, str)
|
||||||
}
|
}
|
||||||
os.Unsetenv("MARATHON_APP_LABEL_DCOS_PACKAGE_VERSION")
|
os.Unsetenv("MARATHON_APP_LABEL_DCOS_PACKAGE_VERSION")
|
||||||
os.Unsetenv(testCase.envName)
|
os.Unsetenv(testCase.envName)
|
||||||
|
@ -29,12 +29,14 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// file size for performance read and write checks
|
// file size for performance read and write checks
|
||||||
const randBufSize = 1 * humanize.KiByte
|
const (
|
||||||
const randParts = 1024
|
randBufSize = 1 * humanize.KiByte
|
||||||
const fileSize = randParts * randBufSize
|
randParts = 1024
|
||||||
|
fileSize = randParts * randBufSize
|
||||||
|
|
||||||
// Total count of read / write iteration for performance measurement
|
// Total count of read / write iteration for performance measurement
|
||||||
const iterations = 10
|
iterations = 10
|
||||||
|
)
|
||||||
|
|
||||||
// Info stat fs struct is container which holds following values
|
// Info stat fs struct is container which holds following values
|
||||||
// Total - total size of the volume / disk
|
// Total - total size of the volume / disk
|
||||||
|
@ -20,7 +20,7 @@ package disk
|
|||||||
|
|
||||||
import "strconv"
|
import "strconv"
|
||||||
|
|
||||||
// fsType2StringMap - list of filesystems supported by donut on linux
|
// fsType2StringMap - list of filesystems supported on linux
|
||||||
var fsType2StringMap = map[string]string{
|
var fsType2StringMap = map[string]string{
|
||||||
"1021994": "TMPFS",
|
"1021994": "TMPFS",
|
||||||
"137d": "EXT",
|
"137d": "EXT",
|
||||||
@ -34,6 +34,9 @@ var fsType2StringMap = map[string]string{
|
|||||||
"ef51": "EXT2OLD",
|
"ef51": "EXT2OLD",
|
||||||
"ef53": "EXT4",
|
"ef53": "EXT4",
|
||||||
"f15f": "ecryptfs",
|
"f15f": "ecryptfs",
|
||||||
|
"794c7630": "overlayfs",
|
||||||
|
"2fc12fc1": "zfs",
|
||||||
|
"ff534d42": "cifs",
|
||||||
}
|
}
|
||||||
|
|
||||||
// getFSType returns the filesystem type of the underlying mounted filesystem
|
// getFSType returns the filesystem type of the underlying mounted filesystem
|
||||||
|
Loading…
x
Reference in New Issue
Block a user