Rename putObjectFromSource as putObject

Also live server tests now use Minio Play server.
This commit is contained in:
Harshavardhana 2017-02-18 16:27:37 +05:30 committed by Aditya Manthramurthy
parent 687176fe20
commit fa527afa96
6 changed files with 18 additions and 23 deletions

View File

@ -36,9 +36,5 @@ install:
- stack --no-terminal --install-ghc test --only-dependencies - stack --no-terminal --install-ghc test --only-dependencies
script: script:
# Download Minio Server
- wget -q "https://dl.minio.io/server/minio/release/linux-amd64/minio" && chmod +x ./minio
# Run server in background.
- MINIO_ACCESS_KEY=minio MINIO_SECRET_KEY=minio123 ./minio server /tmp/export &
# Build the package, its tests, and its docs and run the tests # Build the package, its tests, and its docs and run the tests
- stack --no-terminal test --haddock --no-haddock-deps - stack --no-terminal test --haddock --no-haddock-deps

View File

@ -26,12 +26,11 @@ stack test
``` ```
A section of the tests require a live Minio server, running on `http://localhost:9000` A section of the tests use `https://play.minio.io:9000`.
Documentation can be locally built with: Documentation can be locally built with:
```sh
``` shell
stack haddock stack haddock

View File

@ -21,12 +21,12 @@ main = do
object = "obj" object = "obj"
mb15 = 15 * 1024 * 1024 mb15 = 15 * 1024 * 1024
-- Eg 1. Upload a stream of repeating "a" using putObjectFromSource. -- Eg 1. Upload a stream of repeating "a" using putObject.
res1 <- runResourceT $ runMinio minioPlayCI $ do res1 <- runResourceT $ runMinio minioPlayCI $ do
putObjectFromSource bucket object (CC.repeat "a") (Just mb15) putObject bucket object (CC.repeat "a") (Just mb15)
case res1 of case res1 of
Left e -> putStrLn $ "putObjectFromSource failed." ++ (show e) Left e -> putStrLn $ "putObject failed." ++ (show e)
Right () -> putStrLn "putObjectFromSource succeeded." Right () -> putStrLn "putObject succeeded."
-- Eg 2. Upload a file using fPutObject. -- Eg 2. Upload a file using fPutObject.

View File

@ -43,7 +43,7 @@ module Network.Minio
---------------------- ----------------------
, fGetObject , fGetObject
, fPutObject , fPutObject
, putObjectFromSource , putObject
, getObject , getObject
, statObject , statObject
@ -75,7 +75,7 @@ fGetObject bucket object fp = do
-- | Upload the given file to the given object. -- | Upload the given file to the given object.
fPutObject :: Bucket -> Object -> FilePath -> Minio () fPutObject :: Bucket -> Object -> FilePath -> Minio ()
fPutObject bucket object f = void $ putObject bucket object $ fPutObject bucket object f = void $ putObjectInternal bucket object $
ODFile f Nothing ODFile f Nothing
-- | Put an object from a conduit source. The size can be provided if -- | Put an object from a conduit source. The size can be provided if
@ -83,9 +83,9 @@ fPutObject bucket object f = void $ putObject bucket object $
-- performing a multipart upload. If not specified, it is assumed that -- performing a multipart upload. If not specified, it is assumed that
-- the object can be potentially 5TiB and selects multipart sizes -- the object can be potentially 5TiB and selects multipart sizes
-- appropriately. -- appropriately.
putObjectFromSource :: Bucket -> Object -> C.Producer Minio ByteString putObject :: Bucket -> Object -> C.Producer Minio ByteString
-> Maybe Int64 -> Minio () -> Maybe Int64 -> Minio ()
putObjectFromSource bucket object src sizeMay = void $ putObject bucket object $ putObject bucket object src sizeMay = void $ putObjectInternal bucket object $
ODStream src sizeMay ODStream src sizeMay
-- | Get an object from the object store as a resumable source (conduit). -- | Get an object from the object store as a resumable source (conduit).

View File

@ -1,6 +1,6 @@
module Network.Minio.PutObject module Network.Minio.PutObject
( (
putObject putObjectInternal
, ObjectData(..) , ObjectData(..)
, selectPartSizes , selectPartSizes
) where ) where
@ -49,9 +49,9 @@ data ObjectData m = ODFile FilePath (Maybe Int64) -- ^ Takes filepath and option
-- | Put an object from ObjectData. This high-level API handles -- | Put an object from ObjectData. This high-level API handles
-- objects of all sizes, and even if the object size is unknown. -- objects of all sizes, and even if the object size is unknown.
putObject :: Bucket -> Object -> ObjectData Minio -> Minio ETag putObjectInternal :: Bucket -> Object -> ObjectData Minio -> Minio ETag
putObject b o (ODStream src sizeMay) = sequentialMultipartUpload b o sizeMay src putObjectInternal b o (ODStream src sizeMay) = sequentialMultipartUpload b o sizeMay src
putObject b o (ODFile fp sizeMay) = do putObjectInternal b o (ODFile fp sizeMay) = do
hResE <- withNewHandle fp $ \h -> hResE <- withNewHandle fp $ \h ->
liftM2 (,) (isHandleSeekable h) (getFileSize h) liftM2 (,) (isHandleSeekable h) (getFileSize h)

View File

@ -62,7 +62,7 @@ funTestWithBucket t minioTest = testCaseSteps t $ \step -> do
bktSuffix <- liftIO $ generate $ Q.vectorOf 10 (Q.choose ('a', 'z')) bktSuffix <- liftIO $ generate $ Q.vectorOf 10 (Q.choose ('a', 'z'))
let b = T.concat [funTestBucketPrefix, T.pack bktSuffix] let b = T.concat [funTestBucketPrefix, T.pack bktSuffix]
liftStep = liftIO . step liftStep = liftIO . step
ret <- runResourceT $ runMinio def $ do ret <- runResourceT $ runMinio minioPlayCI $ do
liftStep $ "Creating bucket for test - " ++ t liftStep $ "Creating bucket for test - " ++ t
makeBucket b def makeBucket b def
minioTest liftStep b minioTest liftStep b
@ -136,7 +136,7 @@ liveServerUnitTests = testGroup "Unit tests against a live server"
rFile <- mkRandFile mb100 rFile <- mkRandFile mb100
step "Upload multipart file." step "Upload multipart file."
putObjectFromSource bucket obj (CB.sourceFile rFile) Nothing putObject bucket obj (CB.sourceFile rFile) Nothing
step "Retrieve and verify file size" step "Retrieve and verify file size"
destFile <- mkRandFile 0 destFile <- mkRandFile 0
@ -154,7 +154,7 @@ liveServerUnitTests = testGroup "Unit tests against a live server"
mb100 = 100 * 1024 * 1024 mb100 = 100 * 1024 * 1024
step "Upload multipart file." step "Upload multipart file."
void $ putObject bucket obj $ ODFile "/dev/zero" (Just mb100) void $ putObjectInternal bucket obj $ ODFile "/dev/zero" (Just mb100)
step "Retrieve and verify file size" step "Retrieve and verify file size"
destFile <- mkRandFile 0 destFile <- mkRandFile 0
@ -198,7 +198,7 @@ liveServerUnitTests = testGroup "Unit tests against a live server"
, funTestWithBucket "multipart" $ \step bucket -> do , funTestWithBucket "multipart" $ \step bucket -> do
step "upload large object" step "upload large object"
void $ putObject bucket "big" (ODFile "/dev/zero" $ Just $ 1024*1024*100) void $ putObjectInternal bucket "big" (ODFile "/dev/zero" $ Just $ 1024*1024*100)
step "cleanup" step "cleanup"
deleteObject bucket "big" deleteObject bucket "big"