From a3f2f632bc9ea27b3c7b6ca1beab074e455665ba Mon Sep 17 00:00:00 2001 From: Andrew Schoen Date: Wed, 12 Nov 2014 15:21:27 -0600 Subject: [PATCH] Moves all integration tests to an integration folder and provides a new tox env to run only those tests Signed-off-by: Andrew Schoen --- .coveragerc | 2 +- pytest.ini | 2 +- .../orchestra/test/integration/__init__.py | 0 .../{ => integration}/test_integration.py | 6 +- teuthology/test/integration/__init__.py | 0 teuthology/test/integration/test_suite.py | 86 +++++++++++++++++++ teuthology/test/test_suite.py | 84 ------------------ tox.ini | 16 +++- 8 files changed, 106 insertions(+), 90 deletions(-) create mode 100644 teuthology/orchestra/test/integration/__init__.py rename teuthology/orchestra/test/{ => integration}/test_integration.py (93%) create mode 100644 teuthology/test/integration/__init__.py create mode 100644 teuthology/test/integration/test_suite.py diff --git a/.coveragerc b/.coveragerc index 9f08918b0..560e80017 100644 --- a/.coveragerc +++ b/.coveragerc @@ -1,2 +1,2 @@ [run] -omit = teuthology/test/* +omit = */test/* diff --git a/pytest.ini b/pytest.ini index 847360a69..b50b1e608 100644 --- a/pytest.ini +++ b/pytest.ini @@ -1,2 +1,2 @@ [pytest] -norecursedirs = .git build virtualenv teuthology.egg-info .tox +norecursedirs = .git build virtualenv teuthology.egg-info .tox */integration diff --git a/teuthology/orchestra/test/integration/__init__.py b/teuthology/orchestra/test/integration/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/teuthology/orchestra/test/test_integration.py b/teuthology/orchestra/test/integration/test_integration.py similarity index 93% rename from teuthology/orchestra/test/test_integration.py rename to teuthology/orchestra/test/integration/test_integration.py index 6d45b28bc..1fc34966c 100644 --- a/teuthology/orchestra/test/test_integration.py +++ b/teuthology/orchestra/test/integration/test_integration.py @@ -1,11 +1,11 @@ -from .. import monkey +from teuthology.orchestra import monkey monkey.patch_all() from cStringIO import StringIO import os -from .. import connection, remote, run -from .util import assert_raises +from teuthology.orchestra import connection, remote, run +from teuthology.orchestra.test.util import assert_raises from teuthology.exceptions import CommandCrashedError, ConnectionLostError from pytest import skip diff --git a/teuthology/test/integration/__init__.py b/teuthology/test/integration/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/teuthology/test/integration/test_suite.py b/teuthology/test/integration/test_suite.py new file mode 100644 index 000000000..012dbc5f3 --- /dev/null +++ b/teuthology/test/integration/test_suite.py @@ -0,0 +1,86 @@ +import os +import requests +from pytest import raises, skip + +from teuthology.config import config +from teuthology import suite + + +class TestSuiteOnline(object): + def setup(self): + if 'TEST_ONLINE' not in os.environ: + skip("To run these sets, set the environment variable TEST_ONLINE") + + def test_ceph_hash_simple(self): + resp = requests.get( + 'https://api.github.com/repos/ceph/ceph/git/refs/heads/master') + ref_hash = resp.json()['object']['sha'] + assert suite.get_hash('ceph') == ref_hash + + def test_kernel_hash_saya(self): + # We don't currently have these packages. + assert suite.get_hash('kernel', 'master', 'basic', 'saya') is None + + def test_all_master_branches(self): + # Don't attempt to send email + config.results_email = None + job_config = suite.create_initial_config('suite', 'master', + 'master', 'master', 'testing', + 'basic', 'centos', 'plana') + assert ((job_config.branch, job_config.teuthology_branch, + job_config.suite_branch) == ('master', 'master', 'master')) + + def test_config_bogus_kernel_branch(self): + # Don't attempt to send email + config.results_email = None + with raises(suite.ScheduleFailError): + suite.create_initial_config('s', None, 'master', 't', + 'bogus_kernel_branch', 'f', 'd', 'm') + + def test_config_bogus_kernel_flavor(self): + # Don't attempt to send email + config.results_email = None + with raises(suite.ScheduleFailError): + suite.create_initial_config('s', None, 'master', 't', 'k', + 'bogus_kernel_flavor', 'd', 'm') + + def test_config_bogus_ceph_branch(self): + # Don't attempt to send email + config.results_email = None + with raises(suite.ScheduleFailError): + suite.create_initial_config('s', None, 'bogus_ceph_branch', 't', + 'k', 'f', 'd', 'm') + + def test_config_bogus_suite_branch(self): + # Don't attempt to send email + config.results_email = None + with raises(suite.ScheduleFailError): + suite.create_initial_config('s', 'bogus_suite_branch', 'master', + 't', 'k', 'f', 'd', 'm') + + def test_config_bogus_teuthology_branch(self): + # Don't attempt to send email + config.results_email = None + with raises(suite.ScheduleFailError): + suite.create_initial_config('s', None, 'master', + 'bogus_teuth_branch', 'k', 'f', 'd', + 'm') + + def test_config_substitution(self): + # Don't attempt to send email + config.results_email = None + job_config = suite.create_initial_config('MY_SUITE', 'master', + 'master', 'master', 'testing', + 'basic', 'centos', 'plana') + assert job_config['suite'] == 'MY_SUITE' + + def test_config_kernel_section(self): + # Don't attempt to send email + config.results_email = None + job_config = suite.create_initial_config('MY_SUITE', 'master', + 'master', 'master', 'testing', + 'basic', 'centos', 'plana') + assert job_config['kernel']['kdb'] is True + + +# maybe use notario for the above? diff --git a/teuthology/test/test_suite.py b/teuthology/test/test_suite.py index f30f1eea8..f7306d058 100644 --- a/teuthology/test/test_suite.py +++ b/teuthology/test/test_suite.py @@ -1,9 +1,5 @@ -import os -import requests from datetime import datetime -from pytest import raises, skip -from teuthology.config import config from teuthology import suite @@ -56,83 +52,3 @@ class TestSuiteOffline(object): assert isinstance( suite.dict_templ['overrides']['admin_socket']['branch'], suite.Placeholder) - - -class TestSuiteOnline(object): - def setup(self): - if 'TEST_ONLINE' not in os.environ: - skip("To run these sets, set the environment variable TEST_ONLINE") - - def test_ceph_hash_simple(self): - resp = requests.get( - 'https://api.github.com/repos/ceph/ceph/git/refs/heads/master') - ref_hash = resp.json()['object']['sha'] - assert suite.get_hash('ceph') == ref_hash - - def test_kernel_hash_saya(self): - # We don't currently have these packages. - assert suite.get_hash('kernel', 'master', 'basic', 'saya') is None - - def test_all_master_branches(self): - # Don't attempt to send email - config.results_email = None - job_config = suite.create_initial_config('suite', 'master', - 'master', 'master', 'testing', - 'basic', 'centos', 'plana') - assert ((job_config.branch, job_config.teuthology_branch, - job_config.suite_branch) == ('master', 'master', 'master')) - - def test_config_bogus_kernel_branch(self): - # Don't attempt to send email - config.results_email = None - with raises(suite.ScheduleFailError): - suite.create_initial_config('s', None, 'master', 't', - 'bogus_kernel_branch', 'f', 'd', 'm') - - def test_config_bogus_kernel_flavor(self): - # Don't attempt to send email - config.results_email = None - with raises(suite.ScheduleFailError): - suite.create_initial_config('s', None, 'master', 't', 'k', - 'bogus_kernel_flavor', 'd', 'm') - - def test_config_bogus_ceph_branch(self): - # Don't attempt to send email - config.results_email = None - with raises(suite.ScheduleFailError): - suite.create_initial_config('s', None, 'bogus_ceph_branch', 't', - 'k', 'f', 'd', 'm') - - def test_config_bogus_suite_branch(self): - # Don't attempt to send email - config.results_email = None - with raises(suite.ScheduleFailError): - suite.create_initial_config('s', 'bogus_suite_branch', 'master', - 't', 'k', 'f', 'd', 'm') - - def test_config_bogus_teuthology_branch(self): - # Don't attempt to send email - config.results_email = None - with raises(suite.ScheduleFailError): - suite.create_initial_config('s', None, 'master', - 'bogus_teuth_branch', 'k', 'f', 'd', - 'm') - - def test_config_substitution(self): - # Don't attempt to send email - config.results_email = None - job_config = suite.create_initial_config('MY_SUITE', 'master', - 'master', 'master', 'testing', - 'basic', 'centos', 'plana') - assert job_config['suite'] == 'MY_SUITE' - - def test_config_kernel_section(self): - # Don't attempt to send email - config.results_email = None - job_config = suite.create_initial_config('MY_SUITE', 'master', - 'master', 'master', 'testing', - 'basic', 'centos', 'plana') - assert job_config['kernel']['kdb'] is True - - -# maybe use notario for the above? diff --git a/tox.ini b/tox.ini index dbe5b894f..1ce78de42 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist = py27, flake8 +envlist = py27, py27-integration, flake8 [testenv:py27] sitepackages=True @@ -14,6 +14,20 @@ deps= commands=py.test --cov=teuthology --cov-report=term -v {posargs:teuthology scripts} +[testenv:py27-integration] +sitepackages=True +deps= + -r{toxinidir}/requirements.txt + pytest + mock + fudge + nose + pytest-cov==1.6 + coverage==3.7.1 + +commands=py.test --cov=teuthology --cov-report=term -v {posargs:teuthology/test/integration teuthology/orchestra/test/integration} +basepython=python2.7 + [testenv:flake8] deps= flake8 -- 2.47.3