145
150
def test_get_package_mirror_info_az_ec2(self):
146
151
arch_mirrors = gapmi(package_mirrors, arch="amd64")
152
data_source_mock = mock.Mock(availability_zone="us-east-1a")
148
results = gpmi(arch_mirrors, availability_zone="us-east-1a",
154
results = gpmi(arch_mirrors, data_source=data_source_mock,
149
155
mirror_filter=self.return_first)
150
156
self.assertEqual(results,
151
157
{'primary': 'http://us-east-1.ec2/',
152
158
'security': 'http://security-mirror1-intel'})
154
results = gpmi(arch_mirrors, availability_zone="us-east-1a",
160
results = gpmi(arch_mirrors, data_source=data_source_mock,
155
161
mirror_filter=self.return_second)
156
162
self.assertEqual(results,
157
163
{'primary': 'http://us-east-1a.clouds/',
158
164
'security': 'http://security-mirror2-intel'})
160
results = gpmi(arch_mirrors, availability_zone="us-east-1a",
166
results = gpmi(arch_mirrors, data_source=data_source_mock,
161
167
mirror_filter=self.return_none)
162
168
self.assertEqual(results, package_mirrors[0]['failsafe'])
164
170
def test_get_package_mirror_info_az_non_ec2(self):
165
171
arch_mirrors = gapmi(package_mirrors, arch="amd64")
172
data_source_mock = mock.Mock(availability_zone="nova.cloudvendor")
167
results = gpmi(arch_mirrors, availability_zone="nova.cloudvendor",
174
results = gpmi(arch_mirrors, data_source=data_source_mock,
168
175
mirror_filter=self.return_first)
169
176
self.assertEqual(results,
170
177
{'primary': 'http://nova.cloudvendor.clouds/',
171
178
'security': 'http://security-mirror1-intel'})
173
results = gpmi(arch_mirrors, availability_zone="nova.cloudvendor",
180
results = gpmi(arch_mirrors, data_source=data_source_mock,
174
181
mirror_filter=self.return_last)
175
182
self.assertEqual(results,
176
183
{'primary': 'http://nova.cloudvendor.clouds/',
179
186
def test_get_package_mirror_info_none(self):
180
187
arch_mirrors = gapmi(package_mirrors, arch="amd64")
188
data_source_mock = mock.Mock(availability_zone=None)
182
190
# because both search entries here replacement based on
183
191
# availability-zone, the filter will be called with an empty list and
184
192
# failsafe should be taken.
185
results = gpmi(arch_mirrors, availability_zone=None,
193
results = gpmi(arch_mirrors, data_source=data_source_mock,
186
194
mirror_filter=self.return_first)
187
195
self.assertEqual(results,
188
196
{'primary': 'http://fs-primary-intel',
189
197
'security': 'http://security-mirror1-intel'})
191
results = gpmi(arch_mirrors, availability_zone=None,
199
results = gpmi(arch_mirrors, data_source=data_source_mock,
192
200
mirror_filter=self.return_last)
193
201
self.assertEqual(results,
194
202
{'primary': 'http://fs-primary-intel',
195
203
'security': 'http://security-mirror2-intel'})
205
def test_systemd_in_use(self):
206
cls = distros.fetch("ubuntu")
207
d = cls("ubuntu", {}, None)
208
self.patchOS(self.tmp)
209
self.patchUtils(self.tmp)
210
os.makedirs('/run/systemd/system')
211
self.assertTrue(d.uses_systemd())
213
def test_systemd_not_in_use(self):
214
cls = distros.fetch("ubuntu")
215
d = cls("ubuntu", {}, None)
216
self.patchOS(self.tmp)
217
self.patchUtils(self.tmp)
218
self.assertFalse(d.uses_systemd())
220
def test_systemd_symlink(self):
221
cls = distros.fetch("ubuntu")
222
d = cls("ubuntu", {}, None)
223
self.patchOS(self.tmp)
224
self.patchUtils(self.tmp)
225
os.makedirs('/run/systemd')
226
os.symlink('/', '/run/systemd/system')
227
self.assertFalse(d.uses_systemd())
198
229
# def _get_package_mirror_info(mirror_info, availability_zone=None,
199
230
# mirror_filter=util.search_for_mirror):