diff --git a/Dockerfile.simpleci b/Dockerfile.simpleci index dfb982e7b..57ae60977 100644 --- a/Dockerfile.simpleci +++ b/Dockerfile.simpleci @@ -6,7 +6,7 @@ FROM golang:1.11.4 COPY . /go/src/github.com/minio/minio WORKDIR /go/src/github.com/minio/minio -RUN apt-get update && apt-get install -y jq +RUN apt-get update && apt-get install -y jq RUN make RUN bash -c 'diff -au <(gofmt -s -d cmd) <(printf "")' @@ -14,7 +14,7 @@ RUN bash -c 'diff -au <(gofmt -s -d pkg) <(printf "")' RUN apt-get update && \ apt-get -y install sudo -RUN touch /etc/sudoers +RUN touch /etc/sudoers RUN echo "root ALL=(ALL) ALL" >> /etc/sudoers RUN echo "ci ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers @@ -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 make verifiers RUN make crosscompile -RUN make coverage || true +RUN make coverage RUN make verify #------------------------------------------------------------- diff --git a/cmd/posix-list-dir_test.go b/cmd/posix-list-dir_test.go index a704d2894..602c70720 100644 --- a/cmd/posix-list-dir_test.go +++ b/cmd/posix-list-dir_test.go @@ -20,6 +20,7 @@ import ( "fmt" "io/ioutil" "os" + "path" "path/filepath" "runtime" "sort" @@ -33,15 +34,27 @@ func TestReadDirFail(t *testing.T) { 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. - 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) } // Only valid for 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. - if _, err := readDir("/proc/1/fd"); err == nil { + if _, err := readDir(permDir); err == nil { t.Fatalf("expected = an error, got: nil") } } diff --git a/cmd/posix_test.go b/cmd/posix_test.go index 25e380eca..c5481653b 100644 --- a/cmd/posix_test.go +++ b/cmd/posix_test.go @@ -1069,70 +1069,53 @@ func TestPosixReadFile(t *testing.T) { volume, "path/to/my/object", 0, 5, []byte("hello"), nil, }, - // One path segment length is 255 chars long. - 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 + // Object is a directory. - 3 { volume, "object-as-dir", 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", 0, 5, nil, errFileNameTooLong}, - // Path length is > 1024 chars long. - 7 + // Path length is > 1024 chars long. - 5 { volume, "level0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001/level0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002/level0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003/object000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001", 0, 5, nil, errFileNameTooLong}, - // Buffer size greater than object size. - 8 + // Buffer size greater than object size. - 6 { volume, "myobject", 0, 16, []byte("hello, world"), io.ErrUnexpectedEOF, }, - // Reading from an offset success. - 9 + // Reading from an offset success. - 7 { volume, "myobject", 7, 5, []byte("world"), nil, }, - // Reading from an object but buffer size greater. - 10 + // Reading from an object but buffer size greater. - 8 { volume, "myobject", 7, 8, []byte("world"), io.ErrUnexpectedEOF, }, - // Seeking ahead returns io.EOF. - 11 + // Seeking ahead returns io.EOF. - 9 { volume, "myobject", 14, 1, nil, io.EOF, }, - // Empty volume name. - 12 + // Empty volume name. - 10 { "", "myobject", 14, 1, nil, errVolumeNotFound, }, - // Empty filename name. - 13 + // Empty filename name. - 11 { volume, "", 14, 1, nil, errIsNotRegular, }, - // Non existent volume name - 14. + // Non existent volume name - 12 { "abcd", "", 14, 1, nil, errVolumeNotFound, }, - // Non existent filename - 15. + // Non existent filename - 13 { volume, "abcd", 14, 1, nil, errFileNotFound, }, @@ -1361,8 +1344,7 @@ func TestPosixAppendFile(t *testing.T) { {"myobject", nil}, // TestPosix to use same path of previously created file. {"path/to/my/testobject", nil}, - // One path segment length is 255 chars long. - {"path/to/my/object000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001", nil}, + // TestPosix to use object is a directory now. {"object-as-dir", errIsNotRegular}, // path segment uses previously uploaded object. {"myobject/testobject", errFileAccessDenied}, @@ -1372,17 +1354,6 @@ func TestPosixAppendFile(t *testing.T) { {"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 { 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) diff --git a/cmd/update-main_test.go b/cmd/update-main_test.go index c76ccb0d3..7f3414ad7 100644 --- a/cmd/update-main_test.go +++ b/cmd/update-main_test.go @@ -23,6 +23,7 @@ import ( "net/http/httptest" "os" "runtime" + "strings" "testing" "time" ) @@ -82,13 +83,19 @@ func TestReleaseTagToNFromTimeConversion(t *testing.T) { func TestDownloadURL(t *testing.T) { minioVersion1 := releaseTimeToReleaseTag(UTCNow()) durl := getDownloadURL(minioVersion1) - if runtime.GOOS == "windows" { - if durl != minioReleaseURL+"minio.exe" { - t.Errorf("Expected %s, got %s", minioReleaseURL+"minio.exe", durl) + if IsDocker() { + if durl != "docker pull minio/minio:"+minioVersion1 { + t.Errorf("Expected %s, got %s", "docker pull minio/minio:"+minioVersion1, durl) } } else { - if durl != minioReleaseURL+"minio" { - t.Errorf("Expected %s, got %s", minioReleaseURL+"minio", durl) + if runtime.GOOS == "windows" { + 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") } str := getUserAgent(testCase.mode) - if str != testCase.expectedStr { - t.Errorf("Test %d: expected: %s, got: %s", i+1, testCase.expectedStr, str) + expectedStr := testCase.expectedStr + 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(testCase.envName) diff --git a/pkg/disk/disk.go b/pkg/disk/disk.go index 7660cce5b..a6392d3d5 100644 --- a/pkg/disk/disk.go +++ b/pkg/disk/disk.go @@ -29,12 +29,14 @@ import ( ) // file size for performance read and write checks -const randBufSize = 1 * humanize.KiByte -const randParts = 1024 -const fileSize = randParts * randBufSize +const ( + randBufSize = 1 * humanize.KiByte + randParts = 1024 + fileSize = randParts * randBufSize -// Total count of read / write iteration for performance measurement -const iterations = 10 + // Total count of read / write iteration for performance measurement + iterations = 10 +) // Info stat fs struct is container which holds following values // Total - total size of the volume / disk diff --git a/pkg/disk/type_linux.go b/pkg/disk/type_linux.go index 7de259a3c..bd5ecfca2 100644 --- a/pkg/disk/type_linux.go +++ b/pkg/disk/type_linux.go @@ -20,7 +20,7 @@ package disk import "strconv" -// fsType2StringMap - list of filesystems supported by donut on linux +// fsType2StringMap - list of filesystems supported on linux var fsType2StringMap = map[string]string{ "1021994": "TMPFS", "137d": "EXT", @@ -34,6 +34,9 @@ var fsType2StringMap = map[string]string{ "ef51": "EXT2OLD", "ef53": "EXT4", "f15f": "ecryptfs", + "794c7630": "overlayfs", + "2fc12fc1": "zfs", + "ff534d42": "cifs", } // getFSType returns the filesystem type of the underlying mounted filesystem