teuthology 1.0.0__py3-none-any.whl → 1.2.0__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 (172) hide show
  1. scripts/describe.py +1 -0
  2. scripts/dispatcher.py +62 -0
  3. scripts/exporter.py +18 -0
  4. scripts/lock.py +1 -1
  5. scripts/node_cleanup.py +58 -0
  6. scripts/openstack.py +9 -9
  7. scripts/results.py +12 -11
  8. scripts/run.py +4 -0
  9. scripts/schedule.py +4 -0
  10. scripts/suite.py +61 -16
  11. scripts/supervisor.py +44 -0
  12. scripts/update_inventory.py +10 -4
  13. scripts/wait.py +31 -0
  14. teuthology/__init__.py +24 -21
  15. teuthology/beanstalk.py +4 -3
  16. teuthology/config.py +17 -6
  17. teuthology/contextutil.py +18 -14
  18. teuthology/describe_tests.py +25 -18
  19. teuthology/dispatcher/__init__.py +365 -0
  20. teuthology/dispatcher/supervisor.py +374 -0
  21. teuthology/exceptions.py +54 -0
  22. teuthology/exporter.py +347 -0
  23. teuthology/kill.py +76 -75
  24. teuthology/lock/cli.py +16 -7
  25. teuthology/lock/ops.py +276 -70
  26. teuthology/lock/query.py +61 -44
  27. teuthology/ls.py +9 -18
  28. teuthology/misc.py +152 -137
  29. teuthology/nuke/__init__.py +12 -351
  30. teuthology/openstack/__init__.py +4 -3
  31. teuthology/openstack/openstack-centos-7.0-user-data.txt +1 -1
  32. teuthology/openstack/openstack-centos-7.1-user-data.txt +1 -1
  33. teuthology/openstack/openstack-centos-7.2-user-data.txt +1 -1
  34. teuthology/openstack/openstack-debian-8.0-user-data.txt +1 -1
  35. teuthology/openstack/openstack-opensuse-42.1-user-data.txt +1 -1
  36. teuthology/openstack/openstack-teuthology.cron +0 -1
  37. teuthology/orchestra/cluster.py +51 -9
  38. teuthology/orchestra/connection.py +23 -16
  39. teuthology/orchestra/console.py +111 -50
  40. teuthology/orchestra/daemon/cephadmunit.py +23 -5
  41. teuthology/orchestra/daemon/state.py +10 -3
  42. teuthology/orchestra/daemon/systemd.py +10 -8
  43. teuthology/orchestra/opsys.py +32 -11
  44. teuthology/orchestra/remote.py +369 -152
  45. teuthology/orchestra/run.py +21 -12
  46. teuthology/packaging.py +54 -15
  47. teuthology/provision/__init__.py +30 -10
  48. teuthology/provision/cloud/openstack.py +12 -6
  49. teuthology/provision/cloud/util.py +1 -2
  50. teuthology/provision/downburst.py +83 -29
  51. teuthology/provision/fog.py +68 -20
  52. teuthology/provision/openstack.py +5 -4
  53. teuthology/provision/pelagos.py +13 -5
  54. teuthology/repo_utils.py +91 -44
  55. teuthology/report.py +57 -35
  56. teuthology/results.py +5 -3
  57. teuthology/run.py +21 -15
  58. teuthology/run_tasks.py +114 -40
  59. teuthology/schedule.py +4 -3
  60. teuthology/scrape.py +28 -22
  61. teuthology/suite/__init__.py +75 -46
  62. teuthology/suite/build_matrix.py +34 -24
  63. teuthology/suite/fragment-merge.lua +105 -0
  64. teuthology/suite/matrix.py +31 -2
  65. teuthology/suite/merge.py +175 -0
  66. teuthology/suite/placeholder.py +8 -8
  67. teuthology/suite/run.py +204 -102
  68. teuthology/suite/util.py +67 -211
  69. teuthology/task/__init__.py +1 -1
  70. teuthology/task/ansible.py +101 -31
  71. teuthology/task/buildpackages.py +2 -2
  72. teuthology/task/ceph_ansible.py +13 -6
  73. teuthology/task/cephmetrics.py +2 -1
  74. teuthology/task/clock.py +33 -14
  75. teuthology/task/exec.py +18 -0
  76. teuthology/task/hadoop.py +2 -2
  77. teuthology/task/install/__init__.py +51 -22
  78. teuthology/task/install/bin/adjust-ulimits +16 -0
  79. teuthology/task/install/bin/daemon-helper +114 -0
  80. teuthology/task/install/bin/stdin-killer +263 -0
  81. teuthology/task/install/deb.py +24 -4
  82. teuthology/task/install/redhat.py +36 -32
  83. teuthology/task/install/rpm.py +41 -14
  84. teuthology/task/install/util.py +48 -22
  85. teuthology/task/internal/__init__.py +69 -11
  86. teuthology/task/internal/edit_sudoers.sh +10 -0
  87. teuthology/task/internal/lock_machines.py +3 -133
  88. teuthology/task/internal/redhat.py +48 -28
  89. teuthology/task/internal/syslog.py +31 -8
  90. teuthology/task/kernel.py +155 -147
  91. teuthology/task/lockfile.py +1 -1
  92. teuthology/task/mpi.py +10 -10
  93. teuthology/task/pcp.py +1 -1
  94. teuthology/task/selinux.py +17 -8
  95. teuthology/task/ssh_keys.py +6 -6
  96. teuthology/task/tests/__init__.py +137 -77
  97. teuthology/task/tests/test_fetch_coredumps.py +116 -0
  98. teuthology/task/tests/test_run.py +4 -4
  99. teuthology/timer.py +3 -3
  100. teuthology/util/loggerfile.py +19 -0
  101. teuthology/util/scanner.py +159 -0
  102. teuthology/util/sentry.py +52 -0
  103. teuthology/util/time.py +52 -0
  104. teuthology-1.2.0.data/scripts/adjust-ulimits +16 -0
  105. teuthology-1.2.0.data/scripts/daemon-helper +114 -0
  106. teuthology-1.2.0.data/scripts/stdin-killer +263 -0
  107. teuthology-1.2.0.dist-info/METADATA +89 -0
  108. teuthology-1.2.0.dist-info/RECORD +174 -0
  109. {teuthology-1.0.0.dist-info → teuthology-1.2.0.dist-info}/WHEEL +1 -1
  110. {teuthology-1.0.0.dist-info → teuthology-1.2.0.dist-info}/entry_points.txt +5 -2
  111. scripts/nuke.py +0 -45
  112. scripts/worker.py +0 -37
  113. teuthology/nuke/actions.py +0 -456
  114. teuthology/openstack/test/__init__.py +0 -0
  115. teuthology/openstack/test/openstack-integration.py +0 -286
  116. teuthology/openstack/test/test_config.py +0 -35
  117. teuthology/openstack/test/test_openstack.py +0 -1695
  118. teuthology/orchestra/test/__init__.py +0 -0
  119. teuthology/orchestra/test/integration/__init__.py +0 -0
  120. teuthology/orchestra/test/integration/test_integration.py +0 -94
  121. teuthology/orchestra/test/test_cluster.py +0 -240
  122. teuthology/orchestra/test/test_connection.py +0 -106
  123. teuthology/orchestra/test/test_console.py +0 -217
  124. teuthology/orchestra/test/test_opsys.py +0 -404
  125. teuthology/orchestra/test/test_remote.py +0 -185
  126. teuthology/orchestra/test/test_run.py +0 -286
  127. teuthology/orchestra/test/test_systemd.py +0 -54
  128. teuthology/orchestra/test/util.py +0 -12
  129. teuthology/sentry.py +0 -18
  130. teuthology/test/__init__.py +0 -0
  131. teuthology/test/fake_archive.py +0 -107
  132. teuthology/test/fake_fs.py +0 -92
  133. teuthology/test/integration/__init__.py +0 -0
  134. teuthology/test/integration/test_suite.py +0 -86
  135. teuthology/test/task/__init__.py +0 -205
  136. teuthology/test/task/test_ansible.py +0 -624
  137. teuthology/test/task/test_ceph_ansible.py +0 -176
  138. teuthology/test/task/test_console_log.py +0 -88
  139. teuthology/test/task/test_install.py +0 -337
  140. teuthology/test/task/test_internal.py +0 -57
  141. teuthology/test/task/test_kernel.py +0 -243
  142. teuthology/test/task/test_pcp.py +0 -379
  143. teuthology/test/task/test_selinux.py +0 -35
  144. teuthology/test/test_config.py +0 -189
  145. teuthology/test/test_contextutil.py +0 -68
  146. teuthology/test/test_describe_tests.py +0 -316
  147. teuthology/test/test_email_sleep_before_teardown.py +0 -81
  148. teuthology/test/test_exit.py +0 -97
  149. teuthology/test/test_get_distro.py +0 -47
  150. teuthology/test/test_get_distro_version.py +0 -47
  151. teuthology/test/test_get_multi_machine_types.py +0 -27
  152. teuthology/test/test_job_status.py +0 -60
  153. teuthology/test/test_ls.py +0 -48
  154. teuthology/test/test_misc.py +0 -368
  155. teuthology/test/test_nuke.py +0 -232
  156. teuthology/test/test_packaging.py +0 -763
  157. teuthology/test/test_parallel.py +0 -28
  158. teuthology/test/test_repo_utils.py +0 -204
  159. teuthology/test/test_report.py +0 -77
  160. teuthology/test/test_results.py +0 -155
  161. teuthology/test/test_run.py +0 -238
  162. teuthology/test/test_safepath.py +0 -55
  163. teuthology/test/test_schedule.py +0 -45
  164. teuthology/test/test_scrape.py +0 -167
  165. teuthology/test/test_timer.py +0 -80
  166. teuthology/test/test_vps_os_vers_parameter_checking.py +0 -84
  167. teuthology/test/test_worker.py +0 -303
  168. teuthology/worker.py +0 -339
  169. teuthology-1.0.0.dist-info/METADATA +0 -76
  170. teuthology-1.0.0.dist-info/RECORD +0 -210
  171. {teuthology-1.0.0.dist-info → teuthology-1.2.0.dist-info}/LICENSE +0 -0
  172. {teuthology-1.0.0.dist-info → teuthology-1.2.0.dist-info}/top_level.txt +0 -0
@@ -1,763 +0,0 @@
1
- import pytest
2
-
3
- from unittest.mock import patch, Mock
4
-
5
- from teuthology import packaging
6
- from teuthology.exceptions import VersionNotFoundError
7
-
8
- KOJI_TASK_RPMS_MATRIX = [
9
- ('tasks/6745/9666745/kernel-4.1.0-0.rc2.git2.1.fc23.x86_64.rpm', 'kernel'),
10
- ('tasks/6745/9666745/kernel-modules-4.1.0-0.rc2.git2.1.fc23.x86_64.rpm', 'kernel-modules'),
11
- ('tasks/6745/9666745/kernel-tools-4.1.0-0.rc2.git2.1.fc23.x86_64.rpm', 'kernel-tools'),
12
- ('tasks/6745/9666745/kernel-tools-libs-devel-4.1.0-0.rc2.git2.1.fc23.x86_64.rpm', 'kernel-tools-libs-devel'),
13
- ('tasks/6745/9666745/kernel-headers-4.1.0-0.rc2.git2.1.fc23.x86_64.rpm', 'kernel-headers'),
14
- ('tasks/6745/9666745/kernel-tools-debuginfo-4.1.0-0.rc2.git2.1.fc23.x86_64.rpm', 'kernel-tools-debuginfo'),
15
- ('tasks/6745/9666745/kernel-debuginfo-common-x86_64-4.1.0-0.rc2.git2.1.fc23.x86_64.rpm', 'kernel-debuginfo-common-x86_64'),
16
- ('tasks/6745/9666745/perf-debuginfo-4.1.0-0.rc2.git2.1.fc23.x86_64.rpm', 'perf-debuginfo'),
17
- ('tasks/6745/9666745/kernel-modules-extra-4.1.0-0.rc2.git2.1.fc23.x86_64.rpm', 'kernel-modules-extra'),
18
- ('tasks/6745/9666745/kernel-tools-libs-4.1.0-0.rc2.git2.1.fc23.x86_64.rpm', 'kernel-tools-libs'),
19
- ('tasks/6745/9666745/kernel-core-4.1.0-0.rc2.git2.1.fc23.x86_64.rpm', 'kernel-core'),
20
- ('tasks/6745/9666745/kernel-debuginfo-4.1.0-0.rc2.git2.1.fc23.x86_64.rpm', 'kernel-debuginfo'),
21
- ('tasks/6745/9666745/python-perf-4.1.0-0.rc2.git2.1.fc23.x86_64.rpm', 'python-perf'),
22
- ('tasks/6745/9666745/kernel-devel-4.1.0-0.rc2.git2.1.fc23.x86_64.rpm', 'kernel-devel'),
23
- ('tasks/6745/9666745/python-perf-debuginfo-4.1.0-0.rc2.git2.1.fc23.x86_64.rpm', 'python-perf-debuginfo'),
24
- ('tasks/6745/9666745/perf-4.1.0-0.rc2.git2.1.fc23.x86_64.rpm', 'perf'),
25
- ]
26
-
27
- KOJI_TASK_RPMS = [rpm[0] for rpm in KOJI_TASK_RPMS_MATRIX]
28
-
29
-
30
- class TestPackaging(object):
31
-
32
- def test_get_package_name_deb(self):
33
- remote = Mock()
34
- remote.os.package_type = "deb"
35
- assert packaging.get_package_name('sqlite', remote) == "sqlite3"
36
-
37
- def test_get_package_name_rpm(self):
38
- remote = Mock()
39
- remote.os.package_type = "rpm"
40
- assert packaging.get_package_name('sqlite', remote) is None
41
-
42
- def test_get_package_name_not_found(self):
43
- remote = Mock()
44
- remote.os.package_type = "rpm"
45
- assert packaging.get_package_name('notthere', remote) is None
46
-
47
- def test_get_service_name_deb(self):
48
- remote = Mock()
49
- remote.os.package_type = "deb"
50
- assert packaging.get_service_name('httpd', remote) == 'apache2'
51
-
52
- def test_get_service_name_rpm(self):
53
- remote = Mock()
54
- remote.os.package_type = "rpm"
55
- assert packaging.get_service_name('httpd', remote) == 'httpd'
56
-
57
- def test_get_service_name_not_found(self):
58
- remote = Mock()
59
- remote.os.package_type = "rpm"
60
- assert packaging.get_service_name('notthere', remote) is None
61
-
62
- def test_install_package_deb(self):
63
- m_remote = Mock()
64
- m_remote.os.package_type = "deb"
65
- expected = [
66
- 'DEBIAN_FRONTEND=noninteractive',
67
- 'sudo',
68
- '-E',
69
- 'apt-get',
70
- '-y',
71
- '--force-yes',
72
- 'install',
73
- 'apache2'
74
- ]
75
- packaging.install_package('apache2', m_remote)
76
- m_remote.run.assert_called_with(args=expected)
77
-
78
- def test_install_package_rpm(self):
79
- m_remote = Mock()
80
- m_remote.os.package_type = "rpm"
81
- expected = [
82
- 'sudo',
83
- 'yum',
84
- '-y',
85
- 'install',
86
- 'httpd'
87
- ]
88
- packaging.install_package('httpd', m_remote)
89
- m_remote.run.assert_called_with(args=expected)
90
-
91
- def test_remove_package_deb(self):
92
- m_remote = Mock()
93
- m_remote.os.package_type = "deb"
94
- expected = [
95
- 'DEBIAN_FRONTEND=noninteractive',
96
- 'sudo',
97
- '-E',
98
- 'apt-get',
99
- '-y',
100
- 'purge',
101
- 'apache2'
102
- ]
103
- packaging.remove_package('apache2', m_remote)
104
- m_remote.run.assert_called_with(args=expected)
105
-
106
- def test_remove_package_rpm(self):
107
- m_remote = Mock()
108
- m_remote.os.package_type = "rpm"
109
- expected = [
110
- 'sudo',
111
- 'yum',
112
- '-y',
113
- 'erase',
114
- 'httpd'
115
- ]
116
- packaging.remove_package('httpd', m_remote)
117
- m_remote.run.assert_called_with(args=expected)
118
-
119
- def test_get_koji_package_name(self):
120
- build_info = dict(version="3.10.0", release="123.20.1")
121
- result = packaging.get_koji_package_name("kernel", build_info)
122
- assert result == "kernel-3.10.0-123.20.1.x86_64.rpm"
123
-
124
- @patch("teuthology.packaging.config")
125
- def test_get_kojiroot_base_url(self, m_config):
126
- m_config.kojiroot_url = "http://kojiroot.com"
127
- build_info = dict(
128
- package_name="kernel",
129
- version="3.10.0",
130
- release="123.20.1",
131
- )
132
- result = packaging.get_kojiroot_base_url(build_info)
133
- expected = "http://kojiroot.com/kernel/3.10.0/123.20.1/x86_64/"
134
- assert result == expected
135
-
136
- @patch("teuthology.packaging.config")
137
- def test_get_koji_build_info_success(self, m_config):
138
- m_config.kojihub_url = "http://kojihub.com"
139
- m_proc = Mock()
140
- expected = dict(foo="bar")
141
- m_proc.exitstatus = 0
142
- m_proc.stdout.getvalue.return_value = str(expected)
143
- m_remote = Mock()
144
- m_remote.run.return_value = m_proc
145
- result = packaging.get_koji_build_info(1, m_remote, dict())
146
- assert result == expected
147
- args, kwargs = m_remote.run.call_args
148
- expected_args = [
149
- 'python', '-c',
150
- 'import koji; '
151
- 'hub = koji.ClientSession("http://kojihub.com"); '
152
- 'print(hub.getBuild(1))',
153
- ]
154
- assert expected_args == kwargs['args']
155
-
156
- @patch("teuthology.packaging.config")
157
- def test_get_koji_build_info_fail(self, m_config):
158
- m_config.kojihub_url = "http://kojihub.com"
159
- m_proc = Mock()
160
- m_proc.exitstatus = 1
161
- m_remote = Mock()
162
- m_remote.run.return_value = m_proc
163
- m_ctx = Mock()
164
- m_ctx.summary = dict()
165
- with pytest.raises(RuntimeError):
166
- packaging.get_koji_build_info(1, m_remote, m_ctx)
167
-
168
- @patch("teuthology.packaging.config")
169
- def test_get_koji_task_result_success(self, m_config):
170
- m_config.kojihub_url = "http://kojihub.com"
171
- m_proc = Mock()
172
- expected = dict(foo="bar")
173
- m_proc.exitstatus = 0
174
- m_proc.stdout.getvalue.return_value = str(expected)
175
- m_remote = Mock()
176
- m_remote.run.return_value = m_proc
177
- result = packaging.get_koji_task_result(1, m_remote, dict())
178
- assert result == expected
179
- args, kwargs = m_remote.run.call_args
180
- expected_args = [
181
- 'python', '-c',
182
- 'import koji; '
183
- 'hub = koji.ClientSession("http://kojihub.com"); '
184
- 'print(hub.getTaskResult(1))',
185
- ]
186
- assert expected_args == kwargs['args']
187
-
188
- @patch("teuthology.packaging.config")
189
- def test_get_koji_task_result_fail(self, m_config):
190
- m_config.kojihub_url = "http://kojihub.com"
191
- m_proc = Mock()
192
- m_proc.exitstatus = 1
193
- m_remote = Mock()
194
- m_remote.run.return_value = m_proc
195
- m_ctx = Mock()
196
- m_ctx.summary = dict()
197
- with pytest.raises(RuntimeError):
198
- packaging.get_koji_task_result(1, m_remote, m_ctx)
199
-
200
- @patch("teuthology.packaging.config")
201
- def test_get_koji_task_rpm_info_success(self, m_config):
202
- m_config.koji_task_url = "http://kojihub.com/work"
203
- expected = dict(
204
- base_url="http://kojihub.com/work/tasks/6745/9666745/",
205
- version="4.1.0-0.rc2.git2.1.fc23.x86_64",
206
- rpm_name="kernel-4.1.0-0.rc2.git2.1.fc23.x86_64.rpm",
207
- package_name="kernel",
208
- )
209
- result = packaging.get_koji_task_rpm_info('kernel', KOJI_TASK_RPMS)
210
- assert expected == result
211
-
212
- @patch("teuthology.packaging.config")
213
- def test_get_koji_task_rpm_info_fail(self, m_config):
214
- m_config.koji_task_url = "http://kojihub.com/work"
215
- with pytest.raises(RuntimeError):
216
- packaging.get_koji_task_rpm_info('ceph', KOJI_TASK_RPMS)
217
-
218
- def test_get_package_version_deb_found(self):
219
- remote = Mock()
220
- remote.os.package_type = "deb"
221
- proc = Mock()
222
- proc.exitstatus = 0
223
- proc.stdout.getvalue.return_value = "2.2"
224
- remote.run.return_value = proc
225
- result = packaging.get_package_version(remote, "apache2")
226
- assert result == "2.2"
227
-
228
- def test_get_package_version_deb_command(self):
229
- remote = Mock()
230
- remote.os.package_type = "deb"
231
- packaging.get_package_version(remote, "apache2")
232
- args, kwargs = remote.run.call_args
233
- expected_args = ['dpkg-query', '-W', '-f', '${Version}', 'apache2']
234
- assert expected_args == kwargs['args']
235
-
236
- def test_get_package_version_rpm_found(self):
237
- remote = Mock()
238
- remote.os.package_type = "rpm"
239
- proc = Mock()
240
- proc.exitstatus = 0
241
- proc.stdout.getvalue.return_value = "2.2"
242
- remote.run.return_value = proc
243
- result = packaging.get_package_version(remote, "httpd")
244
- assert result == "2.2"
245
-
246
- def test_get_package_version_rpm_command(self):
247
- remote = Mock()
248
- remote.os.package_type = "rpm"
249
- packaging.get_package_version(remote, "httpd")
250
- args, kwargs = remote.run.call_args
251
- expected_args = ['rpm', '-q', 'httpd', '--qf', '%{VERSION}-%{RELEASE}']
252
- assert expected_args == kwargs['args']
253
-
254
- def test_get_package_version_not_found(self):
255
- remote = Mock()
256
- remote.os.package_type = "rpm"
257
- proc = Mock()
258
- proc.exitstatus = 1
259
- proc.stdout.getvalue.return_value = "not installed"
260
- remote.run.return_value = proc
261
- result = packaging.get_package_version(remote, "httpd")
262
- assert result is None
263
-
264
- def test_get_package_version_invalid_version(self):
265
- # this tests the possibility that the package is not found
266
- # but the exitstatus is still 0. Not entirely sure we'll ever
267
- # hit this condition, but I want to test the codepath regardless
268
- remote = Mock()
269
- remote.os.package_type = "rpm"
270
- proc = Mock()
271
- proc.exitstatus = 0
272
- proc.stdout.getvalue.return_value = "not installed"
273
- remote.run.return_value = proc
274
- result = packaging.get_package_version(remote, "httpd")
275
- assert result is None
276
-
277
- @pytest.mark.parametrize("input, expected", KOJI_TASK_RPMS_MATRIX)
278
- def test_get_koji_task_result_package_name(self, input, expected):
279
- assert packaging._get_koji_task_result_package_name(input) == expected
280
-
281
- @patch("requests.get")
282
- def test_get_response_success(self, m_get):
283
- resp = Mock()
284
- resp.ok = True
285
- m_get.return_value = resp
286
- result = packaging._get_response("google.com")
287
- assert result == resp
288
-
289
- @patch("requests.get")
290
- def test_get_response_failed_wait(self, m_get):
291
- resp = Mock()
292
- resp.ok = False
293
- m_get.return_value = resp
294
- packaging._get_response("google.com", wait=True, sleep=1, tries=2)
295
- assert m_get.call_count == 2
296
-
297
- @patch("requests.get")
298
- def test_get_response_failed_no_wait(self, m_get):
299
- resp = Mock()
300
- resp.ok = False
301
- m_get.return_value = resp
302
- packaging._get_response("google.com", sleep=1, tries=2)
303
- assert m_get.call_count == 1
304
-
305
-
306
- class TestBuilderProject(object):
307
- klass = None
308
-
309
- def setup(self):
310
- if self.klass is None:
311
- pytest.skip()
312
-
313
- def _get_remote(self, arch="x86_64", system_type="deb", distro="ubuntu",
314
- codename="trusty", version="14.04"):
315
- rem = Mock()
316
- rem.system_type = system_type
317
- rem.os.name = distro
318
- rem.os.codename = codename
319
- rem.os.version = version
320
- rem.arch = arch
321
-
322
- return rem
323
-
324
- def test_init_from_remote_base_url(self, expected=None):
325
- assert expected is not None
326
- rem = self._get_remote()
327
- ctx = dict(foo="bar")
328
- gp = self.klass("ceph", {}, ctx=ctx, remote=rem)
329
- result = gp.base_url
330
- assert result == expected
331
-
332
- def test_init_from_remote_base_url_debian(self, expected=None):
333
- assert expected is not None
334
- # remote.os.codename returns and empty string on debian
335
- rem = self._get_remote(distro="debian", codename='', version="7.1")
336
- ctx = dict(foo="bar")
337
- gp = self.klass("ceph", {}, ctx=ctx, remote=rem)
338
- result = gp.base_url
339
- assert result == expected
340
-
341
- def test_init_from_config_base_url(self, expected=None):
342
- assert expected is not None
343
- config = dict(
344
- os_type="ubuntu",
345
- os_version="14.04",
346
- sha1="sha1",
347
- )
348
- gp = self.klass("ceph", config)
349
- result = gp.base_url
350
- print(self.m_get.call_args_list)
351
- assert result == expected
352
-
353
- def test_init_from_config_branch_ref(self):
354
- config = dict(
355
- os_type="ubuntu",
356
- os_version="14.04",
357
- branch='jewel',
358
- )
359
- gp = self.klass("ceph", config)
360
- result = gp.uri_reference
361
- expected = 'ref/jewel'
362
- assert result == expected
363
-
364
- def test_init_from_config_tag_ref(self):
365
- config = dict(
366
- os_type="ubuntu",
367
- os_version="14.04",
368
- tag='v10.0.1',
369
- )
370
- gp = self.klass("ceph", config)
371
- result = gp.uri_reference
372
- expected = 'ref/v10.0.1'
373
- assert result == expected
374
-
375
- def test_init_from_config_tag_overrides_branch_ref(self, caplog):
376
- config = dict(
377
- os_type="ubuntu",
378
- os_version="14.04",
379
- branch='jewel',
380
- tag='v10.0.1',
381
- )
382
- gp = self.klass("ceph", config)
383
- result = gp.uri_reference
384
- expected = 'ref/v10.0.1'
385
- assert result == expected
386
- expected_log = 'More than one of ref, tag, branch, or sha1 supplied; using tag'
387
- assert expected_log in caplog.text
388
- return gp
389
-
390
- def test_init_from_config_branch_overrides_sha1(self, caplog):
391
- config = dict(
392
- os_type="ubuntu",
393
- os_version="14.04",
394
- branch='jewel',
395
- sha1='sha1',
396
- )
397
- gp = self.klass("ceph", config)
398
- result = gp.uri_reference
399
- expected = 'ref/jewel'
400
- assert result == expected
401
- expected_log = 'More than one of ref, tag, branch, or sha1 supplied; using branch'
402
- assert expected_log in caplog.text
403
- return gp
404
-
405
- REFERENCE_MATRIX = [
406
- ('the_ref', 'the_tag', 'the_branch', 'the_sha1', dict(ref='the_ref')),
407
- (None, 'the_tag', 'the_branch', 'the_sha1', dict(tag='the_tag')),
408
- (None, None, 'the_branch', 'the_sha1', dict(branch='the_branch')),
409
- (None, None, None, 'the_sha1', dict(sha1='the_sha1')),
410
- (None, None, 'the_branch', None, dict(branch='the_branch')),
411
- ]
412
-
413
- @pytest.mark.parametrize(
414
- "ref, tag, branch, sha1, expected",
415
- REFERENCE_MATRIX,
416
- )
417
- def test_choose_reference(self, ref, tag, branch, sha1, expected):
418
- config = dict(
419
- os_type='ubuntu',
420
- os_version='18.04',
421
- )
422
- if ref:
423
- config['ref'] = ref
424
- if tag:
425
- config['tag'] = tag
426
- if branch:
427
- config['branch'] = branch
428
- if sha1:
429
- config['sha1'] = sha1
430
- gp = self.klass("ceph", config)
431
- assert gp._choose_reference() == expected
432
-
433
- def test_get_package_version_found(self):
434
- rem = self._get_remote()
435
- ctx = dict(foo="bar")
436
- gp = self.klass("ceph", {}, ctx=ctx, remote=rem)
437
- assert gp.version == "0.90.0"
438
-
439
- @patch("teuthology.packaging._get_response")
440
- def test_get_package_version_not_found(self, m_get_response):
441
- rem = self._get_remote()
442
- ctx = dict(foo="bar")
443
- resp = Mock()
444
- resp.ok = False
445
- m_get_response.return_value = resp
446
- gp = self.klass("ceph", {}, ctx=ctx, remote=rem)
447
- with pytest.raises(VersionNotFoundError):
448
- gp.version
449
-
450
- def test_get_package_sha1_fetched_found(self):
451
- rem = self._get_remote()
452
- ctx = dict(foo="bar")
453
- gp = self.klass("ceph", {}, ctx=ctx, remote=rem)
454
- assert gp.sha1 == "the_sha1"
455
-
456
- def test_get_package_sha1_fetched_not_found(self):
457
- rem = self._get_remote()
458
- ctx = dict(foo="bar")
459
- gp = self.klass("ceph", {}, ctx=ctx, remote=rem)
460
- assert not gp.sha1
461
-
462
- DISTRO_MATRIX = [None] * 12
463
-
464
- @pytest.mark.parametrize(
465
- "matrix_index",
466
- range(len(DISTRO_MATRIX)),
467
- )
468
- def test_get_distro_remote(self, matrix_index):
469
- (distro, version, codename, expected) = \
470
- self.DISTRO_MATRIX[matrix_index]
471
- rem = self._get_remote(distro=distro, version=version,
472
- codename=codename)
473
- ctx = dict(foo="bar")
474
- gp = self.klass("ceph", {}, ctx=ctx, remote=rem)
475
- assert gp.distro == expected
476
-
477
- DISTRO_MATRIX_NOVER = [
478
- ('rhel', None, None, 'centos8'),
479
- ('centos', None, None, 'centos8'),
480
- ('fedora', None, None, 'fedora25'),
481
- ('ubuntu', None, None, 'bionic'),
482
- ('debian', None, None, 'jessie'),
483
- ]
484
-
485
- @pytest.mark.parametrize(
486
- "matrix_index",
487
- range(len(DISTRO_MATRIX) + len(DISTRO_MATRIX_NOVER)),
488
- )
489
- def test_get_distro_config(self, matrix_index):
490
- (distro, version, codename, expected) = \
491
- (self.DISTRO_MATRIX + self.DISTRO_MATRIX_NOVER)[matrix_index]
492
- config = dict(
493
- os_type=distro,
494
- os_version=version
495
- )
496
- gp = self.klass("ceph", config)
497
- assert gp.distro == expected
498
-
499
- DIST_RELEASE_MATRIX = [
500
- ('rhel', '7.0', None, 'el7'),
501
- ('centos', '6.5', None, 'el6'),
502
- ('centos', '7.0', None, 'el7'),
503
- ('centos', '7.1', None, 'el7'),
504
- ('centos', '8.1', None, 'el8'),
505
- ('fedora', '20', None, 'fc20'),
506
- ('debian', '7.0', None, 'debian'),
507
- ('debian', '7', None, 'debian'),
508
- ('debian', '7.1', None, 'debian'),
509
- ('ubuntu', '12.04', None, 'ubuntu'),
510
- ('ubuntu', '14.04', None, 'ubuntu'),
511
- ]
512
-
513
- @pytest.mark.parametrize(
514
- "matrix_index",
515
- range(len(DIST_RELEASE_MATRIX)),
516
- )
517
- def test_get_dist_release(self, matrix_index):
518
- (distro, version, codename, expected) = \
519
- (self.DIST_RELEASE_MATRIX)[matrix_index]
520
- rem = self._get_remote(distro=distro, version=version,
521
- codename=codename)
522
- ctx = dict(foo="bar")
523
- gp = self.klass("ceph", {}, ctx=ctx, remote=rem)
524
- assert gp.dist_release == expected
525
-
526
-
527
- class TestGitbuilderProject(TestBuilderProject):
528
- klass = packaging.GitbuilderProject
529
-
530
- def setup(self):
531
- self.p_config = patch('teuthology.packaging.config')
532
- self.m_config = self.p_config.start()
533
- self.m_config.baseurl_template = \
534
- 'http://{host}/{proj}-{pkg_type}-{dist}-{arch}-{flavor}/{uri}'
535
- self.m_config.gitbuilder_host = "gitbuilder.ceph.com"
536
- self.p_get_config_value = \
537
- patch('teuthology.packaging._get_config_value_for_remote')
538
- self.m_get_config_value = self.p_get_config_value.start()
539
- self.m_get_config_value.return_value = None
540
- self.p_get = patch('requests.get')
541
- self.m_get = self.p_get.start()
542
- self.p_get_response = patch("teuthology.packaging._get_response")
543
- self.m_get_response = self.p_get_response.start()
544
-
545
- def teardown(self):
546
- self.p_config.stop()
547
- self.p_get_config_value.stop()
548
- self.p_get.stop()
549
- self.p_get_response.stop()
550
-
551
- def test_init_from_remote_base_url(self, expected=None):
552
- super(TestGitbuilderProject, self)\
553
- .test_init_from_remote_base_url(
554
- "http://gitbuilder.ceph.com/"
555
- "ceph-deb-trusty-x86_64-basic/ref/master"
556
- )
557
-
558
- def test_init_from_remote_base_url_debian(self):
559
- super(TestGitbuilderProject, self)\
560
- .test_init_from_remote_base_url_debian(
561
- "http://gitbuilder.ceph.com/"
562
- "ceph-deb-wheezy-x86_64-basic/ref/master"
563
- )
564
-
565
- def test_init_from_config_base_url(self):
566
- super(TestGitbuilderProject, self).test_init_from_config_base_url(
567
- "http://gitbuilder.ceph.com/ceph-deb-trusty-x86_64-basic/sha1/sha1"
568
- )
569
-
570
- def test_get_package_version_found(self):
571
- resp = Mock()
572
- resp.ok = True
573
- resp.text = "0.90.0"
574
- self.m_get_response.return_value = resp
575
- super(TestGitbuilderProject, self)\
576
- .test_get_package_version_found()
577
-
578
- def test_version_strip_v(self):
579
- resp = Mock()
580
- resp.ok = True
581
- resp.text = "v0.90.0"
582
- self.m_get_response.return_value = resp
583
- super(TestGitbuilderProject, self)\
584
- .test_get_package_version_found()
585
-
586
- def test_get_package_sha1_fetched_found(self):
587
- resp = Mock()
588
- resp.ok = True
589
- resp.text = "the_sha1"
590
- self.m_get.return_value = resp
591
- super(TestGitbuilderProject, self)\
592
- .test_get_package_sha1_fetched_found()
593
-
594
- def test_get_package_sha1_fetched_not_found(self):
595
- resp = Mock()
596
- resp.ok = False
597
- self.m_get.return_value = resp
598
- super(TestGitbuilderProject, self)\
599
- .test_get_package_sha1_fetched_not_found()
600
-
601
- DISTRO_MATRIX = [
602
- ('rhel', '7.0', None, 'centos7'),
603
- ('centos', '6.5', None, 'centos6'),
604
- ('centos', '7.0', None, 'centos7'),
605
- ('centos', '7.1', None, 'centos7'),
606
- ('centos', '8.1', None, 'centos8'),
607
- ('fedora', '20', None, 'fedora20'),
608
- ('ubuntu', '14.04', 'trusty', 'trusty'),
609
- ('ubuntu', '14.04', None, 'trusty'),
610
- ('debian', '7.0', None, 'wheezy'),
611
- ('debian', '7', None, 'wheezy'),
612
- ('debian', '7.1', None, 'wheezy'),
613
- ('ubuntu', '12.04', None, 'precise'),
614
- ('ubuntu', '14.04', None, 'trusty'),
615
- ]
616
-
617
-
618
- class TestShamanProject(TestBuilderProject):
619
- klass = packaging.ShamanProject
620
-
621
- def setup(self):
622
- self.p_config = patch('teuthology.packaging.config')
623
- self.m_config = self.p_config.start()
624
- self.m_config.use_shaman = True
625
- self.m_config.shaman_host = 'shaman.ceph.com'
626
- self.p_get_config_value = \
627
- patch('teuthology.packaging._get_config_value_for_remote')
628
- self.m_get_config_value = self.p_get_config_value.start()
629
- self.m_get_config_value.return_value = None
630
- self.p_get = patch('requests.get')
631
- self.m_get = self.p_get.start()
632
-
633
- def teardown(self):
634
- self.p_config.stop()
635
- self.p_get_config_value.stop()
636
- self.p_get.stop()
637
-
638
- def test_init_from_remote_base_url(self):
639
- # Here, we really just need to make sure ShamanProject._search()
640
- # queries the right URL. So let's make _get_base_url() just pass that
641
- # URL through and test that value.
642
- def m_get_base_url(obj):
643
- obj._search()
644
- return self.m_get.call_args_list[0][0][0]
645
- with patch(
646
- 'teuthology.packaging.ShamanProject._get_base_url',
647
- new=m_get_base_url,
648
- ):
649
- super(TestShamanProject, self)\
650
- .test_init_from_remote_base_url(
651
- "https://shaman.ceph.com/api/search?status=ready"
652
- "&project=ceph&flavor=default"
653
- "&distros=ubuntu%2F14.04%2Fx86_64&ref=master"
654
- )
655
-
656
- def test_init_from_remote_base_url_debian(self):
657
- # Here, we really just need to make sure ShamanProject._search()
658
- # queries the right URL. So let's make _get_base_url() just pass that
659
- # URL through and test that value.
660
- def m_get_base_url(obj):
661
- obj._search()
662
- return self.m_get.call_args_list[0][0][0]
663
- with patch(
664
- 'teuthology.packaging.ShamanProject._get_base_url',
665
- new=m_get_base_url,
666
- ):
667
- super(TestShamanProject, self)\
668
- .test_init_from_remote_base_url_debian(
669
- "https://shaman.ceph.com/api/search?status=ready"
670
- "&project=ceph&flavor=default"
671
- "&distros=debian%2F7.1%2Fx86_64&ref=master"
672
- )
673
-
674
- def test_init_from_config_base_url(self):
675
- # Here, we really just need to make sure ShamanProject._search()
676
- # queries the right URL. So let's make _get_base_url() just pass that
677
- # URL through and test that value.
678
- def m_get_base_url(obj):
679
- obj._search()
680
- return self.m_get.call_args_list[0][0][0]
681
- with patch(
682
- 'teuthology.packaging.ShamanProject._get_base_url',
683
- new=m_get_base_url,
684
- ):
685
- super(TestShamanProject, self).test_init_from_config_base_url(
686
- "https://shaman.ceph.com/api/search?status=ready&project=ceph" \
687
- "&flavor=default&distros=ubuntu%2F14.04%2Fx86_64&sha1=sha1"
688
- )
689
-
690
- @patch('teuthology.packaging.ShamanProject._get_package_sha1')
691
- def test_init_from_config_tag_ref(self, m_get_package_sha1):
692
- m_get_package_sha1.return_value = 'the_sha1'
693
- super(TestShamanProject, self).test_init_from_config_tag_ref()
694
-
695
- def test_init_from_config_tag_overrides_branch_ref(self, caplog):
696
- with patch(
697
- 'teuthology.packaging.repo_utils.ls_remote',
698
- ) as m_ls_remote:
699
- m_ls_remote.return_value = 'sha1_from_my_tag'
700
- obj = super(TestShamanProject, self)\
701
- .test_init_from_config_tag_overrides_branch_ref(caplog)
702
- search_uri = obj._search_uri
703
- assert 'sha1=sha1_from_my_tag' in search_uri
704
- assert 'jewel' not in search_uri
705
-
706
- def test_init_from_config_branch_overrides_sha1(self, caplog):
707
- obj = super(TestShamanProject, self)\
708
- .test_init_from_config_branch_overrides_sha1(caplog)
709
- search_uri = obj._search_uri
710
- assert 'jewel' in search_uri
711
- assert 'sha1' not in search_uri
712
-
713
- def test_get_package_version_found(self):
714
- resp = Mock()
715
- resp.ok = True
716
- resp.json.return_value = [
717
- dict(
718
- sha1='the_sha1',
719
- extra=dict(package_manager_version='0.90.0'),
720
- )
721
- ]
722
- self.m_get.return_value = resp
723
- super(TestShamanProject, self)\
724
- .test_get_package_version_found()
725
-
726
- def test_get_package_sha1_fetched_found(self):
727
- resp = Mock()
728
- resp.ok = True
729
- resp.json.return_value = [dict(sha1='the_sha1')]
730
- self.m_get.return_value = resp
731
- super(TestShamanProject, self)\
732
- .test_get_package_sha1_fetched_found()
733
-
734
- def test_get_package_sha1_fetched_not_found(self):
735
- resp = Mock()
736
- resp.json.return_value = []
737
- self.m_get.return_value = resp
738
- super(TestShamanProject, self)\
739
- .test_get_package_sha1_fetched_not_found()
740
-
741
- DISTRO_MATRIX = [
742
- ('rhel', '7.0', None, 'centos/7'),
743
- ('centos', '6.5', None, 'centos/6'),
744
- ('centos', '7.0', None, 'centos/7'),
745
- ('centos', '7.1', None, 'centos/7'),
746
- ('centos', '8.1', None, 'centos/8'),
747
- ('fedora', '20', None, 'fedora/20'),
748
- ('ubuntu', '14.04', 'trusty', 'ubuntu/14.04'),
749
- ('ubuntu', '14.04', None, 'ubuntu/14.04'),
750
- ('debian', '7.0', None, 'debian/7.0'),
751
- ('debian', '7', None, 'debian/7'),
752
- ('debian', '7.1', None, 'debian/7.1'),
753
- ('ubuntu', '12.04', None, 'ubuntu/12.04'),
754
- ('ubuntu', '14.04', None, 'ubuntu/14.04'),
755
- ]
756
-
757
- DISTRO_MATRIX_NOVER = [
758
- ('rhel', None, None, 'centos/8'),
759
- ('centos', None, None, 'centos/8'),
760
- ('fedora', None, None, 'fedora/25'),
761
- ('ubuntu', None, None, 'ubuntu/18.04'),
762
- ('debian', None, None, 'debian/8.0'),
763
- ]