diff options
-rw-r--r-- | buildscripts/idl/__init__.py | 0 | ||||
-rw-r--r-- | buildscripts/resmokeconfig/suites/buildscripts_test.yml | 16 | ||||
-rw-r--r-- | buildscripts/resmokelib/selector.py | 9 | ||||
-rw-r--r-- | buildscripts/resmokelib/testing/testcases/pytest.py | 32 | ||||
-rw-r--r-- | buildscripts/tests/ciconfig/test_evergreen.py | 4 | ||||
-rw-r--r-- | buildscripts/tests/resmokelib/logging/__init__.py | 0 | ||||
-rw-r--r-- | buildscripts/tests/resmokelib/test_archival.py | 5 | ||||
-rw-r--r-- | buildscripts/tests/resmokelib/test_selector.py | 7 | ||||
-rw-r--r-- | buildscripts/tests/resmokelib/testing/fixtures/__init__.py | 0 | ||||
-rwxr-xr-x | buildscripts/tests/resmokelib/testing/hooks/test_combine_benchmark_results.py | 4 | ||||
-rwxr-xr-x | buildscripts/tests/test_aws_ec2.py | 5 | ||||
-rwxr-xr-x | buildscripts/tests/test_remote_operations.py | 4 | ||||
-rw-r--r-- | etc/evergreen.yml | 12 |
13 files changed, 71 insertions, 27 deletions
diff --git a/buildscripts/idl/__init__.py b/buildscripts/idl/__init__.py new file mode 100644 index 00000000000..e69de29bb2d --- /dev/null +++ b/buildscripts/idl/__init__.py diff --git a/buildscripts/resmokeconfig/suites/buildscripts_test.yml b/buildscripts/resmokeconfig/suites/buildscripts_test.yml new file mode 100644 index 00000000000..c73fe49db66 --- /dev/null +++ b/buildscripts/resmokeconfig/suites/buildscripts_test.yml @@ -0,0 +1,16 @@ +test_kind: py_test + +selector: + roots: + - buildscripts/tests/**/test_*.py + - buildscripts/idl/tests/**/test_*.py + exclude_files: + - buildscripts/tests/resmokelib/test_archival.py # Requires boto3. + - buildscripts/tests/resmokelib/test_selector.py # Test assumes POSIX path. + - buildscripts/tests/resmokelib/testing/hooks/test_combine_benchmark_results.py # Requires mock. + - buildscripts/tests/test_aws_ec2.py # Requires boto3. + - buildscripts/tests/test_remote_operations.py # Requires ssh to be enabled locally. + - buildscripts/tests/test_update_test_lifecycle.py # Test assumes POSIX path. + + +executor: {} diff --git a/buildscripts/resmokelib/selector.py b/buildscripts/resmokelib/selector.py index 4fe1450d945..d83cddd9142 100644 --- a/buildscripts/resmokelib/selector.py +++ b/buildscripts/resmokelib/selector.py @@ -568,6 +568,14 @@ class _SleepTestCaseSelector(_Selector): _Selector.__init__(self, test_file_explorer, tests_are_files=False) +class _PyTestCaseSelectorConfig(_SelectorConfig): + """_SelectorConfig subclass for py_test tests.""" + + def __init__(self, roots, include_files=None, exclude_files=None): + _SelectorConfig.__init__(self, roots=roots, include_files=include_files, + exclude_files=exclude_files) + + ########################################## # Module entry point for filtering tests # ########################################## @@ -582,6 +590,7 @@ _SELECTOR_REGISTRY = { "fsm_workload_test": (_JSTestSelectorConfig, _JSTestSelector), "json_schema_test": (_JsonSchemaTestSelectorConfig, _Selector), "js_test": (_JSTestSelectorConfig, _JSTestSelector), + "py_test": (_PyTestCaseSelectorConfig, _Selector), "sleep_test": (_SleepTestCaseSelectorConfig, _SleepTestCaseSelector), } diff --git a/buildscripts/resmokelib/testing/testcases/pytest.py b/buildscripts/resmokelib/testing/testcases/pytest.py new file mode 100644 index 00000000000..6c1c343f197 --- /dev/null +++ b/buildscripts/resmokelib/testing/testcases/pytest.py @@ -0,0 +1,32 @@ +""" +unittest.TestCase for Python unittests. +""" +import os +import unittest + +from buildscripts.resmokelib.testing.testcases import interface + + +class PyTestCase(interface.TestCase): + + REGISTERED_NAME = "py_test" + + def __init__(self, logger, py_filename): + interface.TestCase.__init__(self, logger, "PyTest", py_filename) + + def run_test(self): + suite = unittest.defaultTestLoader.loadTestsFromName(self.test_module_name) + result = unittest.TextTestRunner().run(suite) + if result.failures: + msg = "Python test {} failed".format(self.test_name) + raise self.failureException(msg) + + self.return_code = 0 + + def as_command(self): + return "python -m unittest {}".format(self.test_module_name) + + @property + def test_module_name(self): + """Get the dotted module name from the path.""" + return os.path.splitext(self.test_name)[0].replace(os.sep, ".") diff --git a/buildscripts/tests/ciconfig/test_evergreen.py b/buildscripts/tests/ciconfig/test_evergreen.py index fe31eb3dbab..9409389f0a1 100644 --- a/buildscripts/tests/ciconfig/test_evergreen.py +++ b/buildscripts/tests/ciconfig/test_evergreen.py @@ -192,7 +192,3 @@ class TestVariant(unittest.TestCase): resmoke_task = variant_debian.get_task("resmoke_task") self.assertEqual("--suites=somesuite --storageEngine=mmapv1", resmoke_task.combined_resmoke_args) - - -if __name__ == "__main__": - unittest.main() diff --git a/buildscripts/tests/resmokelib/logging/__init__.py b/buildscripts/tests/resmokelib/logging/__init__.py new file mode 100644 index 00000000000..e69de29bb2d --- /dev/null +++ b/buildscripts/tests/resmokelib/logging/__init__.py diff --git a/buildscripts/tests/resmokelib/test_archival.py b/buildscripts/tests/resmokelib/test_archival.py index a21621060d9..e0a05d51b45 100644 --- a/buildscripts/tests/resmokelib/test_archival.py +++ b/buildscripts/tests/resmokelib/test_archival.py @@ -1,4 +1,3 @@ -#!/usr/bin/env python """ Unit tests for archival. """ from __future__ import absolute_import @@ -241,7 +240,3 @@ class ArchivalLimitTests(ArchivalTestCase): status, message = self.archive.archive_files_to_s3(display_name, temp_file, self.bucket, s3_path) self.assertEqual(1, status, message) - - -if __name__ == "__main__": - unittest.main() diff --git a/buildscripts/tests/resmokelib/test_selector.py b/buildscripts/tests/resmokelib/test_selector.py index 197678041d3..809bce67e70 100644 --- a/buildscripts/tests/resmokelib/test_selector.py +++ b/buildscripts/tests/resmokelib/test_selector.py @@ -109,7 +109,8 @@ class MockTestFileExplorer(object): def __init__(self): self.files = [ "dir/subdir1/test11.js", "dir/subdir1/test12.js", "dir/subdir2/test21.js", - "dir/subdir3/a/test3a1.js", "build/testA", "build/testB", "build/testC", "dbtest" + "dir/subdir3/a/test3a1.js", "build/testA", "build/testB", "build/testC", "dbtest", + "dbtest.exe" ] self.tags = { "dir/subdir1/test11.js": ["tag1", "tag2"], "dir/subdir1/test12.js": ["tag3"], @@ -523,7 +524,3 @@ class TestFilterTests(unittest.TestCase): selected, excluded = selector.filter_tests("db_test", config, self.test_file_explorer) self.assertEqual(["dbtestB"], selected) self.assertEqual(["dbtestA", "dbtestC"], excluded) - - -if __name__ == "__main__": - unittest.main() diff --git a/buildscripts/tests/resmokelib/testing/fixtures/__init__.py b/buildscripts/tests/resmokelib/testing/fixtures/__init__.py new file mode 100644 index 00000000000..e69de29bb2d --- /dev/null +++ b/buildscripts/tests/resmokelib/testing/fixtures/__init__.py diff --git a/buildscripts/tests/resmokelib/testing/hooks/test_combine_benchmark_results.py b/buildscripts/tests/resmokelib/testing/hooks/test_combine_benchmark_results.py index 34f3eded3b9..d67e96a99b8 100755 --- a/buildscripts/tests/resmokelib/testing/hooks/test_combine_benchmark_results.py +++ b/buildscripts/tests/resmokelib/testing/hooks/test_combine_benchmark_results.py @@ -151,7 +151,3 @@ class TestBenchmarkThreadsReport(CombineBenchmarkResultsFixture): self.assertEqual(len(report.keys()), 1) self.assertIn("1", report.keys()) self.assertNotIn("1_mean", report.keys()) - - -if __name__ == "__main__": - unittest.main() diff --git a/buildscripts/tests/test_aws_ec2.py b/buildscripts/tests/test_aws_ec2.py index 3886e5a5b68..c289a662821 100755 --- a/buildscripts/tests/test_aws_ec2.py +++ b/buildscripts/tests/test_aws_ec2.py @@ -1,4 +1,3 @@ -#!/usr/bin/env python """Unit test for buildscripts/aws_ec2.py.""" from __future__ import absolute_import @@ -213,7 +212,3 @@ class AwsEc2TagInstance(AwsEc2TestCase): self.assertTrue(tag in self.tags, ret) for tag in self.tags: self.assertTrue(tag in ret.tags, ret) - - -if __name__ == "__main__": - unittest.main() diff --git a/buildscripts/tests/test_remote_operations.py b/buildscripts/tests/test_remote_operations.py index 0218cb28ece..955969c3c69 100755 --- a/buildscripts/tests/test_remote_operations.py +++ b/buildscripts/tests/test_remote_operations.py @@ -444,7 +444,3 @@ class RemoteOperation(RemoteOperationsTestCase): # Invalid operation self.assertRaises(ValueError, lambda: self.rop.operation("invalid", None)) - - -if __name__ == "__main__": - unittest.main() diff --git a/etc/evergreen.yml b/etc/evergreen.yml index 66f00eec5ab..fb8002171fa 100644 --- a/etc/evergreen.yml +++ b/etc/evergreen.yml @@ -4524,6 +4524,16 @@ tasks: - func: "do setup" - func: "run idl tests" +- name: buildscripts_test + depends_on: [] + commands: + - func: "git get project" + - func: "get buildnumber" + - func: "set up credentials" + - func: "run tests" + vars: + resmoke_args: --suites=buildscripts_test + - name: package depends_on: - name: compile @@ -6408,6 +6418,7 @@ buildvariants: - name: auth_audit - name: benchmarks_orphaned - name: benchmarks_sharding + - name: buildscripts_test - name: dbtest - name: ese - name: external_auth @@ -7215,6 +7226,7 @@ buildvariants: - name: benchmarks_sharding distros: - centos6-perf + - name: buildscripts_test - name: bulk_gle_passthrough - name: causally_consistent_jscore_passthrough - name: causally_consistent_jscore_passthrough_auth |