From 1815ad27684435a0612c987b5d6d8893417593f8 Mon Sep 17 00:00:00 2001 From: Prashanth Pai Date: Thu, 10 Mar 2016 11:38:07 +0530 Subject: Fix and simplify tox.ini * Remove deprecated tox options * Simplify tox.ini * Update .gitignore * Update test-requirements.txt * Fix pep8 issues All tests now run on centos7 without any modifications. Code coverage output is now displayed properly for both unit test and functional test runs. Change-Id: I877cc0ad2c560579c12d528af3ac9bf5eea28378 Signed-off-by: Prashanth Pai --- .functests | 28 ++++++++++++++++++++++++++++ .gitignore | 14 +++++++------- functional_tests.sh | 46 ---------------------------------------------- gluster/__init__.py | 4 +--- gluster/api.py | 10 ++++------ test-requirements.txt | 4 +--- tox.ini | 30 +++++++++--------------------- 7 files changed, 50 insertions(+), 86 deletions(-) create mode 100755 .functests delete mode 100755 functional_tests.sh diff --git a/.functests b/.functests new file mode 100755 index 0000000..44739c0 --- /dev/null +++ b/.functests @@ -0,0 +1,28 @@ +#!/bin/bash + +# Copyright (c) 2014 Red Hat, 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. + +# This program expects to be run by tox in a virtual python environment +# so that it does not pollute the host development system + +SRC_DIR=$(python -c "import os; print os.path.dirname(os.path.realpath('$0'))") +set -e +cd ${SRC_DIR} + +nosetests -v --exe test/functional +rvalue=$? +cd - +exit $rvalue diff --git a/.gitignore b/.gitignore index 5aa73ab..32ade1e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,9 +1,9 @@ +*.py[co] .tox -gfapi.egg-info -test/unit/.coverage -test/unit/nosetests.xml -test/unit/coverage.xml -test/unit/cover -functional_tests +*.egg +*.egg-info +.coverage +cover +pycscope.* build -*.pyc +dist diff --git a/functional_tests.sh b/functional_tests.sh deleted file mode 100755 index 32fcbe6..0000000 --- a/functional_tests.sh +++ /dev/null @@ -1,46 +0,0 @@ -#!/bin/bash - -# Copyright (c) 2014 Red Hat, 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. - -# This program expects to be run by tox in a virtual python environment -# so that it does not pollute the host development system - -cleanup() -{ - if [ -d "/export/brick/b1/" ]; then - sudo rm -rf /export/brick/b1/* > /dev/null 2>&1 - fi -} - -fail() -{ - cleanup - echo "$1" - exit 1 -} - -### MAIN ### - -mkdir functional_tests > /dev/null 2>&1 -nosetests -v --exe \ - --with-xunit \ - --xunit-file functional_tests/libgfapi-python.xml \ - --with-html-output \ - --html-out-file functional_tests/libgfapi-python-result.html \ - test/functional || fail "Functional tests failed" - -cleanup -exit 0 diff --git a/gluster/__init__.py b/gluster/__init__.py index 4562ec8..351a4f3 100644 --- a/gluster/__init__.py +++ b/gluster/__init__.py @@ -41,9 +41,7 @@ class PkgInfo(object): return '%s-dev' % (self.canonical_version,) -### -### Change the Package version here -### +# Change the Package version here _pkginfo = PkgInfo('0.0.1', '0', 'python-libgfapi', False) __version__ = _pkginfo.pretty_version __canonical_version__ = _pkginfo.canonical_version diff --git a/gluster/api.py b/gluster/api.py index c0bad67..7163076 100755 --- a/gluster/api.py +++ b/gluster/api.py @@ -200,7 +200,7 @@ class Dirent (ctypes.Structure): # glfs_posix_lock; # glfs_dup; # -# } +# } # # GFAPI_3.4.2 { # glfs_setfsuid; @@ -478,10 +478,8 @@ glfs_getcwd = gfapi_prototype('glfs_getcwd', ctypes.c_char_p, # TODO: # discard and fallocate fails with "AttributeError: /lib64/libgfapi.so.0: undefined symbol: glfs_discard", # noqa # for time being, using it from api.* # noqa # glfs_discard = ctypes.CFUNCTYPE(ctypes.c_int, ctypes.c_void_p, ctypes.c_ulong, ctypes.c_size_t)(('glfs_discard', client)) # noqa -#_glfs_fallocate = ctypes.CFUNCTYPE(ctypes.c_int, ctypes.c_void_p, ctypes.c_int, ctypes.c_ulong, ctypes.c_size_t) # noqa +# _glfs_fallocate = ctypes.CFUNCTYPE(ctypes.c_int, ctypes.c_void_p, ctypes.c_int, ctypes.c_ulong, ctypes.c_size_t) # noqa # (('glfs_fallocate', client)) # noqa - - -#glfs_discard = ctypes.CFUNCTYPE(ctypes.c_int, ctypes.c_void_p, ctypes.c_ulong, ctypes.c_size_t)(('glfs_discard', client)) # noqa -#glfs_fallocate = ctypes.CFUNCTYPE(ctypes.c_int, ctypes.c_void_p, ctypes.c_int, ctypes.c_ulong, ctypes.c_size_t)(('glfs_fallocate', client)) # noqa +# glfs_discard = ctypes.CFUNCTYPE(ctypes.c_int, ctypes.c_void_p, ctypes.c_ulong, ctypes.c_size_t)(('glfs_discard', client)) # noqa +# glfs_fallocate = ctypes.CFUNCTYPE(ctypes.c_int, ctypes.c_void_p, ctypes.c_int, ctypes.c_ulong, ctypes.c_size_t)(('glfs_fallocate', client)) # noqa diff --git a/test-requirements.txt b/test-requirements.txt index 4ddce0f..c6662ef 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -1,9 +1,7 @@ # Hacking already pins down pep8, pyflakes and flake8 -hacking>=0.8.0,<0.9 +hacking>=0.10.0,<0.11 coverage nose nosexcover -openstack.nose_plugin nosehtmloutput -sphinx>=1.1.2 mock>=1.0 diff --git a/tox.ini b/tox.ini index 6965bac..b9213ba 100644 --- a/tox.ini +++ b/tox.ini @@ -1,40 +1,28 @@ [tox] envlist = py26,py27,pep8 +minversion = 1.6 [testenv] -whitelist_externals=bash passenv = LD_LIBRARY_PATH setenv = VIRTUAL_ENV={envdir} - NOSE_WITH_OPENSTACK=1 - NOSE_OPENSTACK_COLOR=1 - NOSE_OPENSTACK_RED=0.05 - NOSE_OPENSTACK_YELLOW=0.025 - NOSE_OPENSTACK_SHOW_ELAPSED=1 - NOSE_OPENSTACK_STDOUT=1 + NOSE_WITH_COVERAGE=1 + NOSE_COVER_BRANCHES=1 + NOSE_COVER_ERASE=1 + NOSE_COVER_PACKAGE=gluster deps = - --download-cache={homedir}/.pipcache -r{toxinidir}/test-requirements.txt -changedir = {toxinidir}/test/unit -commands = nosetests -v --exe --with-xunit --with-coverage --cover-package gluster --cover-erase --cover-xml --cover-html --cover-branches --with-html-output {posargs} - -[tox:jenkins] -downloadcache = ~/cache/pip +commands = nosetests -v {posargs:test/unit} [testenv:functest] -changedir = {toxinidir} -commands = bash functional_tests.sh +commands = ./.functests {posargs} [testenv:pep8] -deps = - --download-cache={homedir}/.pipcache - -r{toxinidir}/test-requirements.txt -changedir = {toxinidir} commands = - flake8 setup.py - flake8 gluster test + flake8 {posargs:gluster test setup.py} [testenv:cover] setenv = NOSE_WITH_COVERAGE=1 + NOSE_COVER_BRANCHES=1 [testenv:venv] commands = {posargs} -- cgit