Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CI: Add support for GHC 8.10, stack and live-server testing #156

Merged
merged 7 commits into from
Jun 24, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix live-server tests for all platforms
  • Loading branch information
donatello committed Jun 18, 2020
commit 2ff1deac6c7450c2658f42080ca1bdea89a1193d
13 changes: 11 additions & 2 deletions .github/workflows/haskell-cabal.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,25 +50,34 @@ jobs:

- name: Before install (Linux)
if: matrix.os == 'ubuntu-latest'
env:
MINIO_ACCESS_KEY: minio
MINIO_SECRET_KEY: minio123
run: |
mkdir -p /tmp/minio /tmp/minio-config/certs
cp test/cert/* /tmp/minio-config/certs/
(cd /tmp/minio; wget -q https://dl.min.io/server/minio/release/linux-amd64/minio; chmod +x ./minio)
sudo cp /tmp/minio-config/certs/public.crt /usr/local/share/ca-certificates/
sudo update-ca-certificates
MINIO_ACCESS_KEY=minio MINIO_SECRET_KEY=minio123 /tmp/minio/minio server --quiet --certs-dir /tmp/minio-config/certs data 2>&1 > minio.log &
/tmp/minio/minio server --quiet --certs-dir /tmp/minio-config/certs data 2>&1 > minio.log &

- name: Before install (MacOS)
if: matrix.os == 'macos-latest'
env:
MINIO_ACCESS_KEY: minio
MINIO_SECRET_KEY: minio123
run: |
mkdir -p /tmp/minio /tmp/minio-config/certs
cp test/cert/* /tmp/minio-config/certs/
(cd /tmp/minio; wget -q https://dl.min.io/server/minio/release/darwin-amd64/minio; chmod +x ./minio)
sudo security add-trusted-cert -d -r trustRoot -k /Library/Keychains/System.keychain /tmp/minio-config/certs/public.crt
MINIO_ACCESS_KEY=minio MINIO_SECRET_KEY=minio123 /tmp/minio/minio server --quiet --certs-dir /tmp/minio-config/certs data 2>&1 > minio.log &
/tmp/minio/minio server --quiet --certs-dir /tmp/minio-config/certs data 2>&1 > minio.log &

- name: Before install (Windows)
if: matrix.os == 'windows-latest'
env:
MINIO_ACCESS_KEY: minio
MINIO_SECRET_KEY: minio123
run: |
New-Item -ItemType Directory -Path "$env:temp/minio-config/certs/"
Copy-Item -Path test\cert\* -Destination "$env:temp/minio-config/certs/"
Expand Down
31 changes: 17 additions & 14 deletions test/LiveServer.hs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ randomDataSrc s' = genBS s'

mkRandFile :: R.MonadResource m => Int64 -> m FilePath
mkRandFile size = do
dir <- liftIO $ getTemporaryDirectory
dir <- liftIO getTemporaryDirectory
C.runConduit $ randomDataSrc size C..| CB.sinkTempFile dir "miniohstest.random"

funTestBucketPrefix :: Text
Expand Down Expand Up @@ -158,25 +158,26 @@ basicTests = funTestWithBucket "Basic tests" $
liftIO $ region == "us-east-1" @? ("Got unexpected region => " ++ show region)

step "singlepart putObject works"
fPutObject bucket "lsb-release" "/etc/lsb-release" defaultPutObjectOptions
testFilepath <- mkRandFile 200
fPutObject bucket "test-file" testFilepath defaultPutObjectOptions

step "fPutObject onto a non-existent bucket and check for NoSuchBucket exception"
fpE <- try $ fPutObject "nosuchbucket" "lsb-release" "/etc/lsb-release" defaultPutObjectOptions
fpE <- try $ fPutObject "nosuchbucket" "test-file-2" testFilepath defaultPutObjectOptions
case fpE of
Left exn -> liftIO $ exn @?= NoSuchBucket
_ -> return ()

outFile <- mkRandFile 0
step "simple fGetObject works"
fGetObject bucket "lsb-release" outFile defaultGetObjectOptions
fGetObject bucket "test-file" outFile defaultGetObjectOptions

let unmodifiedTime = UTCTime (fromGregorian 2010 11 26) 69857
step "fGetObject an object which is modified now but requesting as un-modified in past, check for exception"
resE <-
try $
fGetObject
bucket
"lsb-release"
"test-file"
outFile
defaultGetObjectOptions
{ gooIfUnmodifiedSince = (Just unmodifiedTime)
Expand All @@ -190,7 +191,7 @@ basicTests = funTestWithBucket "Basic tests" $
try $
fGetObject
bucket
"lsb-release"
"test-file"
outFile
defaultGetObjectOptions
{ gooIfMatch = (Just "invalid-etag")
Expand All @@ -204,10 +205,10 @@ basicTests = funTestWithBucket "Basic tests" $
try $
fGetObject
bucket
"lsb-release"
"test-file"
outFile
defaultGetObjectOptions
{ gooRange = (Just $ HT.ByteRangeFromTo 100 200)
{ gooRange = (Just $ HT.ByteRangeFromTo 100 300)
}
case resE2 of
Left exn -> liftIO $ exn @?= ServiceErr "InvalidRange" "The requested range is not satisfiable"
Expand All @@ -216,7 +217,7 @@ basicTests = funTestWithBucket "Basic tests" $
step "fGetObject on object with a valid range"
fGetObject
bucket
"lsb-release"
"test-file"
outFile
defaultGetObjectOptions
{ gooRange = (Just $ HT.ByteRangeFrom 1)
Expand All @@ -236,7 +237,7 @@ basicTests = funTestWithBucket "Basic tests" $
abortMultipartUpload bucket "newmpupload" uid

step "delete object works"
deleteObject bucket "lsb-release"
deleteObject bucket "test-file"

step "statObject test"
let object = "sample"
Expand Down Expand Up @@ -353,8 +354,9 @@ highLevelListingTest = funTestWithBucket "High-level listObjects Test" $
)
os

testFilepath <- mkRandFile 200
forM_ expectedObjects $
\obj -> fPutObject bucket obj "/etc/lsb-release" defaultPutObjectOptions
\obj -> fPutObject bucket obj testFilepath defaultPutObjectOptions

step "High-level listing of objects"
items <- C.runConduit $ listObjects bucket Nothing False C..| sinkList
Expand Down Expand Up @@ -470,10 +472,11 @@ listingTest :: TestTree
listingTest = funTestWithBucket "Listing Test" $ \step bucket -> do
step "listObjects' test"
step "put 10 objects"
let objects = (\s -> T.concat ["lsb-release", T.pack (show s)]) <$> [1 .. 10 :: Int]
let objects = (\s -> T.concat ["test-file-", T.pack (show s)]) <$> [1 .. 10 :: Int]

testFilepath <- mkRandFile 200
forM_ [1 .. 10 :: Int] $ \s ->
fPutObject bucket (T.concat ["lsb-release", T.pack (show s)]) "/etc/lsb-release" defaultPutObjectOptions
fPutObject bucket (T.concat ["test-file-", T.pack (show s)]) testFilepath defaultPutObjectOptions

step "Simple list"
res <- listObjects' bucket Nothing Nothing Nothing Nothing
Expand All @@ -490,7 +493,7 @@ listingTest = funTestWithBucket "Listing Test" $ \step bucket -> do
sort $
map
( T.concat
. ("lsb-release" :)
. ("test-file-" :)
. (\x -> [x])
. T.pack
. show
Expand Down