diff --git a/hooks/lib/check-unittest.sh b/hooks/lib/check-unittest.sh index 95b2c28bc3..b706324feb 100755 --- a/hooks/lib/check-unittest.sh +++ b/hooks/lib/check-unittest.sh @@ -24,7 +24,7 @@ fi # Unit test failures can't easily be mapped to specific input files. # Always run all tests, and report a failure via nonzero exit code if # any test fails. -if ! tox -e py27 >&2; then +if ! tox -e py27,scripttests >&2; then >&2 echo "*** tox failed. Note: If dependencies have changed, try "\ "running 'tox -r' to update the tox environment" exit 1 diff --git a/requirements-testing.txt b/requirements-testing.txt index 7694ae4d6a..1cafe4e9ff 100644 --- a/requirements-testing.txt +++ b/requirements-testing.txt @@ -29,3 +29,6 @@ mock>=1.0.1 nose>=1.3 flake8>=2.1.0 psutil==3.0.0 +gcs-oauth2-boto-plugin +azure + diff --git a/script-tests/object_storage_worker_tests.py b/script-tests/object_storage_worker_tests.py new file mode 100644 index 0000000000..46171d35fe --- /dev/null +++ b/script-tests/object_storage_worker_tests.py @@ -0,0 +1,45 @@ +# Copyright 2016 PerfKitBenchmarker Authors. All rights reserved. +# +# 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. + +"""Tests for the object_storage_service benchmark worker process.""" + +import itertools +import unittest + +import object_storage_api_tests + + +class TestSizeDistributionIterator(unittest.TestCase): + def testPointDistribution(self): + dist = {} + dist[10] = 100.0 + + iter = object_storage_api_tests.SizeDistributionIterator(dist) + + lst = list(itertools.islice(iter, 5)) + + self.assertEqual(lst, [10, 10, 10, 10, 10]) + + +class TestMaxSizeInDistribution(unittest.TestCase): + def testPointDistribution(self): + dist = {} + dist[10] = 100.0 + + self.assertEqual(object_storage_api_tests.MaxSizeInDistribution(dist), + 10) + + +if __name__ == '__main__': + unittest.main() diff --git a/tox.ini b/tox.ini index 430658cb81..9c63c5b2fa 100644 --- a/tox.ini +++ b/tox.ini @@ -4,7 +4,7 @@ # and then run "tox" from this directory. [tox] -envlist = py27,flake8 +envlist = py27,flake8,scripttests [testenv] usedevelop = True @@ -14,10 +14,15 @@ passenv = HOME deps = -rrequirements-testing.txt +[testenv:scripttests] +commands = nosetests {toxinidir}/script-tests [] +setenv = + PYTHONPATH = {toxinidir}/perfkitbenchmarker/scripts:{env:PYTHONPATH} + [testenv:flake8] skip_install = True usedevelop = True -commands = flake8 perfkitbenchmarker tests pkb.py +commands = flake8 perfkitbenchmarker tests script-tests pkb.py deps = flake8==2.4.1 pep8==1.5.7