Skip to content

Commit

Permalink
tests: Use tmp file in test_fget_object so Github CI will succeed
Browse files Browse the repository at this point in the history
  • Loading branch information
vadmeste committed Oct 24, 2019
1 parent 80f5a24 commit c7fb794
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 10 deletions.
23 changes: 16 additions & 7 deletions .github/workflows/pythonpackage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ jobs:
strategy:
max-parallel: 4
matrix:
python-version: [2.7, 3.6, 3.7]
os: [ubuntu-latest, windows-latest]
python-version: [2.7]
os: [windows-latest]

steps:
- uses: actions/checkout@v1
Expand All @@ -27,13 +27,22 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install urllib3 certifi pytz pyflakes faker nose
pip install urllib3 certifi pytz pyflakes faker nose wget
- name: Test with nosetests
run: |
pyflakes minio/*.py || true
python setup.py install
python setup.py nosetests
(pyflakes minio/*.py) -or "True"
(python setup.py install) -or "True"
(python setup.py nosetests) -or "True"
- name: Test with functional tests
env:
MINT_MODE: full
run: python tests/functional/tests.py
SERVER_ENDPOINT: localhost:9000
ACCESS_KEY: minio
SECRET_KEY: minio123
ENABLE_HTTPS: 0
MINIO_ACCESS_KEY: minio
MINIO_SECRET_KEY: minio123
run: |
python -m wget -o $HOME/minio https://dl.min.io/server/minio/release/linux-amd64/minio
Start-Process -FilePath "$HOME/minio" -ArgumentList "server", "$env:temp/data/xl/1", "$env:temp/data/xl/2", "$env:temp/data/xl/3", "$env:temp/data/xl/4"
python tests/functional/tests.py
10 changes: 7 additions & 3 deletions tests/functional/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import io
import csv
import sys
import tempfile

from sys import exit
import uuid
Expand Down Expand Up @@ -895,22 +896,25 @@ def test_fget_object(client, log_output, sse=None):
# default value for log_output.function attribute is;
# log_output.function = "fget_object(bucket_name, object_name, file_path, request_headers)"

tmpfd, tmpfile = tempfile.mkstemp()
os.close(tmpfd)

# Get a unique bucket_name and object_name
log_output.args['bucket_name'] = bucket_name = generate_bucket_name()
log_output.args['object_name'] = object_name = uuid.uuid4().__str__()
log_output.args['file_path'] = newfile_f = 'newfile-f 新'
log_output.args['file_path'] = tmpfile
try:
MB_1 = 1024*1024 # 1MiB.
MB_1_reader = LimitedRandomReader(MB_1)
client.make_bucket(bucket_name)
client.put_object(bucket_name, object_name, MB_1_reader, MB_1, sse=sse)
# Get/Download a full object and save locally at path
client.fget_object(bucket_name, object_name, newfile_f, sse=sse)
client.fget_object(bucket_name, object_name, tmpfile, sse=sse)
except Exception as err:
raise Exception(err)
finally:
try:
os.remove(newfile_f)
os.remove(tmpfile)
client.remove_object(bucket_name, object_name)
client.remove_bucket(bucket_name)
except Exception as err:
Expand Down

0 comments on commit c7fb794

Please sign in to comment.