Skip to content

Commit

Permalink
changes coverage to an opt out with NO_COVERAGE env var (#2480)
Browse files Browse the repository at this point in the history
  • Loading branch information
gmmeyer committed May 6, 2016
1 parent f69d10a commit ea06786
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 8 deletions.
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ matrix:
env:
global:
- CONCURRENCY=2
- COVERAGE=true
- NOSE_FILTER="not windows"
- INTEGRATIONS_DIR=$HOME/embedded
- PIP_CACHE=$HOME/.cache/pip
Expand Down
1 change: 0 additions & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ environment:
VOLATILE_DIR: c:\projects
NOSE_FILTER: windows
FLAVORS: windows
COVERAGE: true
PYWIN_PATH: C:\projects\dd-agent\.cache\pywin32-py2.7.exe
matrix:
- PYTHON: C:\\Python27
Expand Down
8 changes: 8 additions & 0 deletions tests/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,14 @@ rake ci:run[bone]

To create rake tasks for a new flavor you can use this [skeleton file](../ci/skeleton.rb).

# Coverage

We like to see that the metrics being generated are actually covered by tests. For the integration tests you can call the method self.coverage_report() in your test to see how many of the metrics you're actually looking at.

Note, however, that Travis and Appveyor enforce coverage. It will fail the test if you don't have 100% coverage.

But, since the we also know that the coverage report is very verbose, and that it can be annoying to fail a test for this, we don't enforce it being called where it doesn't make sense. And we also allow you to turn off the failure locally by setting the environment variable: `NO_COVERAGE=true`.


# Travis

Expand Down
2 changes: 1 addition & 1 deletion tests/checks/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ def coverage_report(self):
untested_events=pformat(untested_events),
))

if os.getenv('COVERAGE'):
if not os.getenv('NO_COVERAGE'):
self.assertEquals(coverage_metrics, 100.0)
self.assertEquals(coverage_events, 100.0)
self.assertEquals(coverage_sc, 100.0)
Expand Down
2 changes: 1 addition & 1 deletion tests/checks/integration/test_mysql.py
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ def test_complex_config(self):
+ self.OPTIONAL_STATUS_VARS
+ self.OPTIONAL_STATUS_VARS_5_6_6), 1)

# Raises when COVERAGE=true and coverage < 100%
# Raises when coverage < 100%
self.coverage_report()

def test_connection_failure(self):
Expand Down
2 changes: 1 addition & 1 deletion tests/checks/integration/test_process.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ def test_check(self, mock_process):
else:
self.assertServiceCheckOK('process.up', count=1, tags=expected_tags)

# Raises when COVERAGE=true and coverage < 100%
# Raises when coverage < 100%
self.coverage_report()

# Run the check a second time and check that `cpu_pct` is there
Expand Down
2 changes: 1 addition & 1 deletion tests/checks/integration/test_supervisord.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def test_check(self):
self.assertServiceCheck("supervisord.can_connect", status=AgentCheck.OK,
tags=instance_tags, count=1)

# Raises when COVERAGE=true and coverage < 100%
# Raises when coverage < 100%
self.coverage_report()

# Sleep 10s to give enough time to processes to terminate
Expand Down
4 changes: 2 additions & 2 deletions tests/checks/mock/test_directory.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ def test_directory_metrics(self):
# 12 files in 'temp_dir'
self.assertMetric("system.disk.directory.files", tags=dir_tags, count=1, value=12)

# Raises when COVERAGE=true and coverage < 100%
# Raises when coverage < 100%
self.coverage_report()

def test_file_metrics(self):
Expand Down Expand Up @@ -169,5 +169,5 @@ def test_file_metrics(self):
for mname in self.COMMON_METRICS:
self.assertMetric(mname, tags=dir_tags, count=1)

# Raises when COVERAGE=true and coverage < 100%
# Raises when coverage < 100%
self.coverage_report()

0 comments on commit ea06786

Please sign in to comment.