From d9f01bf538098961adae17c82dddb786363fe22d Mon Sep 17 00:00:00 2001 From: "Bala.FA" Date: Tue, 8 Dec 2020 20:06:00 +0530 Subject: [PATCH] Makefile: add tests target --- .gitignore | 2 + MAINTAINERS.md | 7 ++- Makefile | 18 ++++---- run_functional_tests.sh | 51 ++++++++++++++++++++++ tests/functional/play.min.io.kes.root.cert | 9 ++++ tests/functional/play.min.io.kes.root.key | 3 ++ tests/functional_test.sh | 30 ------------- tests/unit_test.sh | 17 -------- 8 files changed, 78 insertions(+), 59 deletions(-) create mode 100755 run_functional_tests.sh create mode 100644 tests/functional/play.min.io.kes.root.cert create mode 100644 tests/functional/play.min.io.kes.root.key delete mode 100755 tests/functional_test.sh delete mode 100755 tests/unit_test.sh diff --git a/.gitignore b/.gitignore index 7eaa52982..c39612d3b 100644 --- a/.gitignore +++ b/.gitignore @@ -26,3 +26,5 @@ var/ .#* .vscode #* +tests/functional/.* +tests/functional/minio* diff --git a/MAINTAINERS.md b/MAINTAINERS.md index bcf2c55da..dba7a0eee 100644 --- a/MAINTAINERS.md +++ b/MAINTAINERS.md @@ -8,7 +8,7 @@ Fork [minio-py upstream](https://github.com/minio/minio-py/fork) source reposito ```sh $ git clone git@github.com:minio/minio-py $ cd minio-py -$ pip install urllib3 certifi pyflakes faker twine +$ pip install --user --upgrade twine ``` ### Modify package version @@ -23,10 +23,9 @@ __version__ = '2.2.5' ``` ### Build and verify -Run `./tests/unit_test.sh` and `./tests/functional_test.sh` to verify the SDK. ```sh -$ ./tests/unit_test.sh -$ ./tests/functional_test.sh all +$ make +$ python setup.py register $ python setup.py sdist bdist bdist_wheel ``` diff --git a/Makefile b/Makefile index 39f33544f..05ba13a7d 100644 --- a/Makefile +++ b/Makefile @@ -1,9 +1,12 @@ -.PHONY: examples tests publish +.PHONY: default +default: tests getdeps: - @pip install --user --upgrade pylint autopep8 + @echo "Installing required dependencies" + @pip install --user --upgrade autopep8 certifi configparser mock nose pylint urllib3 check: getdeps + @echo "Running checks" @pylint --reports=no --score=no --disable=R0401,R0801 minio/*py @pylint --reports=no --score=no minio/credentials tests/functional @isort --diff . @@ -13,9 +16,8 @@ apply: getdeps @isort . @find . -name "*.py" -exec autopep8 --in-place {} + -publish: - python setup.py register - python setup.py sdist bdist bdist_wheel upload - -tests: - python setup.py nosetests +tests: check + @echo "Running unit tests" + @nosetests + @echo "Running functional tests" + @(env bash run_functional_tests.sh) diff --git a/run_functional_tests.sh b/run_functional_tests.sh new file mode 100755 index 000000000..199ad8598 --- /dev/null +++ b/run_functional_tests.sh @@ -0,0 +1,51 @@ +#!/usr/bin/env bash +# +# MinIO Python Library for Amazon S3 Compatible Cloud Storage, (C) 2020 MinIO, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +function run_minio_server() { + if [ ! -f tests/functional/minio ]; then + wget --quiet -output-document tests/functional/minio https://dl.min.io/server/minio/release/linux-amd64/minio + chmod +x tests/functional/minio + fi + + export MINIO_ACCESS_KEY=minio + export MINIO_SECRET_KEY=minio123 + export MINIO_KMS_KES_ENDPOINT=https://play.min.io:7373 + export MINIO_KMS_KES_KEY_FILE=tests/functional/play.min.io.kes.root.key + export MINIO_KMS_KES_CERT_FILE=tests/functional/play.min.io.kes.root.cert + export MINIO_KMS_KES_KEY_NAME=my-minio-key + export MINIO_NOTIFY_WEBHOOK_ENABLE_miniopytest=on + export MINIO_NOTIFY_WEBHOOK_ENDPOINT_miniopytest=http://example.org/ + export SQS_ARN="arn:minio:sqs::miniopytest:webhook" + tests/functional/minio server --config-dir tests/functional/.cfg tests/functional/.d{1...4} >tests/functional/minio.log 2>&1 & +} + +if [ -z ${SERVER_ENDPOINT+x} ]; then + run_minio_server + MINIO_PID=$! + trap "kill -9 $MINIO_PID" INT + + export MINT_MODE=full + export SERVER_ENDPOINT=localhost:9000 + export ACCESS_KEY=minio + export SECRET_KEY=minio123 + export ENABLE_HTTPS=0 +fi + +PYTHONPATH=$PWD python tests/functional/tests.py +if [ -n "$MINIO_PID" ]; then + kill -9 "$MINIO_PID" +fi diff --git a/tests/functional/play.min.io.kes.root.cert b/tests/functional/play.min.io.kes.root.cert new file mode 100644 index 000000000..5f220f79b --- /dev/null +++ b/tests/functional/play.min.io.kes.root.cert @@ -0,0 +1,9 @@ +-----BEGIN CERTIFICATE----- +MIIBKDCB26ADAgECAhB6vebGMUfKnmBKyqoApRSOMAUGAytlcDAbMRkwFwYDVQQD +DBByb290QHBsYXkubWluLmlvMB4XDTIwMDQzMDE1MjIyNVoXDTI1MDQyOTE1MjIy +NVowGzEZMBcGA1UEAwwQcm9vdEBwbGF5Lm1pbi5pbzAqMAUGAytlcAMhALzn735W +fmSH/ghKs+4iPWziZMmWdiWr/sqvqeW+WwSxozUwMzAOBgNVHQ8BAf8EBAMCB4Aw +EwYDVR0lBAwwCgYIKwYBBQUHAwIwDAYDVR0TAQH/BAIwADAFBgMrZXADQQDZOrGK +b2ATkDlu2pTcP3LyhSBDpYh7V4TvjRkBTRgjkacCzwFLm+mh+7US8V4dBpIDsJ4u +uWoF0y6vbLVGIlkG +-----END CERTIFICATE----- diff --git a/tests/functional/play.min.io.kes.root.key b/tests/functional/play.min.io.kes.root.key new file mode 100644 index 000000000..53a47e25d --- /dev/null +++ b/tests/functional/play.min.io.kes.root.key @@ -0,0 +1,3 @@ +-----BEGIN PRIVATE KEY----- +MC4CAQAwBQYDK2VwBCIEID9E7FSYWrMD+VjhI6q545cYT9YOyFxZb7UnjEepYDRc +-----END PRIVATE KEY----- diff --git a/tests/functional_test.sh b/tests/functional_test.sh deleted file mode 100755 index b10ff288f..000000000 --- a/tests/functional_test.sh +++ /dev/null @@ -1,30 +0,0 @@ -#!/usr/bin/env bash -# -# MinIO Python Library for Amazon S3 Compatible Cloud Storage, (C) 2017 MinIO, Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -main () { - echo "Running python tests..." - - echo "building..." - (cd ..; python setup.py install --prefix ${HOME}/.local; cd -) - - echo "running..." - python ./functional/tests.py -} - -# invoke the script -# Move to the directory which contains this script and invoke it -cd $(dirname $(realpath $0)) && main "$@" diff --git a/tests/unit_test.sh b/tests/unit_test.sh deleted file mode 100755 index 4c1173aa6..000000000 --- a/tests/unit_test.sh +++ /dev/null @@ -1,17 +0,0 @@ -#!/usr/bin/env bash -# -# MinIO Python Library for Amazon S3 Compatible Cloud Storage, (C) 2017 MinIO, Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -echo "Running unit tests... " && python setup.py nosetests