Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[tests] split tests/ into two subdirectories #1571

Merged
merged 2 commits into from
Apr 27, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ node_modules/*
venv/*
*.swp
*.log
!nagios.log
*.pid
*.deb
*.rpm
Expand Down
11 changes: 7 additions & 4 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ unless ENV['TRAVIS']
end

desc 'Setup a development environment for the Agent'
task "setup_env" do
task 'setup_env' do
`mkdir -p venv`
`wget -O venv/virtualenv.py https://raw.github.com/pypa/virtualenv/1.11.6/virtualenv.py`
`python venv/virtualenv.py --no-site-packages --no-pip --no-setuptools venv/`
Expand All @@ -64,23 +64,26 @@ end
namespace :test do
desc 'Run dogstatsd tests'
task 'dogstatsd' do
sh 'nosetests tests/test_dogstatsd.py'
sh 'nosetests tests/core/test_dogstatsd.py'
end

desc 'Run performance tests'
task 'performance' do
sh 'nosetests --with-xunit --xunit-file=nosetests-performance.xml tests/performance/benchmark*.py'
sh 'nosetests --with-xunit --xunit-file=nosetests-performance.xml tests/core/benchmark*.py'
end

desc 'cProfile unit tests (requires \'nose-cprof\')'
task 'profile' do
sh 'nosetests --with-cprofile tests/performance/benchmark*.py'
sh 'nosetests --with-cprofile tests/core/benchmark*.py'
end

desc 'cProfile tests, then run pstats'
task 'profile:pstats' => ['test:profile'] do
sh 'python -m pstats stats.dat'
end

desc 'Display test coverage for checks'
task 'coverage' => 'ci:default:coverage'
end

desc 'Lint the code through pylint'
Expand Down
26 changes: 0 additions & 26 deletions checks/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -682,32 +682,6 @@ def agent_formatter(metric, value, timestamp, tags, hostname, device_name=None,
return (metric, int(timestamp), value)


def run_check(name, path=None):
from tests.common import get_check

# Read the config file
confd_path = path or os.path.join(get_confd_path(get_os()), '%s.yaml' % name)

try:
f = open(confd_path)
except IOError:
raise Exception('Unable to open configuration at %s' % confd_path)

config_str = f.read()
f.close()

# Run the check
check, instances = get_check(name, config_str)
if not instances:
raise Exception('YAML configuration returned no instances.')
for instance in instances:
check.check(instance)
if check.has_events():
print "Events:\n"
pprint(check.get_events(), indent=4)
print "Metrics:\n"
pprint(check.get_metrics(), indent=4)

def create_service_check(check_name, status, tags=None, timestamp=None,
hostname=None, check_run_id=None, message=None):
""" Create a service_check dict. See AgentCheck.service_check() for
Expand Down
33 changes: 32 additions & 1 deletion ci/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,37 @@
namespace :default do |flavor|
task :before_install => ['ci:common:before_install']

task :coverage do
ci_dir = File.dirname(__FILE__)
checks_dir = File.join(ci_dir, '..', 'checks.d')
tests_checks_dir = File.join(ci_dir, '..', 'tests', 'checks')
mock_dir = File.join(tests_checks_dir, 'mock')
integration_dir = File.join(tests_checks_dir, 'integration')
untested, mocked, perfects = [], [], []
Dir.glob(File.join(checks_dir, '*.py')).each do |check|
check_name = /((\w|_)+).py$/.match(check)[1]
if File.exist?(File.join(integration_dir, "test_#{check_name}.py"))
perfects.push(check_name)
elsif File.exist?(File.join(mock_dir, "test_#{check_name}.py"))
mocked.push(check_name)
else
untested.push(check_name)
end
end
total_checks = (untested + mocked + perfects).length
unless untested.empty?
puts "Untested checks (#{untested.length}/#{total_checks})".red
puts '-----------------------'.red
untested.each { |check_name| puts check_name.red }
puts ''
end
unless mocked.empty?
puts "Mocked tests (#{mocked.length}/#{total_checks})".yellow
puts '--------------------'.yellow
mocked.each { |check_name| puts check_name.yellow }
end
end

task :install => ['ci:common:install']

task :before_script => ['ci:common:before_script']
Expand All @@ -12,7 +43,7 @@
sh %(find . -name '*.py' -not \\( -path '*.cache*' -or -path '*embedded*' -or -path '*venv*' \\) | xargs -n 1 pylint --rcfile=./.pylintrc)
end

task :script => ['ci:common:script', :lint] do
task :script => ['ci:common:script', :coverage, :lint] do
Rake::Task['ci:common:run_tests'].invoke('default')
end

Expand Down
6 changes: 3 additions & 3 deletions ez_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,9 @@ def do_download():
try:
import pkg_resources
except ImportError:
return do_download()
return do_download()
try:
pkg_resources.require("setuptools>="+version); return
pkg_resources.require("setuptools>="+version); return #pylint: disable=E1102
except pkg_resources.VersionConflict, e:
if was_imported:
print >>sys.stderr, (
Expand Down Expand Up @@ -225,7 +225,7 @@ def main(argv, version=DEFAULT_VERSION):
req = "setuptools>="+version
import pkg_resources
try:
pkg_resources.require(req)
pkg_resources.require(req) #pylint: disable=E1102
except pkg_resources.VersionConflict:
try:
from setuptools.command.easy_install import main
Expand Down
194 changes: 0 additions & 194 deletions tests/cassandra/cfstats

This file was deleted.

5 changes: 0 additions & 5 deletions tests/cassandra/info

This file was deleted.

9 changes: 0 additions & 9 deletions tests/cassandra/info.8

This file was deleted.

10 changes: 0 additions & 10 deletions tests/cassandra/info.opp

This file was deleted.

14 changes: 0 additions & 14 deletions tests/cassandra/tpstats

This file was deleted.

Loading