Repository: aurora Updated Branches: refs/heads/master 942760466 -> bd1218867
Add a workaround for test_du_diskcollector failing on macOS Bugs closed: AURORA-1956 Reviewed at https://reviews.apache.org/r/63746/ Project: http://git-wip-us.apache.org/repos/asf/aurora/repo Commit: http://git-wip-us.apache.org/repos/asf/aurora/commit/bd121886 Tree: http://git-wip-us.apache.org/repos/asf/aurora/tree/bd121886 Diff: http://git-wip-us.apache.org/repos/asf/aurora/diff/bd121886 Branch: refs/heads/master Commit: bd12188674c15e743b17acaa4491f7db6cba61e4 Parents: 9427604 Author: Bill Farner <[email protected]> Authored: Mon Nov 13 13:44:39 2017 -0800 Committer: Bill Farner <[email protected]> Committed: Mon Nov 13 13:44:39 2017 -0800 ---------------------------------------------------------------------- build-support/python/make-pycharm-virtualenv | 20 ++++++++++------ .../apache/thermos/monitoring/test_disk.py | 24 +++++++++++++------- 2 files changed, 29 insertions(+), 15 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/aurora/blob/bd121886/build-support/python/make-pycharm-virtualenv ---------------------------------------------------------------------- diff --git a/build-support/python/make-pycharm-virtualenv b/build-support/python/make-pycharm-virtualenv index 0f422d6..b1b575a 100755 --- a/build-support/python/make-pycharm-virtualenv +++ b/build-support/python/make-pycharm-virtualenv @@ -29,13 +29,19 @@ pushd "$BUILDROOT" # TODO(John Sirois): Either get this info from the current pants install itself instead of # using a parallel ephemeral install like we do here (slow), or else invert things and # allow user-control of the pytest lib versions within reason. - rm -rf "$VENV_DIR" - ./build-support/virtualenv "$VENV_DIR" - source $VENV_DIR/bin/activate - python -m pip install pantsbuild.pants==$(./pants --version) - pytest_requirement=$(python -m pip freeze | grep pytest==) - pytest_cov_requirement=$(python -m pip freeze | grep pytest-cov==) - deactivate + + #rm -rf "$VENV_DIR" + #./build-support/virtualenv "$VENV_DIR" + #source $VENV_DIR/bin/activate + # python -m pip install pantsbuild.pants==$(./pants --version) + # pytest_requirement=$(python -m pip freeze | grep pytest==) + # pytest_cov_requirement=$(python -m pip freeze | grep pytest-cov==) + #deactivate + # TODO(wfarner): The above attempt to fetch pytest versions from pants stopped + # working with commit 0c177058. As a workaround, manually specify the versions + # for now. + pytest_requirement='pytest==3.2.3' + pytest_cov_requirement='pytest-cov==2.5.1' rm -rf "$VENV_DIR" ./build-support/virtualenv "$VENV_DIR" http://git-wip-us.apache.org/repos/asf/aurora/blob/bd121886/src/test/python/apache/thermos/monitoring/test_disk.py ---------------------------------------------------------------------- diff --git a/src/test/python/apache/thermos/monitoring/test_disk.py b/src/test/python/apache/thermos/monitoring/test_disk.py index e57467c..362393b 100644 --- a/src/test/python/apache/thermos/monitoring/test_disk.py +++ b/src/test/python/apache/thermos/monitoring/test_disk.py @@ -14,7 +14,9 @@ import os from tempfile import mkstemp +from unittest import TestCase +from twitter.common import dirutil from twitter.common.dirutil import safe_mkdtemp from twitter.common.quantity import Amount, Data @@ -29,6 +31,11 @@ def make_file(size, dir): _, filename = mkstemp(dir=dir) with open(filename, 'w') as f: f.write('0' * int(size.as_(Data.BYTES))) + + # Workaround for AURORA-1956. On macOS 10.13 with APFS, st_blocks is not + # consistent with st_size. + while dirutil.safe_size(filename) < int(size.as_(Data.BYTES)): + f.write('0' * 1024) return filename @@ -52,13 +59,14 @@ def _run_collector_tests(collector, target, wait): assert TEST_AMOUNT_SUM.as_(Data.BYTES) > collector.value >= TEST_AMOUNT_2.as_(Data.BYTES) -def test_du_diskcollector(): - target = safe_mkdtemp() - collector = DiskCollector(target) +class TestDiskCollector(TestCase): + def test_du_diskcollector(self): + target = safe_mkdtemp() + collector = DiskCollector(target) - def wait(): - collector.sample() - if collector._thread is not None: - collector._thread.event.wait() + def wait(): + collector.sample() + if collector._thread is not None: + collector._thread.event.wait() - _run_collector_tests(collector, target, wait) + _run_collector_tests(collector, target, wait)
