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,404 +0,0 @@
1
- from textwrap import dedent
2
- from teuthology.orchestra.opsys import OS
3
- import pytest
4
-
5
-
6
- class TestOS(object):
7
- str_centos_7_os_release = dedent("""
8
- NAME="CentOS Linux"
9
- VERSION="7 (Core)"
10
- ID="centos"
11
- ID_LIKE="rhel fedora"
12
- VERSION_ID="7"
13
- PRETTY_NAME="CentOS Linux 7 (Core)"
14
- ANSI_COLOR="0;31"
15
- CPE_NAME="cpe:/o:centos:centos:7"
16
- HOME_URL="https://www.centos.org/"
17
- BUG_REPORT_URL="https://bugs.centos.org/"
18
- """)
19
-
20
- str_centos_7_os_release_newer = dedent("""
21
- NAME="CentOS Linux"
22
- VERSION="7 (Core)"
23
- ID="centos"
24
- ID_LIKE="rhel fedora"
25
- VERSION_ID="7"
26
- PRETTY_NAME="CentOS Linux 7 (Core)"
27
- ANSI_COLOR="0;31"
28
- CPE_NAME="cpe:/o:centos:centos:7"
29
- HOME_URL="https://www.centos.org/"
30
- BUG_REPORT_URL="https://bugs.centos.org/"
31
-
32
- CENTOS_MANTISBT_PROJECT="CentOS-7"
33
- CENTOS_MANTISBT_PROJECT_VERSION="7"
34
- REDHAT_SUPPORT_PRODUCT="centos"
35
- REDHAT_SUPPORT_PRODUCT_VERSION="7"
36
- """)
37
-
38
- str_debian_7_lsb_release = dedent("""
39
- Distributor ID: Debian
40
- Description: Debian GNU/Linux 7.1 (wheezy)
41
- Release: 7.1
42
- Codename: wheezy
43
- """)
44
-
45
- str_debian_7_os_release = dedent("""
46
- PRETTY_NAME="Debian GNU/Linux 7 (wheezy)"
47
- NAME="Debian GNU/Linux"
48
- VERSION_ID="7"
49
- VERSION="7 (wheezy)"
50
- ID=debian
51
- ANSI_COLOR="1;31"
52
- HOME_URL="http://www.debian.org/"
53
- SUPPORT_URL="http://www.debian.org/support/"
54
- BUG_REPORT_URL="http://bugs.debian.org/"
55
- """)
56
-
57
- str_debian_8_os_release = dedent("""
58
- PRETTY_NAME="Debian GNU/Linux 8 (jessie)"
59
- NAME="Debian GNU/Linux"
60
- VERSION_ID="8"
61
- VERSION="8 (jessie)"
62
- ID=debian
63
- HOME_URL="http://www.debian.org/"
64
- SUPPORT_URL="http://www.debian.org/support/"
65
- BUG_REPORT_URL="https://bugs.debian.org/"
66
- """)
67
-
68
- str_debian_9_os_release = dedent("""
69
- PRETTY_NAME="Debian GNU/Linux 9 (stretch)"
70
- NAME="Debian GNU/Linux"
71
- VERSION_ID="9"
72
- VERSION="9 (stretch)"
73
- ID=debian
74
- HOME_URL="https://www.debian.org/"
75
- SUPPORT_URL="https://www.debian.org/support"
76
- BUG_REPORT_URL="https://bugs.debian.org/"
77
- """)
78
-
79
- str_ubuntu_12_04_lsb_release = dedent("""
80
- Distributor ID: Ubuntu
81
- Description: Ubuntu 12.04.4 LTS
82
- Release: 12.04
83
- Codename: precise
84
- """)
85
-
86
- str_ubuntu_12_04_os_release = dedent("""
87
- NAME="Ubuntu"
88
- VERSION="12.04.4 LTS, Precise Pangolin"
89
- ID=ubuntu
90
- ID_LIKE=debian
91
- PRETTY_NAME="Ubuntu precise (12.04.4 LTS)"
92
- VERSION_ID="12.04"
93
- """)
94
-
95
- str_ubuntu_14_04_os_release = dedent("""
96
- NAME="Ubuntu"
97
- VERSION="14.04.4 LTS, Trusty Tahr"
98
- ID=ubuntu
99
- ID_LIKE=debian
100
- PRETTY_NAME="Ubuntu 14.04.4 LTS"
101
- VERSION_ID="14.04"
102
- HOME_URL="http://www.ubuntu.com/"
103
- SUPPORT_URL="http://help.ubuntu.com/"
104
- BUG_REPORT_URL="http://bugs.launchpad.net/ubuntu/"
105
- """)
106
-
107
- str_ubuntu_16_04_os_release = dedent("""
108
- NAME="Ubuntu"
109
- VERSION="16.04 LTS (Xenial Xerus)"
110
- ID=ubuntu
111
- ID_LIKE=debian
112
- PRETTY_NAME="Ubuntu 16.04 LTS"
113
- VERSION_ID="16.04"
114
- HOME_URL="http://www.ubuntu.com/"
115
- SUPPORT_URL="http://help.ubuntu.com/"
116
- BUG_REPORT_URL="http://bugs.launchpad.net/ubuntu/"
117
- UBUNTU_CODENAME=xenial
118
- """)
119
-
120
- str_ubuntu_18_04_os_release = dedent("""
121
- NAME="Ubuntu"
122
- VERSION="18.04 LTS (Bionic Beaver)"
123
- ID=ubuntu
124
- ID_LIKE=debian
125
- PRETTY_NAME="Ubuntu 18.04 LTS"
126
- VERSION_ID="18.04"
127
- HOME_URL="https://www.ubuntu.com/"
128
- SUPPORT_URL="https://help.ubuntu.com/"
129
- BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
130
- PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
131
- VERSION_CODENAME=bionic
132
- UBUNTU_CODENAME=bionic
133
- """)
134
-
135
- str_rhel_6_4_lsb_release = dedent("""
136
- LSB Version: :base-4.0-amd64:base-4.0-noarch:core-4.0-amd64:core-4.0-noarch:graphics-4.0-amd64:graphics-4.0-noarch:printing-4.0-amd64:printing-4.0-noarch
137
- Distributor ID: RedHatEnterpriseServer
138
- Description: Red Hat Enterprise Linux Server release 6.4 (Santiago)
139
- Release: 6.4
140
- Codename: Santiago
141
- """)
142
-
143
- str_rhel_7_lsb_release = dedent("""
144
- LSB Version: :core-4.1-amd64:core-4.1-noarch:cxx-4.1-amd64:cxx-4.1-noarch:desktop-4.1-amd64:desktop-4.1-noarch:languages-4.1-amd64:languages-4.1-noarch:printing-4.1-amd64:printing-4.1-noarch
145
- Distributor ID: RedHatEnterpriseServer
146
- Description: Red Hat Enterprise Linux Server release 7.0 (Maipo)
147
- Release: 7.0
148
- Codename: Maipo
149
- """)
150
-
151
- str_rhel_7_os_release = dedent("""
152
- NAME="Red Hat Enterprise Linux Server"
153
- VERSION="7.0 (Maipo)"
154
- ID="rhel"
155
- ID_LIKE="fedora"
156
- VERSION_ID="7.0"
157
- PRETTY_NAME="Red Hat Enterprise Linux Server 7.0 (Maipo)"
158
- ANSI_COLOR="0;31"
159
- CPE_NAME="cpe:/o:redhat:enterprise_linux:7.0:GA:server"
160
- HOME_URL="https://www.redhat.com/"
161
- BUG_REPORT_URL="https://bugzilla.redhat.com/"
162
-
163
- REDHAT_BUGZILLA_PRODUCT="Red Hat Enterprise Linux 7"
164
- REDHAT_BUGZILLA_PRODUCT_VERSION=7.0
165
- REDHAT_SUPPORT_PRODUCT="Red Hat Enterprise Linux"
166
- REDHAT_SUPPORT_PRODUCT_VERSION=7.0
167
- """)
168
-
169
- str_fedora_26_os_release = dedent("""
170
- NAME=Fedora
171
- VERSION="26 (Twenty Six)"
172
- ID=fedora
173
- VERSION_ID=26
174
- PRETTY_NAME="Fedora 26 (Twenty Six)"
175
- ANSI_COLOR="0;34"
176
- CPE_NAME="cpe:/o:fedoraproject:fedora:26"
177
- HOME_URL="https://fedoraproject.org/"
178
- BUG_REPORT_URL="https://bugzilla.redhat.com/"
179
- REDHAT_BUGZILLA_PRODUCT="Fedora"
180
- REDHAT_BUGZILLA_PRODUCT_VERSION=26
181
- REDHAT_SUPPORT_PRODUCT="Fedora"
182
- REDHAT_SUPPORT_PRODUCT_VERSION=26
183
- PRIVACY_POLICY_URL=https://fedoraproject.org/wiki/Legal:PrivacyPolicy
184
- """)
185
-
186
- str_opensuse_42_2_os_release = dedent("""
187
- NAME="openSUSE Leap"
188
- VERSION="42.2"
189
- ID=opensuse
190
- ID_LIKE="suse"
191
- VERSION_ID="42.2"
192
- PRETTY_NAME="openSUSE Leap 42.2"
193
- ANSI_COLOR="0;32"
194
- CPE_NAME="cpe:/o:opensuse:leap:42.2"
195
- BUG_REPORT_URL="https://bugs.opensuse.org"
196
- HOME_URL="https://www.opensuse.org/"
197
- """)
198
-
199
- str_opensuse_42_3_os_release = dedent("""
200
- NAME="openSUSE Leap"
201
- VERSION="42.3"
202
- ID=opensuse
203
- ID_LIKE="suse"
204
- VERSION_ID="42.3"
205
- PRETTY_NAME="openSUSE Leap 42.3"
206
- ANSI_COLOR="0;32"
207
- CPE_NAME="cpe:/o:opensuse:leap:42.3"
208
- BUG_REPORT_URL="https://bugs.opensuse.org"
209
- HOME_URL="https://www.opensuse.org/"
210
- """)
211
-
212
- str_opensuse_15_0_os_release = dedent("""
213
- NAME="openSUSE Leap"
214
- VERSION="15.0"
215
- ID="opensuse-leap"
216
- ID_LIKE="suse opensuse"
217
- VERSION_ID="15.0"
218
- PRETTY_NAME="openSUSE Leap 15.0"
219
- ANSI_COLOR="0;32"
220
- CPE_NAME="cpe:/o:opensuse:leap:15.0"
221
- BUG_REPORT_URL="https://bugs.opensuse.org"
222
- HOME_URL="https://www.opensuse.org/"
223
- """)
224
-
225
- str_opensuse_15_1_os_release = dedent("""
226
- NAME="openSUSE Leap"
227
- VERSION="15.1"
228
- ID="opensuse-leap"
229
- ID_LIKE="suse opensuse"
230
- VERSION_ID="15.1"
231
- PRETTY_NAME="openSUSE Leap 15.1"
232
- ANSI_COLOR="0;32"
233
- CPE_NAME="cpe:/o:opensuse:leap:15.1"
234
- BUG_REPORT_URL="https://bugs.opensuse.org"
235
- HOME_URL="https://www.opensuse.org/"
236
- """)
237
-
238
- def test_centos_7_os_release(self):
239
- os = OS.from_os_release(self.str_centos_7_os_release)
240
- assert os.name == 'centos'
241
- assert os.version == '7'
242
- assert os.codename == 'core'
243
- assert os.package_type == 'rpm'
244
-
245
- def test_centos_7_os_release_newer(self):
246
- os = OS.from_os_release(self.str_centos_7_os_release_newer)
247
- assert os.name == 'centos'
248
- assert os.version == '7'
249
- assert os.codename == 'core'
250
- assert os.package_type == 'rpm'
251
-
252
- def test_debian_7_lsb_release(self):
253
- os = OS.from_lsb_release(self.str_debian_7_lsb_release)
254
- assert os.name == 'debian'
255
- assert os.version == '7.1'
256
- assert os.codename == 'wheezy'
257
- assert os.package_type == 'deb'
258
-
259
- def test_debian_7_os_release(self):
260
- os = OS.from_os_release(self.str_debian_7_os_release)
261
- assert os.name == 'debian'
262
- assert os.version == '7'
263
- assert os.codename == 'wheezy'
264
- assert os.package_type == 'deb'
265
-
266
- def test_debian_8_os_release(self):
267
- os = OS.from_os_release(self.str_debian_8_os_release)
268
- assert os.name == 'debian'
269
- assert os.version == '8'
270
- assert os.codename == 'jessie'
271
- assert os.package_type == 'deb'
272
-
273
- def test_debian_9_os_release(self):
274
- os = OS.from_os_release(self.str_debian_9_os_release)
275
- assert os.name == 'debian'
276
- assert os.version == '9'
277
- assert os.codename == 'stretch'
278
- assert os.package_type == 'deb'
279
-
280
- def test_ubuntu_12_04_lsb_release(self):
281
- os = OS.from_lsb_release(self.str_ubuntu_12_04_lsb_release)
282
- assert os.name == 'ubuntu'
283
- assert os.version == '12.04'
284
- assert os.codename == 'precise'
285
- assert os.package_type == 'deb'
286
-
287
- def test_ubuntu_12_04_os_release(self):
288
- os = OS.from_os_release(self.str_ubuntu_12_04_os_release)
289
- assert os.name == 'ubuntu'
290
- assert os.version == '12.04'
291
- assert os.codename == 'precise'
292
- assert os.package_type == 'deb'
293
-
294
- def test_ubuntu_14_04_os_release(self):
295
- os = OS.from_os_release(self.str_ubuntu_14_04_os_release)
296
- assert os.name == 'ubuntu'
297
- assert os.version == '14.04'
298
- assert os.codename == 'trusty'
299
- assert os.package_type == 'deb'
300
-
301
- def test_ubuntu_16_04_os_release(self):
302
- os = OS.from_os_release(self.str_ubuntu_16_04_os_release)
303
- assert os.name == 'ubuntu'
304
- assert os.version == '16.04'
305
- assert os.codename == 'xenial'
306
- assert os.package_type == 'deb'
307
-
308
- def test_ubuntu_18_04_os_release(self):
309
- os = OS.from_os_release(self.str_ubuntu_18_04_os_release)
310
- assert os.name == 'ubuntu'
311
- assert os.version == '18.04'
312
- assert os.codename == 'bionic'
313
- assert os.package_type == 'deb'
314
-
315
- def test_rhel_6_4_lsb_release(self):
316
- os = OS.from_lsb_release(self.str_rhel_6_4_lsb_release)
317
- assert os.name == 'rhel'
318
- assert os.version == '6.4'
319
- assert os.codename == 'santiago'
320
- assert os.package_type == 'rpm'
321
-
322
- def test_rhel_7_lsb_release(self):
323
- os = OS.from_lsb_release(self.str_rhel_7_lsb_release)
324
- assert os.name == 'rhel'
325
- assert os.version == '7.0'
326
- assert os.codename == 'maipo'
327
- assert os.package_type == 'rpm'
328
-
329
- def test_rhel_7_os_release(self):
330
- os = OS.from_os_release(self.str_rhel_7_os_release)
331
- assert os.name == 'rhel'
332
- assert os.version == '7.0'
333
- assert os.codename == 'maipo'
334
- assert os.package_type == 'rpm'
335
-
336
- def test_fedora_26_os_release(self):
337
- os = OS.from_os_release(self.str_fedora_26_os_release)
338
- assert os.name == 'fedora'
339
- assert os.version == '26'
340
- assert os.codename == '26'
341
- assert os.package_type == 'rpm'
342
-
343
- def test_opensuse_42_2_os_release(self):
344
- os = OS.from_os_release(self.str_opensuse_42_2_os_release)
345
- assert os.name == 'opensuse'
346
- assert os.version == '42.2'
347
- assert os.codename == 'leap'
348
- assert os.package_type == 'rpm'
349
-
350
- def test_opensuse_42_3_os_release(self):
351
- os = OS.from_os_release(self.str_opensuse_42_3_os_release)
352
- assert os.name == 'opensuse'
353
- assert os.version == '42.3'
354
- assert os.codename == 'leap'
355
- assert os.package_type == 'rpm'
356
-
357
- def test_opensuse_15_0_os_release(self):
358
- os = OS.from_os_release(self.str_opensuse_15_0_os_release)
359
- assert os.name == 'opensuse'
360
- assert os.version == '15.0'
361
- assert os.codename == 'leap'
362
- assert os.package_type == 'rpm'
363
-
364
- def test_opensuse_15_1_os_release(self):
365
- os = OS.from_os_release(self.str_opensuse_15_1_os_release)
366
- assert os.name == 'opensuse'
367
- assert os.version == '15.1'
368
- assert os.codename == 'leap'
369
- assert os.package_type == 'rpm'
370
-
371
- def test_version_codename_success(self):
372
- assert OS.version_codename('ubuntu', '14.04') == ('14.04', 'trusty')
373
- assert OS.version_codename('ubuntu', 'trusty') == ('14.04', 'trusty')
374
-
375
- def test_version_codename_failure(self):
376
- with pytest.raises(KeyError) as excinfo:
377
- OS.version_codename('ubuntu', 'frog')
378
- assert excinfo.type == KeyError
379
- assert 'frog' in excinfo.value.args[0]
380
-
381
- def test_repr(self):
382
- os = OS(name='NAME', version='0.1.2', codename='code')
383
- assert repr(os) == "OS(name='NAME', version='0.1.2', codename='code')"
384
-
385
- def test_to_dict(self):
386
- os = OS(name='NAME', version='0.1.2', codename='code')
387
- ref_dict = dict(name='NAME', version='0.1.2', codename='code')
388
- assert os.to_dict() == ref_dict
389
-
390
- def test_version_no_codename(self):
391
- os = OS(name='ubuntu', version='16.04')
392
- assert os.codename == 'xenial'
393
-
394
- def test_codename_no_version(self):
395
- os = OS(name='ubuntu', codename='trusty')
396
- assert os.version == '14.04'
397
-
398
- def test_eq_equal(self):
399
- os = OS(name='ubuntu', codename='trusty', version='14.04')
400
- assert OS(name='ubuntu', codename='trusty', version='14.04') == os
401
-
402
- def test_eq_not_equal(self):
403
- os = OS(name='ubuntu', codename='trusty', version='16.04')
404
- assert OS(name='ubuntu', codename='trusty', version='14.04') != os
@@ -1,185 +0,0 @@
1
- from mock import patch, Mock, MagicMock
2
-
3
- from io import BytesIO
4
-
5
- from teuthology.orchestra import remote
6
- from teuthology.orchestra import opsys
7
- from teuthology.orchestra.run import RemoteProcess
8
-
9
-
10
- class TestRemote(object):
11
-
12
- def setup(self):
13
- self.start_patchers()
14
-
15
- def teardown(self):
16
- self.stop_patchers()
17
-
18
- def start_patchers(self):
19
- self.m_ssh = MagicMock()
20
- self.patcher_ssh = patch(
21
- 'teuthology.orchestra.connection.paramiko.SSHClient',
22
- self.m_ssh,
23
- )
24
- self.patcher_ssh.start()
25
-
26
- def stop_patchers(self):
27
- self.patcher_ssh.stop()
28
-
29
- def test_shortname(self):
30
- r = remote.Remote(
31
- name='jdoe@xyzzy.example.com',
32
- shortname='xyz',
33
- ssh=self.m_ssh,
34
- )
35
- assert r.shortname == 'xyz'
36
- assert str(r) == 'jdoe@xyzzy.example.com'
37
-
38
- def test_shortname_default(self):
39
- r = remote.Remote(
40
- name='jdoe@xyzzy.example.com',
41
- ssh=self.m_ssh,
42
- )
43
- assert r.shortname == 'xyzzy'
44
- assert str(r) == 'jdoe@xyzzy.example.com'
45
-
46
- def test_run(self):
47
- m_transport = MagicMock()
48
- m_transport.getpeername.return_value = ('name', 22)
49
- self.m_ssh.get_transport.return_value = m_transport
50
- m_run = MagicMock()
51
- args = [
52
- 'something',
53
- 'more',
54
- ]
55
- proc = RemoteProcess(
56
- client=self.m_ssh,
57
- args=args,
58
- )
59
- m_run.return_value = proc
60
- rem = remote.Remote(name='jdoe@xyzzy.example.com', ssh=self.m_ssh)
61
- rem._runner = m_run
62
- result = rem.run(args=args)
63
- assert m_transport.getpeername.called_once_with()
64
- assert m_run.called_once_with(args=args)
65
- assert result is proc
66
- assert result.remote is rem
67
-
68
- def test_hostname(self):
69
- m_transport = MagicMock()
70
- m_transport.getpeername.return_value = ('name', 22)
71
- self.m_ssh.get_transport.return_value = m_transport
72
- m_run = MagicMock()
73
- args = [
74
- 'hostname',
75
- '--fqdn',
76
- ]
77
- stdout = BytesIO(b'test_hostname')
78
- stdout.seek(0)
79
- proc = RemoteProcess(
80
- client=self.m_ssh,
81
- args=args,
82
- )
83
- proc.stdout = stdout
84
- proc._stdout_buf = Mock()
85
- proc._stdout_buf.channel.recv_exit_status.return_value = 0
86
- r = remote.Remote(name='xyzzy.example.com', ssh=self.m_ssh)
87
- m_run.return_value = proc
88
- r._runner = m_run
89
- assert r.hostname == 'test_hostname'
90
-
91
- def test_arch(self):
92
- m_transport = MagicMock()
93
- m_transport.getpeername.return_value = ('name', 22)
94
- self.m_ssh.get_transport.return_value = m_transport
95
- m_run = MagicMock()
96
- args = [
97
- 'uname',
98
- '-m',
99
- ]
100
- stdout = BytesIO(b'test_arch')
101
- stdout.seek(0)
102
- proc = RemoteProcess(
103
- client=self.m_ssh,
104
- args='fakey',
105
- )
106
- proc._stdout_buf = Mock()
107
- proc._stdout_buf.channel = Mock()
108
- proc._stdout_buf.channel.recv_exit_status.return_value = 0
109
- proc._stdout_buf.channel.expects('recv_exit_status').returns(0)
110
- proc.stdout = stdout
111
- m_run.return_value = proc
112
- r = remote.Remote(name='jdoe@xyzzy.example.com', ssh=self.m_ssh)
113
- r._runner = m_run
114
- assert m_transport.getpeername.called_once_with()
115
- assert proc._stdout_buf.channel.recv_exit_status.called_once_with()
116
- assert m_run.called_once_with(
117
- client=self.m_ssh,
118
- args=args,
119
- stdout=BytesIO(),
120
- name=r.shortname,
121
- )
122
- assert r.arch == 'test_arch'
123
-
124
- def test_host_key(self):
125
- m_key = MagicMock()
126
- m_key.get_name.return_value = 'key_type'
127
- m_key.get_base64.return_value = 'test ssh key'
128
- m_transport = MagicMock()
129
- m_transport.get_remote_server_key.return_value = m_key
130
- self.m_ssh.get_transport.return_value = m_transport
131
- r = remote.Remote(name='jdoe@xyzzy.example.com', ssh=self.m_ssh)
132
- assert r.host_key == 'key_type test ssh key'
133
- self.m_ssh.get_transport.assert_called_once_with()
134
- m_transport.get_remote_server_key.assert_called_once_with()
135
-
136
- def test_inventory_info(self):
137
- r = remote.Remote('user@host', host_key='host_key')
138
- r._arch = 'arch'
139
- r._os = opsys.OS(name='os_name', version='1.2.3', codename='code')
140
- inv_info = r.inventory_info
141
- assert inv_info == dict(
142
- name='host',
143
- user='user',
144
- arch='arch',
145
- os_type='os_name',
146
- os_version='1.2',
147
- ssh_pub_key='host_key',
148
- up=True,
149
- )
150
-
151
- def test_sftp_open_file(self):
152
- m_file_obj = MagicMock()
153
- m_stat = Mock()
154
- m_stat.st_size = 42
155
- m_file_obj.stat.return_value = m_stat
156
- m_open = MagicMock()
157
- m_open.return_value = m_file_obj
158
- m_open.return_value.__enter__.return_value = m_file_obj
159
- with patch.object(remote.Remote, '_sftp_open_file', new=m_open):
160
- rem = remote.Remote(name='jdoe@xyzzy.example.com', ssh=self.m_ssh)
161
- assert rem._sftp_open_file('x') is m_file_obj
162
- assert rem._sftp_open_file('x').stat() is m_stat
163
- assert rem._sftp_open_file('x').stat().st_size == 42
164
- with rem._sftp_open_file('x') as f:
165
- assert f == m_file_obj
166
-
167
- def test_sftp_get_size(self):
168
- m_file_obj = MagicMock()
169
- m_stat = Mock()
170
- m_stat.st_size = 42
171
- m_file_obj.stat.return_value = m_stat
172
- m_open = MagicMock()
173
- m_open.return_value = m_file_obj
174
- m_open.return_value.__enter__.return_value = m_file_obj
175
- with patch.object(remote.Remote, '_sftp_open_file', new=m_open):
176
- rem = remote.Remote(name='jdoe@xyzzy.example.com', ssh=self.m_ssh)
177
- assert rem._sftp_get_size('/fake/file') == 42
178
-
179
- def test_format_size(self):
180
- assert remote.Remote._format_size(1023).strip() == '1023B'
181
- assert remote.Remote._format_size(1024).strip() == '1KB'
182
- assert remote.Remote._format_size(1024**2).strip() == '1MB'
183
- assert remote.Remote._format_size(1024**5).strip() == '1TB'
184
- assert remote.Remote._format_size(1021112).strip() == '997KB'
185
- assert remote.Remote._format_size(1021112**2).strip() == '971GB'