Commit 41a9e027 by Christine Lytwynec

Revert "Revert "Clytwynec/unique dirs for test results""

This reverts commit 52c4aaca.
parent e9521432
...@@ -14,19 +14,21 @@ class TestPaverBokChoyCmd(unittest.TestCase): ...@@ -14,19 +14,21 @@ class TestPaverBokChoyCmd(unittest.TestCase):
def _expected_command(self, expected_text_append, expected_default_store=None): def _expected_command(self, expected_text_append, expected_default_store=None):
if expected_text_append: if expected_text_append:
expected_text_append = "/" + expected_text_append expected_text_append = "/" + expected_text_append
shard = os.environ.get('SHARD')
expected_statement = ( expected_statement = (
"DEFAULT_STORE={default_store} " "DEFAULT_STORE={default_store} "
"SCREENSHOT_DIR='{repo_dir}/test_root/log' " "SCREENSHOT_DIR='{repo_dir}/test_root/log{shard_str}' "
"BOK_CHOY_HAR_DIR='{repo_dir}/test_root/log/hars' " "BOK_CHOY_HAR_DIR='{repo_dir}/test_root/log{shard_str}/hars' "
"SELENIUM_DRIVER_LOG_DIR='{repo_dir}/test_root/log' " "SELENIUM_DRIVER_LOG_DIR='{repo_dir}/test_root/log{shard_str}' "
"nosetests {repo_dir}/common/test/acceptance/tests{exp_text} " "nosetests {repo_dir}/common/test/acceptance/tests{exp_text} "
"--with-xunit " "--with-xunit "
"--xunit-file={repo_dir}/reports/bok_choy/xunit.xml " "--xunit-file={repo_dir}/reports/bok_choy{shard_str}/xunit.xml "
"--verbosity=2" "--verbosity=2 "
).format( ).format(
default_store=expected_default_store, default_store=expected_default_store,
repo_dir=REPO_DIR, repo_dir=REPO_DIR,
exp_text=expected_text_append, exp_text=expected_text_append,
shard_str='/shard_' + shard if shard else '',
) )
return expected_statement.strip() return expected_statement.strip()
......
...@@ -214,6 +214,18 @@ def coverage(options): ...@@ -214,6 +214,18 @@ def coverage(options):
@task @task
@needs('pavelib.prereqs.install_prereqs') @needs('pavelib.prereqs.install_prereqs')
def combine_coverage():
"""
Combine coverage reports.
"""
for directory in Env.LIB_TEST_DIRS + ['cms', 'lms']:
report_dir = Env.REPORT_DIR / directory
if report_dir.isdir():
sh("cd {} && coverage combine".format(report_dir))
@task
@needs('pavelib.prereqs.install_prereqs')
@cmdopts([ @cmdopts([
("compare_branch=", "b", "Branch to compare against, defaults to origin/master"), ("compare_branch=", "b", "Branch to compare against, defaults to origin/master"),
]) ])
......
...@@ -28,6 +28,15 @@ class Env(object): ...@@ -28,6 +28,15 @@ class Env(object):
BOK_CHOY_REPORT_DIR = REPORT_DIR / "bok_choy" BOK_CHOY_REPORT_DIR = REPORT_DIR / "bok_choy"
BOK_CHOY_COVERAGERC = BOK_CHOY_DIR / ".coveragerc" BOK_CHOY_COVERAGERC = BOK_CHOY_DIR / ".coveragerc"
# If set, put reports for run in "unique" directories.
# The main purpose of this is to ensure that the reports can be 'slurped'
# in the main jenkins flow job without overwriting the reports from other
# build steps. For local development/testing, this shouldn't be needed.
if os.environ.get("SHARD", None):
shard_str = "shard_{}".format(os.environ.get("SHARD"))
BOK_CHOY_REPORT_DIR = BOK_CHOY_REPORT_DIR / shard_str
BOK_CHOY_LOG_DIR = BOK_CHOY_LOG_DIR / shard_str
# For the time being, stubs are used by both the bok-choy and lettuce acceptance tests # For the time being, stubs are used by both the bok-choy and lettuce acceptance tests
# For this reason, the stubs package is currently located in the Django app called "terrain" # For this reason, the stubs package is currently located in the Django app called "terrain"
# where other lettuce configuration is stored. # where other lettuce configuration is stored.
......
...@@ -21,6 +21,15 @@ class NoseTestSuite(TestSuite): ...@@ -21,6 +21,15 @@ class NoseTestSuite(TestSuite):
self.fail_fast = kwargs.get('fail_fast', False) self.fail_fast = kwargs.get('fail_fast', False)
self.run_under_coverage = kwargs.get('with_coverage', True) self.run_under_coverage = kwargs.get('with_coverage', True)
self.report_dir = Env.REPORT_DIR / self.root self.report_dir = Env.REPORT_DIR / self.root
# If set, put reports for run in "unique" directories.
# The main purpose of this is to ensure that the reports can be 'slurped'
# in the main jenkins flow job without overwriting the reports from other
# build steps. For local development/testing, this shouldn't be needed.
if os.environ.get("SHARD", None):
shard_str = "shard_{}".format(os.environ.get("SHARD"))
self.report_dir = self.report_dir / shard_str
self.test_id_dir = Env.TEST_DIR / self.root self.test_id_dir = Env.TEST_DIR / self.root
self.test_ids = self.test_id_dir / 'noseids' self.test_ids = self.test_id_dir / 'noseids'
self.extra_args = kwargs.get('extra_args', '') self.extra_args = kwargs.get('extra_args', '')
...@@ -112,12 +121,14 @@ class SystemTestSuite(NoseTestSuite): ...@@ -112,12 +121,14 @@ class SystemTestSuite(NoseTestSuite):
def cmd(self): def cmd(self):
cmd = ( cmd = (
'./manage.py {system} test --verbosity={verbosity} ' './manage.py {system} test --verbosity={verbosity} '
'{test_id} {test_opts} --traceback --settings=test {extra}'.format( '{test_id} {test_opts} --traceback --settings=test {extra} '
'--with-xunit --xunit-file={xunit_report}'.format(
system=self.root, system=self.root,
verbosity=self.verbosity, verbosity=self.verbosity,
test_id=self.test_id, test_id=self.test_id,
test_opts=self.test_options_flags, test_opts=self.test_options_flags,
extra=self.extra_args, extra=self.extra_args,
xunit_report=self.report_dir / "nosetests.xml",
) )
) )
......
...@@ -98,14 +98,12 @@ END ...@@ -98,14 +98,12 @@ END
"unit") "unit")
case "$SHARD" in case "$SHARD" in
"lms") "lms")
paver test_system -s lms --extra_args="--with-flaky" || { EXIT=1; } SHARD=1 paver test_system -s lms --extra_args="--with-flaky" --cov_args="-p" || { EXIT=1; }
paver coverage
;; ;;
"cms-js-commonlib") "cms-js-commonlib")
paver test_system -s cms --extra_args="--with-flaky" || { EXIT=1; } SHARD=1 paver test_system -s cms --extra_args="--with-flaky" --cov_args="-p" || { EXIT=1; }
paver test_js --coverage --skip_clean || { EXIT=1; } SHARD=1 paver test_js --coverage --skip_clean || { EXIT=1; }
paver test_lib --skip_clean --extra_args="--with-flaky" || { EXIT=1; } SHARD=1 paver test_lib --skip_clean --extra_args="--with-flaky" --cov_args="-p" || { EXIT=1; }
paver coverage
;; ;;
*) *)
paver test --extra_args="--with-flaky" paver test --extra_args="--with-flaky"
...@@ -210,15 +208,4 @@ END ...@@ -210,15 +208,4 @@ END
END END
;; ;;
esac esac
# Move the reports to a directory that is unique to the shard
# so that when they are 'slurped' to the main flow job, they
# do not conflict with and overwrite reports from other shards.
mv reports/ reports_tmp/
mkdir -p reports/${TEST_SUITE}/${SHARD}
mv reports_tmp/* reports/${TEST_SUITE}/${SHARD}
rm -r reports_tmp/
exit $EXIT
;;
esac esac
#!/usr/bin/env bash #!/usr/bin/env bash
source scripts/jenkins-common.sh source scripts/jenkins-common.sh
# Run coverage again to get the diff coverage report # Combine the data files that were generated using -p
paver diff_coverage paver combine_coverage
# Get the diff coverage and html reports for unit tests
paver coverage
# JUnit test reporter will fail the build # JUnit test reporter will fail the build
# if it thinks test results are old # if it thinks test results are old
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment