teuthology 1.2.0__py3-none-any.whl → 1.2.2__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. scripts/node_cleanup.py +18 -2
  2. scripts/suite.py +2 -0
  3. teuthology/__init__.py +0 -1
  4. teuthology/config.py +28 -7
  5. teuthology/dispatcher/supervisor.py +9 -6
  6. teuthology/lock/cli.py +4 -2
  7. teuthology/lock/ops.py +10 -9
  8. teuthology/lock/query.py +28 -4
  9. teuthology/lock/util.py +1 -1
  10. teuthology/misc.py +13 -58
  11. teuthology/openstack/__init__.py +202 -176
  12. teuthology/openstack/setup-openstack.sh +52 -27
  13. teuthology/orchestra/connection.py +3 -1
  14. teuthology/orchestra/daemon/cephadmunit.py +2 -2
  15. teuthology/orchestra/opsys.py +15 -0
  16. teuthology/orchestra/remote.py +54 -2
  17. teuthology/orchestra/run.py +8 -2
  18. teuthology/provision/downburst.py +84 -43
  19. teuthology/provision/fog.py +2 -2
  20. teuthology/repo_utils.py +3 -1
  21. teuthology/run.py +1 -1
  22. teuthology/scrape.py +5 -2
  23. teuthology/suite/merge.py +3 -1
  24. teuthology/suite/run.py +51 -37
  25. teuthology/suite/util.py +2 -2
  26. teuthology/task/install/rpm.py +8 -16
  27. teuthology/task/internal/__init__.py +2 -1
  28. teuthology/task/internal/syslog.py +17 -13
  29. teuthology/task/kernel.py +1 -1
  30. {teuthology-1.2.0.dist-info → teuthology-1.2.2.dist-info}/METADATA +11 -10
  31. {teuthology-1.2.0.dist-info → teuthology-1.2.2.dist-info}/RECORD +38 -44
  32. {teuthology-1.2.0.dist-info → teuthology-1.2.2.dist-info}/WHEEL +1 -1
  33. teuthology/lock/test/__init__.py +0 -0
  34. teuthology/lock/test/test_lock.py +0 -7
  35. teuthology/task/tests/__init__.py +0 -170
  36. teuthology/task/tests/test_fetch_coredumps.py +0 -116
  37. teuthology/task/tests/test_locking.py +0 -25
  38. teuthology/task/tests/test_run.py +0 -40
  39. {teuthology-1.2.0.data → teuthology-1.2.2.data}/scripts/adjust-ulimits +0 -0
  40. {teuthology-1.2.0.data → teuthology-1.2.2.data}/scripts/daemon-helper +0 -0
  41. {teuthology-1.2.0.data → teuthology-1.2.2.data}/scripts/stdin-killer +0 -0
  42. {teuthology-1.2.0.dist-info → teuthology-1.2.2.dist-info}/entry_points.txt +0 -0
  43. {teuthology-1.2.0.dist-info → teuthology-1.2.2.dist-info/licenses}/LICENSE +0 -0
  44. {teuthology-1.2.0.dist-info → teuthology-1.2.2.dist-info}/top_level.txt +0 -0
@@ -1,170 +0,0 @@
1
- """
2
- This task runs teuthology's unit tests and integration tests.
3
- It can run in one of two modes: "py" or "cli". The latter executes py.test in a
4
- separate process, whereas the former invokes it in the teuthology job's python
5
- process.
6
- If the running job has remotes available to it, it will attempt to run integration tests.
7
- Note that this requires running in "py" mode - the default.
8
-
9
- An example::
10
-
11
- tasks
12
- - tests:
13
- """
14
- import logging
15
- import os
16
- import pathlib
17
- import pexpect
18
- import pytest
19
-
20
- from teuthology.job_status import set_status
21
- from teuthology.task import Task
22
- from teuthology.util.loggerfile import LoggerFile
23
-
24
-
25
- log = logging.getLogger(__name__)
26
-
27
-
28
- class TeuthologyContextPlugin(object):
29
- def __init__(self, ctx, config):
30
- self.ctx = ctx
31
- self.config = config
32
- self.failures = list()
33
- self.stats = dict()
34
-
35
- # this is pytest hook for generating tests with custom parameters
36
- def pytest_generate_tests(self, metafunc):
37
- # pass the teuthology ctx and config to each test method
38
- if "ctx" in metafunc.fixturenames and \
39
- "config" in metafunc.fixturenames:
40
- metafunc.parametrize(["ctx", "config"], [(self.ctx, self.config),])
41
-
42
- # log the outcome of each test
43
- @pytest.hookimpl(hookwrapper=True)
44
- def pytest_runtest_makereport(self, item: pytest.Item, call: pytest.CallInfo):
45
- outcome = yield
46
- report = outcome.get_result()
47
- test_path = item.location[0]
48
- line_no = item.location[1]
49
- test_name = item.location[2]
50
- name = f"{test_path}:{line_no}:{test_name}"
51
- log_msg = f"{report.outcome.upper()} {name}"
52
- outcome_str = report.outcome.lower()
53
- self.stats.setdefault(outcome_str, 0)
54
- self.stats[outcome_str] += 1
55
- if outcome_str in ['passed', 'skipped']:
56
- if call.when == 'call':
57
- log.info(log_msg)
58
- else:
59
- log.info(f"----- {name} {call.when} -----")
60
- else:
61
- log_msg = f"{log_msg}:{call.when}"
62
- if call.excinfo:
63
- self.failures.append(name)
64
- log_msg = f"{log_msg}: {call.excinfo.getrepr()}"
65
- else:
66
- self.failures.append(log_msg)
67
- log.error(log_msg)
68
-
69
- return
70
-
71
-
72
- # https://docs.pytest.org/en/stable/reference/exit-codes.html
73
- exit_codes = {
74
- 0: "All tests were collected and passed successfully",
75
- 1: "Tests were collected and run but some of the tests failed",
76
- 2: "Test execution was interrupted by the user",
77
- 3: "Internal error happened while executing tests",
78
- 4: "pytest command line usage error",
79
- 5: "No tests were collected",
80
- }
81
-
82
-
83
- class Tests(Task):
84
- """
85
- Use pytest to recurse through this directory, finding any tests
86
- and then executing them with the teuthology ctx and config args.
87
- Your tests must follow standard pytest conventions to be discovered.
88
-
89
- If config["mode"] == "py", (the default), it will be run in the job's process.
90
- If config["mode"] == "cli" py.test will be invoked as a subprocess.
91
- """
92
- base_args = ['-v', '--color=no']
93
-
94
- def setup(self):
95
- super().setup()
96
- mode = self.config.get("mode", "py")
97
- assert mode in ["py", "cli"], "mode must either be 'py' or 'cli'"
98
- if mode == "cli":
99
- # integration tests need ctx from this process, so we need to invoke
100
- # pytest via python to be able to pass them
101
- assert len(self.cluster.remotes) == 0, \
102
- "Tests requiring remote nodes conflicts with CLI mode"
103
- self.mode = mode
104
- self.stats = dict()
105
- self.orig_curdir = os.curdir
106
-
107
- def begin(self):
108
- super().begin()
109
- try:
110
- if self.mode == "py":
111
- self.status, self.failures = self.run_py()
112
- else:
113
- self.status, self.failures = self.run_cli()
114
- except Exception as e:
115
- log.exception("Saw non-test failure!")
116
- self.ctx.summary['failure_reason'] = str(e)
117
- set_status(self.ctx.summary, "dead")
118
-
119
- def end(self):
120
- if os.curdir != self.orig_curdir:
121
- os.chdir(self.orig_curdir)
122
- if self.stats:
123
- log.info(f"Stats: {self.stats}")
124
- if self.status == 0:
125
- log.info("OK. All tests passed!")
126
- set_status(self.ctx.summary, "pass")
127
- else:
128
- status_msg = str(self.status)
129
- if self.status in exit_codes:
130
- status_msg = f"{status_msg}: {exit_codes[self.status]}"
131
- log.error(f"FAIL (exit code {status_msg})")
132
- if self.failures:
133
- msg = f"{len(self.failures)} Failures: {self.failures}"
134
- self.ctx.summary['failure_reason'] = msg
135
- log.error(msg)
136
- set_status(self.ctx.summary, "fail")
137
- super().end()
138
-
139
- def run_cli(self):
140
- pytest_args = self.base_args + ['./teuthology/test', './scripts']
141
- if len(self.cluster.remotes):
142
- pytest_args.append('./teuthology/task/tests')
143
- self.log.info(f"pytest args: {pytest_args}")
144
- cwd = str(pathlib.Path(__file__).parents[3])
145
- log.info(f"pytest cwd: {cwd}")
146
- _, status = pexpect.run(
147
- "py.test " + " ".join(pytest_args),
148
- cwd=cwd,
149
- withexitstatus=True,
150
- timeout=None,
151
- logfile=LoggerFile(self.log, logging.INFO),
152
- )
153
- return status, []
154
-
155
- def run_py(self):
156
- pytest_args = self.base_args + ['--pyargs', 'teuthology', 'scripts']
157
- if len(self.cluster.remotes):
158
- pytest_args.append(__name__)
159
- self.log.info(f"pytest args: {pytest_args}")
160
- context_plugin = TeuthologyContextPlugin(self.ctx, self.config)
161
- # the cwd needs to change so that FakeArchive can find files in this repo
162
- os.chdir(str(pathlib.Path(__file__).parents[3]))
163
- status = pytest.main(
164
- args=pytest_args,
165
- plugins=[context_plugin],
166
- )
167
- self.stats = context_plugin.stats
168
- return status, context_plugin.failures
169
-
170
- task = Tests
@@ -1,116 +0,0 @@
1
- from teuthology.task.internal import fetch_binaries_for_coredumps
2
- from unittest.mock import patch, Mock
3
- import gzip
4
- import os
5
-
6
- class TestFetchCoreDumps(object):
7
- class MockDecode(object):
8
- def __init__(self, ret):
9
- self.ret = ret
10
- pass
11
-
12
- def decode(self):
13
- return self.ret
14
-
15
- class MockPopen(object):
16
- def __init__(self, ret):
17
- self.ret = ret
18
-
19
- def communicate(self, input=None):
20
- return [TestFetchCoreDumps.MockDecode(self.ret)]
21
-
22
- def setup_method(self):
23
- self.the_function = fetch_binaries_for_coredumps
24
- with gzip.open('file.gz', 'wb') as f:
25
- f.write(b'Hello world!')
26
- self.core_dump_path = "file.gz"
27
- self.m_remote = Mock()
28
- self.uncompressed_correct = self.MockPopen(
29
- "ELF 64-bit LSB core file,"\
30
- " x86-64, version 1 (SYSV), SVR4-style, from 'ceph_test_rados_api_io',"\
31
- " real uid: 1194, effective uid: 1194, real gid: 1194,"\
32
- " effective gid: 1194, execfn: '/usr/bin/ceph_test_rados_api_io', platform: 'x86_64'"
33
- )
34
- self.uncompressed_incorrect = self.MockPopen("ASCII text")
35
- self.compressed_correct = self.MockPopen(
36
- "gzip compressed data, was "\
37
- "'correct.format.core', last modified: Wed Jun 29"\
38
- " 19:55:29 2022, from Unix, original size modulo 2^32 3167080"
39
- )
40
-
41
- self.compressed_incorrect = self.MockPopen(
42
- "gzip compressed data, was "\
43
- "'incorrect.format.core', last modified: Wed Jun 29"\
44
- " 19:56:56 2022, from Unix, original size modulo 2^32 11"
45
- )
46
-
47
- # Core is not compressed and file is in the correct format
48
- @patch('teuthology.task.internal.subprocess.Popen')
49
- @patch('teuthology.task.internal.os')
50
- def test_uncompressed_correct_format(self, m_os, m_subproc_popen):
51
- m_subproc_popen.side_effect = [
52
- self.uncompressed_correct,
53
- Exception("We shouldn't be hitting this!")
54
- ]
55
- m_os.path.join.return_value = self.core_dump_path
56
- m_os.path.sep = self.core_dump_path
57
- m_os.path.isdir.return_value = True
58
- m_os.path.dirname.return_value = self.core_dump_path
59
- m_os.path.exists.return_value = True
60
- m_os.listdir.return_value = [self.core_dump_path]
61
- self.the_function(None, self.m_remote)
62
- assert self.m_remote.get_file.called
63
-
64
- # Core is not compressed and file is in the wrong format
65
- @patch('teuthology.task.internal.subprocess.Popen')
66
- @patch('teuthology.task.internal.os')
67
- def test_uncompressed_incorrect_format(self, m_os, m_subproc_popen):
68
- m_subproc_popen.side_effect = [
69
- self.uncompressed_incorrect,
70
- Exception("We shouldn't be hitting this!")
71
- ]
72
- m_os.path.join.return_value = self.core_dump_path
73
- m_os.path.sep = self.core_dump_path
74
- m_os.path.isdir.return_value = True
75
- m_os.path.dirname.return_value = self.core_dump_path
76
- m_os.path.exists.return_value = True
77
- m_os.listdir.return_value = [self.core_dump_path]
78
- self.the_function(None, self.m_remote)
79
- assert self.m_remote.get_file.called == False
80
-
81
- # Core is compressed and file is in the correct format
82
- @patch('teuthology.task.internal.subprocess.Popen')
83
- @patch('teuthology.task.internal.os')
84
- def test_compressed_correct_format(self, m_os, m_subproc_popen):
85
- m_subproc_popen.side_effect = [
86
- self.compressed_correct,
87
- self.uncompressed_correct
88
- ]
89
- m_os.path.join.return_value = self.core_dump_path
90
- m_os.path.sep = self.core_dump_path
91
- m_os.path.isdir.return_value = True
92
- m_os.path.dirname.return_value = self.core_dump_path
93
- m_os.path.exists.return_value = True
94
- m_os.listdir.return_value = [self.core_dump_path]
95
- self.the_function(None, self.m_remote)
96
- assert self.m_remote.get_file.called
97
-
98
- # Core is compressed and file is in the wrong format
99
- @patch('teuthology.task.internal.subprocess.Popen')
100
- @patch('teuthology.task.internal.os')
101
- def test_compressed_incorrect_format(self, m_os, m_subproc_popen):
102
- m_subproc_popen.side_effect = [
103
- self.compressed_incorrect,
104
- self.uncompressed_incorrect
105
- ]
106
- m_os.path.join.return_value = self.core_dump_path
107
- m_os.path.sep = self.core_dump_path
108
- m_os.path.isdir.return_value = True
109
- m_os.path.dirname.return_value = self.core_dump_path
110
- m_os.path.exists.return_value = True
111
- m_os.listdir.return_value = [self.core_dump_path]
112
- self.the_function(None, self.m_remote)
113
- assert self.m_remote.get_file.called == False
114
-
115
- def teardown(self):
116
- os.remove(self.core_dump_path)
@@ -1,25 +0,0 @@
1
- import pytest
2
-
3
-
4
- class TestLocking(object):
5
-
6
- def test_correct_os_type(self, ctx, config):
7
- os_type = ctx.config.get("os_type")
8
- if os_type is None:
9
- pytest.skip('os_type was not defined')
10
- for remote in ctx.cluster.remotes.keys():
11
- assert remote.os.name == os_type
12
-
13
- def test_correct_os_version(self, ctx, config):
14
- os_version = ctx.config.get("os_version")
15
- if os_version is None:
16
- pytest.skip('os_version was not defined')
17
- if ctx.config.get("os_type") == "debian":
18
- pytest.skip('known issue with debian versions; see: issue #10878')
19
- for remote in ctx.cluster.remotes.keys():
20
- assert remote.inventory_info['os_version'] == os_version
21
-
22
- def test_correct_machine_type(self, ctx, config):
23
- machine_type = ctx.machine_type
24
- for remote in ctx.cluster.remotes.keys():
25
- assert remote.machine_type in machine_type
@@ -1,40 +0,0 @@
1
- import logging
2
- import pytest
3
-
4
- from io import StringIO
5
-
6
- from teuthology.exceptions import CommandFailedError
7
-
8
- log = logging.getLogger(__name__)
9
-
10
-
11
- class TestRun(object):
12
- """
13
- Tests to see if we can make remote procedure calls to the current cluster
14
- """
15
-
16
- def test_command_failed_label(self, ctx, config):
17
- result = ""
18
- try:
19
- ctx.cluster.run(
20
- args=["python3", "-c", "assert False"],
21
- label="working as expected, nothing to see here"
22
- )
23
- except CommandFailedError as e:
24
- result = str(e)
25
-
26
- assert "working as expected" in result
27
-
28
- def test_command_failed_no_label(self, ctx, config):
29
- with pytest.raises(CommandFailedError):
30
- ctx.cluster.run(
31
- args=["python3", "-c", "assert False"],
32
- )
33
-
34
- def test_command_success(self, ctx, config):
35
- result = StringIO()
36
- ctx.cluster.run(
37
- args=["python3", "-c", "print('hi')"],
38
- stdout=result
39
- )
40
- assert result.getvalue().strip() == "hi"