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 1376177
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ jobs:
name: Test on python ${{ matrix.python-version }} and ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
max-parallel: 4
max-parallel: 3
matrix:
python-version: [2.7, 3.6, 3.7]
os: [ubuntu-latest, windows-latest]
os: [ubuntu-latest]

steps:
- uses: actions/checkout@v1
Expand All @@ -28,6 +28,10 @@ jobs:
run: |
python -m pip install --upgrade pip
pip install urllib3 certifi pytz pyflakes faker nose
- name: Generate TLS certificate
run: |
mkdir -p $HOME/.minio/certs/
openssl req -new -newkey rsa:2048 -days 365 -nodes -x509 -keyout $HOME/.minio/certs/private.key -out $HOME/.minio/certs/public.crt -subj '/CN=localhost'
- name: Test with nosetests
run: |
pyflakes minio/*.py || true
Expand All @@ -36,4 +40,15 @@ jobs:
- 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: 1
MINIO_ACCESS_KEY: minio
MINIO_SECRET_KEY: minio123
run: |
wget -O $HOME/minio https://dl.min.io/server/minio/release/linux-amd64/minio
chmod +x $HOME/minio
$HOME/minio server /tmp/xl/{1..4} &
export SSL_CERT_FILE=$HOME/.minio/certs/public.crt
python tests/functional/tests.py
49 changes: 49 additions & 0 deletions .github/workflows/pythonpackage-windows.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Python package

on:
pull_request:
branches:
- master
push:
branches:
- master

jobs:
build:
name: Test on python ${{ matrix.python-version }} and ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
max-parallel: 3
matrix:
python-version: [2.7, 3.6, 3.7]
os: [windows-latest]

steps:
- uses: actions/checkout@v1
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v1
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install urllib3 certifi pytz pyflakes faker nose wget
- name: Test with nosetests
run: |
$ErrorActionPreference = 'continue'
pyflakes minio/*.py
python setup.py install
python setup.py nosetests
- name: Test with functional tests
env:
MINT_MODE: full
SERVER_ENDPOINT: localhost:9000
ACCESS_KEY: minio
SECRET_KEY: minio123
ENABLE_HTTPS: 0
MINIO_ACCESS_KEY: minio
MINIO_SECRET_KEY: minio123
run: |
Invoke-WebRequest -Uri https://dl.min.io/server/minio/release/windows-amd64/minio.exe -OutFile $HOME/minio.exe
Start-Process -NoNewWindow -FilePath "$HOME/minio.exe" -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 1376177

Please sign in to comment.