summaryrefslogtreecommitdiff
path: root/buildscripts/tests
diff options
context:
space:
mode:
Diffstat (limited to 'buildscripts/tests')
-rw-r--r--buildscripts/tests/data/errorcodes/regex_matching/regex_matching.cpp6
-rw-r--r--buildscripts/tests/resmokelib/core/test_pipe.py39
-rw-r--r--buildscripts/tests/resmokelib/multiversion/test_multiversion_service.py32
-rw-r--r--buildscripts/tests/resmokelib/testing/fixtures/test_api_adherence.py1
-rw-r--r--buildscripts/tests/test_burn_in_tests.py18
-rw-r--r--buildscripts/tests/test_errorcodes.py2
6 files changed, 81 insertions, 17 deletions
diff --git a/buildscripts/tests/data/errorcodes/regex_matching/regex_matching.cpp b/buildscripts/tests/data/errorcodes/regex_matching/regex_matching.cpp
index 834d2052a98..b45042b4b0f 100644
--- a/buildscripts/tests/data/errorcodes/regex_matching/regex_matching.cpp
+++ b/buildscripts/tests/data/errorcodes/regex_matching/regex_matching.cpp
@@ -27,4 +27,8 @@ LOGV2_ERROR(25,
"more words");
LOGV2_ERROR(26,
"words",
- "comma, more words words words words words words words words words words words words "
+ "comma, more words words words words words words words words words words words words ");
+iassert(27, "words");
+iasserted(28, "words");
+iassertNoTrace(29, "words");
+iassertedNoTrace(30, "words");
diff --git a/buildscripts/tests/resmokelib/core/test_pipe.py b/buildscripts/tests/resmokelib/core/test_pipe.py
index 69b0e3fb576..6ecece299a7 100644
--- a/buildscripts/tests/resmokelib/core/test_pipe.py
+++ b/buildscripts/tests/resmokelib/core/test_pipe.py
@@ -10,7 +10,7 @@ import mock
from buildscripts.resmokelib.core import pipe as _pipe
-# pylint: disable=missing-docstring
+# pylint: disable=missing-docstring,protected-access
class TestLoggerPipe(unittest.TestCase):
@@ -43,3 +43,40 @@ class TestLoggerPipe(unittest.TestCase):
def test_escapes_null_bytes(self):
calls = self._get_log_calls(b"a\0b")
self.assertEqual(calls, [mock.call(self.LOG_LEVEL, u"a\\0b")])
+
+
+class TestFormatLineForLogging(unittest.TestCase):
+ def test_strips_trailing_whitespace(self):
+ line = b" a "
+
+ line_output = _pipe.LoggerPipe._format_line_for_logging(line)
+
+ self.assertEqual([u" a"], line_output)
+
+ def test_strips_trailing_newlines(self):
+ line = b"a\r\n"
+
+ line_output = _pipe.LoggerPipe._format_line_for_logging(line)
+
+ self.assertEqual([u"a"], line_output)
+
+ def test_handles_invalid_utf8(self):
+ line = b"a\x80b"
+
+ line_output = _pipe.LoggerPipe._format_line_for_logging(line)
+
+ self.assertEqual([u"a\ufffdb"], line_output)
+
+ def test_escapes_null_bytes(self):
+ line = b"a\0b"
+
+ line_output = _pipe.LoggerPipe._format_line_for_logging(line)
+
+ self.assertEqual([u"a\\0b"], line_output)
+
+ def test_long_lines_are_split(self):
+ line = b"a" * 4_000_000
+
+ line_output = _pipe.LoggerPipe._format_line_for_logging(line)
+
+ self.assertEqual(2, len(line_output))
diff --git a/buildscripts/tests/resmokelib/multiversion/test_multiversion_service.py b/buildscripts/tests/resmokelib/multiversion/test_multiversion_service.py
index 2f685f36c97..274b7e5ffbe 100644
--- a/buildscripts/tests/resmokelib/multiversion/test_multiversion_service.py
+++ b/buildscripts/tests/resmokelib/multiversion/test_multiversion_service.py
@@ -38,6 +38,8 @@ class TestCalculateFcvConstants(TestCase):
"100.0"
],
"longTermSupportReleases": ["4.0", "4.2", "4.4", "5.0"],
+ "eolVersions":
+ ["2.0", "2.2", "2.4", "2.6", "3.0", "3.2", "3.4", "3.6", "4.0", "5.1", "5.2"],
})
multiversion_service = under_test.MultiversionService(
@@ -45,15 +47,15 @@ class TestCalculateFcvConstants(TestCase):
mongo_releases=mongo_releases,
)
- fcv_constants = multiversion_service.calculate_fcv_constants()
+ version_constants = multiversion_service.calculate_version_constants()
- self.assertEqual(fcv_constants.latest, Version("6.0"))
- self.assertEqual(fcv_constants.last_continuous, Version("5.3"))
- self.assertEqual(fcv_constants.last_lts, Version("5.0"))
- self.assertEqual(fcv_constants.requires_fcv_tag_list,
+ self.assertEqual(version_constants.latest, Version("6.0"))
+ self.assertEqual(version_constants.last_continuous, Version("5.3"))
+ self.assertEqual(version_constants.last_lts, Version("5.0"))
+ self.assertEqual(version_constants.requires_fcv_tag_list,
[Version(v) for v in ["5.1", "5.2", "5.3", "6.0"]])
- self.assertEqual(fcv_constants.requires_fcv_tag_list_continuous, [Version("6.0")])
- self.assertEqual(fcv_constants.fcvs_less_than_latest, [
+ self.assertEqual(version_constants.requires_fcv_tag_list_continuous, [Version("6.0")])
+ self.assertEqual(version_constants.fcvs_less_than_latest, [
Version(v)
for v in ["4.0", "4.2", "4.4", "4.7", "4.8", "4.9", "5.0", "5.1", "5.2", "5.3"]
])
@@ -67,6 +69,8 @@ class TestCalculateFcvConstants(TestCase):
"6.1", "100.0"
],
"longTermSupportReleases": ["4.0", "4.2", "4.4", "5.0", "6.0"],
+ "eolVersions":
+ ["2.0", "2.2", "2.4", "2.6", "3.0", "3.2", "3.4", "3.6", "4.0", "5.1", "5.2"],
})
multiversion_service = under_test.MultiversionService(
@@ -74,15 +78,15 @@ class TestCalculateFcvConstants(TestCase):
mongo_releases=mongo_releases,
)
- fcv_constants = multiversion_service.calculate_fcv_constants()
+ version_constants = multiversion_service.calculate_version_constants()
- self.assertEqual(fcv_constants.latest, Version("100.0"))
- self.assertEqual(fcv_constants.last_continuous, Version("6.1"))
- self.assertEqual(fcv_constants.last_lts, Version("6.0"))
- self.assertEqual(fcv_constants.requires_fcv_tag_list,
+ self.assertEqual(version_constants.latest, Version("100.0"))
+ self.assertEqual(version_constants.last_continuous, Version("6.1"))
+ self.assertEqual(version_constants.last_lts, Version("6.0"))
+ self.assertEqual(version_constants.requires_fcv_tag_list,
[Version(v) for v in ["6.1", "100.0"]])
- self.assertEqual(fcv_constants.requires_fcv_tag_list_continuous, [Version("100.0")])
- self.assertEqual(fcv_constants.fcvs_less_than_latest, [
+ self.assertEqual(version_constants.requires_fcv_tag_list_continuous, [Version("100.0")])
+ self.assertEqual(version_constants.fcvs_less_than_latest, [
Version(v) for v in
["4.0", "4.2", "4.4", "4.7", "4.8", "4.9", "5.0", "5.1", "5.2", "5.3", "6.0", "6.1"]
])
diff --git a/buildscripts/tests/resmokelib/testing/fixtures/test_api_adherence.py b/buildscripts/tests/resmokelib/testing/fixtures/test_api_adherence.py
index 7f0e1110a32..81b717bb0fe 100644
--- a/buildscripts/tests/resmokelib/testing/fixtures/test_api_adherence.py
+++ b/buildscripts/tests/resmokelib/testing/fixtures/test_api_adherence.py
@@ -8,6 +8,7 @@ import os
DISALLOWED_ROOT = "buildscripts"
ALLOWED_IMPORTS = [
+ "buildscripts.resmokelib.testing.fixtures.external",
"buildscripts.resmokelib.testing.fixtures.interface",
"buildscripts.resmokelib.testing.fixtures.fixturelib",
"buildscripts.resmokelib.multiversionconstants",
diff --git a/buildscripts/tests/test_burn_in_tests.py b/buildscripts/tests/test_burn_in_tests.py
index c51f8c60ecf..369131eff60 100644
--- a/buildscripts/tests/test_burn_in_tests.py
+++ b/buildscripts/tests/test_burn_in_tests.py
@@ -4,12 +4,14 @@ from __future__ import absolute_import
import collections
import datetime
+from io import StringIO
import os
import sys
import subprocess
import unittest
from mock import Mock, patch, MagicMock
+import yaml
import buildscripts.burn_in_tests as under_test
from buildscripts.ciconfig.evergreen import parse_evergreen_file, VariantTask
@@ -556,3 +558,19 @@ class TestLocalFileChangeDetector(unittest.TestCase):
self.assertIn(file_list[2], found_tests)
self.assertNotIn(file_list[1], found_tests)
self.assertEqual(2, len(found_tests))
+
+
+class TestYamlBurnInExecutor(unittest.TestCase):
+ @patch('sys.stdout', new_callable=StringIO)
+ def test_found_tasks_should_be_reported_as_yaml(self, stdout):
+ n_tasks = 5
+ n_tests = 3
+ tests_by_task = create_tests_by_task_mock(n_tasks, n_tests)
+
+ yaml_executor = under_test.YamlBurnInExecutor()
+ yaml_executor.execute(tests_by_task)
+
+ yaml_raw = stdout.getvalue()
+ results = yaml.safe_load(yaml_raw)
+ self.assertEqual(n_tasks, len(results["discovered_tasks"]))
+ self.assertEqual(n_tests, len(results["discovered_tasks"][0]["test_list"]))
diff --git a/buildscripts/tests/test_errorcodes.py b/buildscripts/tests/test_errorcodes.py
index 2a9c9ce1e3f..d14aa505a92 100644
--- a/buildscripts/tests/test_errorcodes.py
+++ b/buildscripts/tests/test_errorcodes.py
@@ -26,7 +26,7 @@ class TestErrorcodes(unittest.TestCase):
captured_error_codes.append(code)
errorcodes.parse_source_files(accumulate_files, TESTDATA_DIR + 'regex_matching/')
- self.assertEqual(26, len(captured_error_codes))
+ self.assertEqual(30, len(captured_error_codes))
def test_dup_checking(self):
"""Test dup checking."""