diff options
author | Mikhail Shchatko <mikhail.shchatko@mongodb.com> | 2021-07-28 13:29:29 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2021-07-30 16:54:57 +0000 |
commit | a2cc442afcb92398d4babf6b69110625956483dd (patch) | |
tree | 0d5aa15f62c1c73d3f29aa04bd8e1cf81b4efae3 /buildscripts/tests | |
parent | 432d231645aa6496a291996a1385409b08bcd7dc (diff) | |
download | mongo-a2cc442afcb92398d4babf6b69110625956483dd.tar.gz |
SERVER-54419 Support last-lts and last-continuous in generating multiversion_exclude_tags.yml file
Diffstat (limited to 'buildscripts/tests')
-rw-r--r-- | buildscripts/tests/resmokelib/run/test_generate_multiversion_exclude_tags.py (renamed from buildscripts/tests/test_evergreen_gen_multiversion_tests.py) | 121 | ||||
-rw-r--r-- | buildscripts/tests/test_burn_in_tests_multiversion.py | 8 |
2 files changed, 91 insertions, 38 deletions
diff --git a/buildscripts/tests/test_evergreen_gen_multiversion_tests.py b/buildscripts/tests/resmokelib/run/test_generate_multiversion_exclude_tags.py index 488cc2b1d9a..decc81f4433 100644 --- a/buildscripts/tests/test_evergreen_gen_multiversion_tests.py +++ b/buildscripts/tests/resmokelib/run/test_generate_multiversion_exclude_tags.py @@ -1,19 +1,18 @@ -''' Tests for the multiversion generators ''' - +"""Unit tests for buildscripts/resmokelib/run/generate_multiversion_exclude_tags.py.""" +# pylint: disable=missing-docstring import os import unittest from tempfile import TemporaryDirectory -from mock import patch, MagicMock -from click.testing import CliRunner +from mock import MagicMock, patch -from buildscripts import evergreen_gen_multiversion_tests as under_test +from buildscripts.resmokelib.config import MultiversionOptions +from buildscripts.resmokelib.run import generate_multiversion_exclude_tags as under_test from buildscripts.util.fileops import read_yaml_file -# pylint: disable=missing-docstring, no-self-use +EXCLUDE_TAGS_FILE = "multiversion_exclude_tags.yml" -@unittest.skip("Skipping until both last-lts and last-continuous are supported") class TestGenerateExcludeYaml(unittest.TestCase): def setUp(self): self._tmpdir = TemporaryDirectory() @@ -23,32 +22,32 @@ class TestGenerateExcludeYaml(unittest.TestCase): self._tmpdir.cleanup() def assert_contents(self, expected): - actual = read_yaml_file(os.path.join(self._tmpdir.name, under_test.EXCLUDE_TAGS_FILE)) + actual = read_yaml_file(os.path.join(self._tmpdir.name, EXCLUDE_TAGS_FILE)) self.assertEqual(actual, expected) - def patch_and_run(self, latest, last_lts): + def patch_and_run(self, latest, old, old_bin_version): """ Helper to patch and run the test. """ mock_multiversion_methods = { 'get_backports_required_hash_for_shell_version': MagicMock(), - 'get_old_yaml': MagicMock(return_value=last_lts) + 'get_old_yaml': MagicMock(return_value=old) } - with patch.multiple('buildscripts.evergreen_gen_multiversion_tests', + with patch.multiple('buildscripts.resmokelib.run.generate_multiversion_exclude_tags', **mock_multiversion_methods): - with patch('buildscripts.evergreen_gen_multiversion_tests.read_yaml_file', - return_value=latest) as mock_read_yaml: + with patch( + 'buildscripts.resmokelib.run.generate_multiversion_exclude_tags.read_yaml_file', + return_value=latest) as mock_read_yaml: - output = os.path.join(self._tmpdir.name, under_test.EXCLUDE_TAGS_FILE) - runner = CliRunner() - result = runner.invoke(under_test.generate_exclude_yaml, [f"--output={output}"]) + output = os.path.join(self._tmpdir.name, EXCLUDE_TAGS_FILE) + under_test.generate_exclude_yaml(old_bin_version=old_bin_version, output=output, + logger=MagicMock()) - self.assertEqual(result.exit_code, 0, result) mock_read_yaml.assert_called_once() mock_multiversion_methods[ 'get_backports_required_hash_for_shell_version'].assert_called_once() - mock_multiversion_methods['get_last_lts_yaml'].assert_called_once() + mock_multiversion_methods['get_old_yaml'].assert_called_once() def test_create_yaml_suite1(self): latest_yaml = { @@ -61,7 +60,7 @@ class TestGenerateExcludeYaml(unittest.TestCase): } } - last_lts_yaml = { + old_yaml = { 'last-continuous': None, 'last-lts': { 'all': [{'ticket': 'fake_ticket0', 'test_file': 'jstests/fake_file0.js'}], 'suites': {'suite1': [{'ticket': 'fake_ticket2', 'test_file': 'jstests/fake_file2.js'}]} @@ -74,7 +73,7 @@ class TestGenerateExcludeYaml(unittest.TestCase): } } - self.patch_and_run(latest_yaml, last_lts_yaml) + self.patch_and_run(latest_yaml, old_yaml, MultiversionOptions.LAST_LTS) self.assert_contents(expected) def test_create_yaml_suite1_and_suite2(self): @@ -89,7 +88,7 @@ class TestGenerateExcludeYaml(unittest.TestCase): } } - last_lts_yaml = { + old_yaml = { 'last-continuous': None, 'last-lts': { 'all': [{'ticket': 'fake_ticket0', 'test_file': 'jstests/fake_file0.js'}], 'suites': {'suite1': [{'ticket': 'fake_ticket2', 'test_file': 'jstests/fake_file2.js'}]} @@ -107,7 +106,7 @@ class TestGenerateExcludeYaml(unittest.TestCase): } } - self.patch_and_run(latest_yaml, last_lts_yaml) + self.patch_and_run(latest_yaml, old_yaml, MultiversionOptions.LAST_LTS) self.assert_contents(expected) def test_both_all_are_none(self): @@ -120,7 +119,7 @@ class TestGenerateExcludeYaml(unittest.TestCase): } } - last_lts_yaml = { + old_yaml = { 'last-continuous': None, 'last-lts': { 'all': None, 'suites': { 'suite1': [{'ticket': 'fake_ticket2', 'test_file': 'jstests/fake_file2.js'}] @@ -134,7 +133,7 @@ class TestGenerateExcludeYaml(unittest.TestCase): } } - self.patch_and_run(latest_yaml, last_lts_yaml) + self.patch_and_run(latest_yaml, old_yaml, MultiversionOptions.LAST_LTS) self.assert_contents(expected) def test_old_all_is_none(self): @@ -148,7 +147,7 @@ class TestGenerateExcludeYaml(unittest.TestCase): } } - last_lts_yaml = { + old_yaml = { 'last-continuous': None, 'last-lts': { 'all': None, 'suites': { 'suite1': [{'ticket': 'fake_ticket2', 'test_file': 'jstests/fake_file2.js'}] @@ -165,7 +164,7 @@ class TestGenerateExcludeYaml(unittest.TestCase): } } - self.patch_and_run(latest_yaml, last_lts_yaml) + self.patch_and_run(latest_yaml, old_yaml, MultiversionOptions.LAST_LTS) self.assert_contents(expected) def test_create_yaml_suite1_and_all(self): @@ -180,7 +179,7 @@ class TestGenerateExcludeYaml(unittest.TestCase): } } - last_lts_yaml = { + old_yaml = { 'last-continuous': None, 'last-lts': { 'all': [{'ticket': 'fake_ticket0', 'test_file': 'jstests/fake_file0.js'}], 'suites': {'suite1': [{'ticket': 'fake_ticket2', 'test_file': 'jstests/fake_file2.js'}]} @@ -196,7 +195,65 @@ class TestGenerateExcludeYaml(unittest.TestCase): } } - self.patch_and_run(latest_yaml, last_lts_yaml) + self.patch_and_run(latest_yaml, old_yaml, MultiversionOptions.LAST_LTS) + self.assert_contents(expected) + + def test_last_continuous(self): + latest_yaml = { + 'last-continuous': { + 'all': [{'ticket': 'fake_ticket0', 'test_file': 'jstests/fake_file0.js'}], + 'suites': { + 'suite1': [{'ticket': 'fake_ticket1', 'test_file': 'jstests/fake_file1.js'}, + {'ticket': 'fake_ticket2', 'test_file': 'jstests/fake_file2.js'}] + } + }, 'last-lts': None + } + + old_yaml = { + 'last-continuous': { + 'all': [{'ticket': 'fake_ticket0', 'test_file': 'jstests/fake_file0.js'}], 'suites': + {'suite1': [{'ticket': 'fake_ticket2', 'test_file': 'jstests/fake_file2.js'}]} + }, 'last-lts': None + } + + expected = { + 'selector': { + 'js_test': {'jstests/fake_file1.js': ['suite1_backport_required_multiversion']} + } + } + + self.patch_and_run(latest_yaml, old_yaml, MultiversionOptions.LAST_CONTINUOUS) + self.assert_contents(expected) + + def test_old_last_continuous_is_empty(self): + latest_yaml = { + 'last-continuous': { + 'all': [{'ticket': 'fake_ticket0', 'test_file': 'jstests/fake_file0.js'}], + 'suites': { + 'suite1': [{'ticket': 'fake_ticket1', 'test_file': 'jstests/fake_file1.js'}, + {'ticket': 'fake_ticket2', 'test_file': 'jstests/fake_file2.js'}] + } + }, 'last-lts': None + } + + old_yaml = { + 'last-continuous': {'all': None, 'suites': {}}, 'last-lts': { + 'all': [{'ticket': 'fake_ticket0', 'test_file': 'jstests/fake_file0.js'}], 'suites': + {'suite1': [{'ticket': 'fake_ticket2', 'test_file': 'jstests/fake_file2.js'}]} + } + } + + expected = { + 'selector': { + 'js_test': { + 'jstests/fake_file0.js': ['backport_required_multiversion'], + 'jstests/fake_file1.js': ['suite1_backport_required_multiversion'], + 'jstests/fake_file2.js': ['suite1_backport_required_multiversion'] + } + } + } + + self.patch_and_run(latest_yaml, old_yaml, MultiversionOptions.LAST_CONTINUOUS) self.assert_contents(expected) # Can delete after backporting the changed yml syntax. @@ -212,7 +269,7 @@ class TestGenerateExcludeYaml(unittest.TestCase): } } - last_lts_yaml = { + old_yaml = { 'all': [{'ticket': 'fake_ticket1', 'test_file': 'jstests/fake_file1.js'}], 'suites': { 'suite1': [{'ticket': 'fake_ticket2', 'test_file': 'jstests/fake_file2.js'}] } @@ -227,9 +284,5 @@ class TestGenerateExcludeYaml(unittest.TestCase): } } - self.patch_and_run(latest_yaml, last_lts_yaml) + self.patch_and_run(latest_yaml, old_yaml, MultiversionOptions.LAST_LTS) self.assert_contents(expected) - - -if __name__ == '__main__': - unittest.main() diff --git a/buildscripts/tests/test_burn_in_tests_multiversion.py b/buildscripts/tests/test_burn_in_tests_multiversion.py index 56aed5fc434..9e1ac0d2e0b 100644 --- a/buildscripts/tests/test_burn_in_tests_multiversion.py +++ b/buildscripts/tests/test_burn_in_tests_multiversion.py @@ -220,7 +220,7 @@ class TestCreateMultiversionGenerateTasksConfig(unittest.TestCase): @unittest.skipIf(sys.platform.startswith("win"), "not supported on windows") @patch( - "buildscripts.evergreen_gen_multiversion_tests.get_backports_required_hash_for_shell_version" + "buildscripts.resmokelib.run.generate_multiversion_exclude_tags.get_backports_required_hash_for_shell_version" ) def test_one_task_one_test(self, mock_hash): mock_hash.return_value = MONGO_4_2_HASH @@ -247,7 +247,7 @@ class TestCreateMultiversionGenerateTasksConfig(unittest.TestCase): @unittest.skipIf(sys.platform.startswith("win"), "not supported on windows") @patch( - "buildscripts.evergreen_gen_multiversion_tests.get_backports_required_hash_for_shell_version" + "buildscripts.resmokelib.run.generate_multiversion_exclude_tags.get_backports_required_hash_for_shell_version" ) def test_n_task_one_test(self, mock_hash): mock_hash.return_value = MONGO_4_2_HASH @@ -276,7 +276,7 @@ class TestCreateMultiversionGenerateTasksConfig(unittest.TestCase): @unittest.skipIf(sys.platform.startswith("win"), "not supported on windows") @patch( - "buildscripts.evergreen_gen_multiversion_tests.get_backports_required_hash_for_shell_version" + "buildscripts.resmokelib.run.generate_multiversion_exclude_tags.get_backports_required_hash_for_shell_version" ) def test_one_task_n_test(self, mock_hash): mock_hash.return_value = MONGO_4_2_HASH @@ -303,7 +303,7 @@ class TestCreateMultiversionGenerateTasksConfig(unittest.TestCase): @unittest.skipIf(sys.platform.startswith("win"), "not supported on windows") @patch( - "buildscripts.evergreen_gen_multiversion_tests.get_backports_required_hash_for_shell_version" + "buildscripts.resmokelib.run.generate_multiversion_exclude_tags.get_backports_required_hash_for_shell_version" ) def test_n_task_m_test(self, mock_hash): mock_hash.return_value = MONGO_4_2_HASH |