From a0d25434dfe587add75f8c74b0317c0d8f975888 Mon Sep 17 00:00:00 2001 From: Akita Noek Date: Wed, 20 Apr 2016 10:49:40 -0400 Subject: [PATCH 1/5] Skip old splunk test This should be removed by #1613 --- awx/main/tests/old/commands/commands_monolithic.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/awx/main/tests/old/commands/commands_monolithic.py b/awx/main/tests/old/commands/commands_monolithic.py index c7a030b8a4..8bf81fc68a 100644 --- a/awx/main/tests/old/commands/commands_monolithic.py +++ b/awx/main/tests/old/commands/commands_monolithic.py @@ -935,6 +935,11 @@ class InventoryImportTest(BaseCommandMixin, BaseLiveServerTest): self.assertNotEqual(new_inv.total_groups, 0) self.assertElapsedLessThan(60) + @unittest.skipIf(True, + 'This test is deprecated and being removed from ' + 'integration and unit tests in favor of writing ' + 'an explicit unit test around what the original ' + 'problem was') def test_splunk_inventory(self): new_inv = self.organizations[0].inventories.create(name='splunk') self.assertEqual(new_inv.hosts.count(), 0) From 568f0e43a55e9c9383d22faa8707a5b8e81f2885 Mon Sep 17 00:00:00 2001 From: Akita Noek Date: Wed, 20 Apr 2016 11:27:17 -0400 Subject: [PATCH 2/5] Skip old slow tests for normal unit test runs, pick them up in nightly runs --- awx/main/tests/old/ad_hoc.py | 2 ++ awx/main/tests/old/commands/commands_monolithic.py | 3 +++ awx/main/tests/old/inventory.py | 4 ++++ awx/main/tests/old/jobs/job_launch.py | 4 ++++ awx/main/tests/old/jobs/jobs_monolithic.py | 8 ++++++++ awx/main/tests/old/jobs/start_cancel.py | 3 +++ awx/main/tests/old/tasks.py | 8 ++++---- 7 files changed, 28 insertions(+), 4 deletions(-) diff --git a/awx/main/tests/old/ad_hoc.py b/awx/main/tests/old/ad_hoc.py index 279b98f3ae..f47ee89877 100644 --- a/awx/main/tests/old/ad_hoc.py +++ b/awx/main/tests/old/ad_hoc.py @@ -58,6 +58,7 @@ class BaseAdHocCommandTest(BaseJobExecutionTest): return self.credential +@unittest.skipIf(os.environ.get('SKIP_SLOW_TESTS', False), 'Skipping slow test') class RunAdHocCommandTest(BaseAdHocCommandTest): ''' Test cases for RunAdHocCommand celery task. @@ -375,6 +376,7 @@ class RunAdHocCommandTest(BaseAdHocCommandTest): def run_pexpect_mock(self, *args, **kwargs): return 'successful', 0 +@unittest.skipIf(os.environ.get('SKIP_SLOW_TESTS', False), 'Skipping slow test') class AdHocCommandApiTest(BaseAdHocCommandTest): ''' Test API list/detail views for ad hoc commands. diff --git a/awx/main/tests/old/commands/commands_monolithic.py b/awx/main/tests/old/commands/commands_monolithic.py index 8bf81fc68a..79b6a630f8 100644 --- a/awx/main/tests/old/commands/commands_monolithic.py +++ b/awx/main/tests/old/commands/commands_monolithic.py @@ -108,6 +108,7 @@ grandchild parent ''' + class BaseCommandMixin(object): ''' Base class for tests that run management commands. @@ -381,6 +382,7 @@ class CleanupJobsTest(BaseCommandMixin, BaseLiveServerTest): self.assertFalse(ad_hoc_commands_after) +@unittest.skipIf(os.environ.get('SKIP_SLOW_TESTS', False), 'Skipping slow test') class CleanupActivityStreamTest(BaseCommandMixin, BaseTest): ''' Test cases for cleanup_activitystream management command. @@ -447,6 +449,7 @@ class CleanupActivityStreamTest(BaseCommandMixin, BaseTest): 'create took %0.3fs, cleanup took %0.3fs, expected < %0.3fs' % (create_elapsed, cleanup_elapsed, create_elapsed / 4)) +@unittest.skipIf(os.environ.get('SKIP_SLOW_TESTS', False), 'Skipping slow test') class InventoryImportTest(BaseCommandMixin, BaseLiveServerTest): ''' Test cases for inventory_import management command. diff --git a/awx/main/tests/old/inventory.py b/awx/main/tests/old/inventory.py index 150eb45a31..ac9ab875b4 100644 --- a/awx/main/tests/old/inventory.py +++ b/awx/main/tests/old/inventory.py @@ -8,6 +8,8 @@ import os import re import tempfile import time +import unittest2 as unittest + # Django from django.conf import settings @@ -37,6 +39,7 @@ inventory['group-\u037c\u03b4\u0138\u0137\u03cd\u03a1\u0121\u0137\u0138\u01a1']. print json.dumps(inventory) """ +@unittest.skipIf(os.environ.get('SKIP_SLOW_TESTS', False), 'Skipping slow test') class InventoryTest(BaseTest): def setUp(self): @@ -1097,6 +1100,7 @@ class InventoryTest(BaseTest): self.assertEqual(response['hosts']['failed'], 8) +@unittest.skipIf(os.environ.get('SKIP_SLOW_TESTS', False), 'Skipping slow test') @override_settings(CELERY_ALWAYS_EAGER=True, CELERY_EAGER_PROPAGATES_EXCEPTIONS=True, IGNORE_CELERY_INSPECTOR=True, diff --git a/awx/main/tests/old/jobs/job_launch.py b/awx/main/tests/old/jobs/job_launch.py index f1f9f607eb..dabf3568bc 100644 --- a/awx/main/tests/old/jobs/job_launch.py +++ b/awx/main/tests/old/jobs/job_launch.py @@ -3,6 +3,8 @@ # Python from __future__ import absolute_import +import os +import unittest2 as unittest # Django import django @@ -15,6 +17,7 @@ import yaml __all__ = ['JobTemplateLaunchTest', 'JobTemplateLaunchPasswordsTest'] +@unittest.skipIf(os.environ.get('SKIP_SLOW_TESTS', False), 'Skipping slow test') class JobTemplateLaunchTest(BaseJobTestMixin, django.test.TransactionTestCase): def setUp(self): super(JobTemplateLaunchTest, self).setUp() @@ -183,6 +186,7 @@ class JobTemplateLaunchTest(BaseJobTestMixin, django.test.TransactionTestCase): with self.current_user(self.user_sue): self.post(self.launch_url, {}, expect=400) +@unittest.skipIf(os.environ.get('SKIP_SLOW_TESTS', False), 'Skipping slow test') class JobTemplateLaunchPasswordsTest(BaseJobTestMixin, django.test.TransactionTestCase): def setUp(self): super(JobTemplateLaunchPasswordsTest, self).setUp() diff --git a/awx/main/tests/old/jobs/jobs_monolithic.py b/awx/main/tests/old/jobs/jobs_monolithic.py index fa4123ad05..aae061ff15 100644 --- a/awx/main/tests/old/jobs/jobs_monolithic.py +++ b/awx/main/tests/old/jobs/jobs_monolithic.py @@ -9,6 +9,9 @@ import struct import threading import time import urlparse +import os +import unittest2 as unittest + # Django import django.test @@ -183,6 +186,7 @@ TEST_SURVEY_REQUIREMENTS = ''' } ''' +@unittest.skipIf(os.environ.get('SKIP_SLOW_TESTS', False), 'Skipping slow test') class JobTemplateTest(BaseJobTestMixin, django.test.TransactionTestCase): JOB_TEMPLATE_FIELDS = ('id', 'type', 'url', 'related', 'summary_fields', @@ -501,6 +505,7 @@ class JobTemplateTest(BaseJobTestMixin, django.test.TransactionTestCase): with self.current_user(self.user_doug): self.get(detail_url, expect=403) +@unittest.skipIf(os.environ.get('SKIP_SLOW_TESTS', False), 'Skipping slow test') class JobTest(BaseJobTestMixin, django.test.TransactionTestCase): def test_get_job_list(self): @@ -653,6 +658,7 @@ class JobTest(BaseJobTestMixin, django.test.TransactionTestCase): # and that jobs come back nicely serialized with related resources and so on ... # that we can drill all the way down and can get at host failure lists, etc ... +@unittest.skipIf(os.environ.get('SKIP_SLOW_TESTS', False), 'Skipping slow test') @override_settings(CELERY_ALWAYS_EAGER=True, CELERY_EAGER_PROPAGATES_EXCEPTIONS=True, ANSIBLE_TRANSPORT='local') @@ -1028,6 +1034,7 @@ class JobTemplateCallbackTest(BaseJobTestMixin, django.test.LiveServerTestCase): self.post(url, data, expect=400, remote_addr=host_ip) +@unittest.skipIf(os.environ.get('SKIP_SLOW_TESTS', False), 'Skipping slow test') @override_settings(CELERY_ALWAYS_EAGER=True, CELERY_EAGER_PROPAGATES_EXCEPTIONS=True, ANSIBLE_TRANSPORT='local') @@ -1092,6 +1099,7 @@ class JobTransactionTest(BaseJobTestMixin, django.test.LiveServerTestCase): self.assertEqual(job.status, 'successful', job.result_stdout) self.assertFalse(errors) +@unittest.skipIf(os.environ.get('SKIP_SLOW_TESTS', False), 'Skipping slow test') class JobTemplateSurveyTest(BaseJobTestMixin, django.test.TransactionTestCase): def setUp(self): super(JobTemplateSurveyTest, self).setUp() diff --git a/awx/main/tests/old/jobs/start_cancel.py b/awx/main/tests/old/jobs/start_cancel.py index e57c70ef15..3a6957af69 100644 --- a/awx/main/tests/old/jobs/start_cancel.py +++ b/awx/main/tests/old/jobs/start_cancel.py @@ -3,6 +3,8 @@ # Python from __future__ import absolute_import +import os +import unittest2 as unittest # Django from django.core.urlresolvers import reverse @@ -15,6 +17,7 @@ from awx.main.tests.job_base import BaseJobTestMixin __all__ = ['JobStartCancelTest',] +@unittest.skipIf(os.environ.get('SKIP_SLOW_TESTS', False), 'Skipping slow test') class JobStartCancelTest(BaseJobTestMixin, BaseLiveServerTest): def test_job_start(self): diff --git a/awx/main/tests/old/tasks.py b/awx/main/tests/old/tasks.py index 28e586376a..05a39fb75b 100644 --- a/awx/main/tests/old/tasks.py +++ b/awx/main/tests/old/tasks.py @@ -237,6 +237,7 @@ TEST_VAULT_PLAYBOOK = '''$ANSIBLE_VAULT;1.1;AES256 TEST_VAULT_PASSWORD = '1234' +@unittest.skipIf(os.environ.get('SKIP_SLOW_TESTS', False), 'Skipping slow test') class RunJobTest(BaseJobExecutionTest): ''' Test cases for RunJob celery task. @@ -337,10 +338,9 @@ class RunJobTest(BaseJobExecutionTest): print qs = self.super_django_user.get_queryset(JobEvent) for je in qs.filter(job=job): - print je.get_event_display2() - print je.event, je, je.failed - print je.event_data - print + print(je.get_event_display2()) + print(je.event, je, je.failed) + print(je.event_data) for job_event in job_events: unicode(job_event) # For test coverage. job_event.save() From 22f18715f7ef5cd32d49b32b1dc159e951439e96 Mon Sep 17 00:00:00 2001 From: Akita Noek Date: Wed, 20 Apr 2016 11:29:01 -0400 Subject: [PATCH 3/5] Removed dup tests, moved old api tests into main/tests/old/api --- awx/api/tests/__init__.py | 7 ------- .../tests => main/tests/old/api}/decorator_paginated.py | 0 awx/{api/tests => main/tests/old/api}/job_tasks.py | 0 3 files changed, 7 deletions(-) delete mode 100644 awx/api/tests/__init__.py rename awx/{api/tests => main/tests/old/api}/decorator_paginated.py (100%) rename awx/{api/tests => main/tests/old/api}/job_tasks.py (100%) diff --git a/awx/api/tests/__init__.py b/awx/api/tests/__init__.py deleted file mode 100644 index 3ed2a22d7d..0000000000 --- a/awx/api/tests/__init__.py +++ /dev/null @@ -1,7 +0,0 @@ -# Copyright (c) 2015 Ansible, Inc. -# All Rights Reserved. - -from __future__ import absolute_import - -from .decorator_paginated import PaginatedDecoratorTests # noqa -from .job_tasks import JobTasksTests # noqa diff --git a/awx/api/tests/decorator_paginated.py b/awx/main/tests/old/api/decorator_paginated.py similarity index 100% rename from awx/api/tests/decorator_paginated.py rename to awx/main/tests/old/api/decorator_paginated.py diff --git a/awx/api/tests/job_tasks.py b/awx/main/tests/old/api/job_tasks.py similarity index 100% rename from awx/api/tests/job_tasks.py rename to awx/main/tests/old/api/job_tasks.py From 31920c6700a8b2f22c55d435d666eed7f8b065d8 Mon Sep 17 00:00:00 2001 From: Akita Noek Date: Wed, 20 Apr 2016 11:48:09 -0400 Subject: [PATCH 4/5] Removed awx/api/tests dir from Makefile since it no longer exists --- Makefile | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index ea7513837d..c215a31224 100644 --- a/Makefile +++ b/Makefile @@ -427,16 +427,17 @@ pylint: reports check: flake8 pep8 # pyflakes pylint +TEST_DIRS=awx/main/tests # Run all API unit tests. test: - py.test awx/main/tests awx/api/tests + py.test $(TEST_DIRS) test_unit: py.test awx/main/tests/unit # Run all API unit tests with coverage enabled. test_coverage: - py.test --create-db --cov=awx --cov-report=xml --junitxml=./reports/junit.xml awx/main/tests awx/api/tests + py.test --create-db --cov=awx --cov-report=xml --junitxml=./reports/junit.xml $(TEST_DIRS) # Output test coverage as HTML (into htmlcov directory). coverage_html: From 659d43136f004eb2c86c32a7b6facb04262471d7 Mon Sep 17 00:00:00 2001 From: Akita Noek Date: Wed, 20 Apr 2016 11:50:20 -0400 Subject: [PATCH 5/5] Added missing import --- awx/main/tests/old/ad_hoc.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/awx/main/tests/old/ad_hoc.py b/awx/main/tests/old/ad_hoc.py index f47ee89877..8052350517 100644 --- a/awx/main/tests/old/ad_hoc.py +++ b/awx/main/tests/old/ad_hoc.py @@ -7,6 +7,8 @@ import os import subprocess import tempfile import mock +import unittest2 as unittest + # Django from django.conf import settings