2016-06-20 13:43:55 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
|
|
|
import mock
|
|
|
|
import json
|
|
|
|
|
2017-01-04 08:35:31 +00:00
|
|
|
import copy
|
2016-06-20 13:43:55 +00:00
|
|
|
import os
|
|
|
|
import sys
|
|
|
|
|
|
|
|
sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..'))
|
|
|
|
|
|
|
|
from tests import helpers
|
2017-01-04 08:35:31 +00:00
|
|
|
from pungi import checks
|
2016-06-20 13:43:55 +00:00
|
|
|
from pungi.phases import osbs
|
|
|
|
|
|
|
|
|
|
|
|
class OSBSPhaseTest(helpers.PungiTestCase):
|
|
|
|
|
|
|
|
@mock.patch('pungi.phases.osbs.ThreadPool')
|
|
|
|
def test_run(self, ThreadPool):
|
2017-03-27 21:53:08 +00:00
|
|
|
cfg = helpers.IterableMock()
|
2016-06-20 13:43:55 +00:00
|
|
|
compose = helpers.DummyCompose(self.topdir, {
|
|
|
|
'osbs': {'^Everything$': cfg}
|
|
|
|
})
|
|
|
|
|
|
|
|
pool = ThreadPool.return_value
|
|
|
|
|
|
|
|
phase = osbs.OSBSPhase(compose)
|
|
|
|
phase.run()
|
|
|
|
|
|
|
|
self.assertEqual(len(pool.add.call_args_list), 1)
|
|
|
|
self.assertEqual(pool.queue_put.call_args_list,
|
|
|
|
[mock.call((compose, compose.variants['Everything'], cfg))])
|
|
|
|
|
|
|
|
@mock.patch('pungi.phases.osbs.ThreadPool')
|
|
|
|
def test_skip_without_config(self, ThreadPool):
|
|
|
|
compose = helpers.DummyCompose(self.topdir, {})
|
|
|
|
compose.just_phases = None
|
|
|
|
compose.skip_phases = []
|
|
|
|
phase = osbs.OSBSPhase(compose)
|
|
|
|
self.assertTrue(phase.skip())
|
|
|
|
|
|
|
|
@mock.patch('pungi.phases.osbs.ThreadPool')
|
|
|
|
def test_dump_metadata(self, ThreadPool):
|
|
|
|
compose = helpers.DummyCompose(self.topdir, {
|
|
|
|
'osbs': {'^Everything$': {}}
|
|
|
|
})
|
|
|
|
compose.just_phases = None
|
|
|
|
compose.skip_phases = []
|
|
|
|
compose.notifier = mock.Mock()
|
|
|
|
phase = osbs.OSBSPhase(compose)
|
|
|
|
phase.start()
|
|
|
|
phase.stop()
|
|
|
|
phase.pool.metadata = METADATA
|
|
|
|
phase.dump_metadata()
|
|
|
|
|
|
|
|
with open(self.topdir + '/compose/metadata/osbs.json') as f:
|
|
|
|
data = json.load(f)
|
|
|
|
self.assertEqual(data, METADATA)
|
|
|
|
|
|
|
|
@mock.patch('pungi.phases.osbs.ThreadPool')
|
|
|
|
def test_dump_metadata_after_skip(self, ThreadPool):
|
|
|
|
compose = helpers.DummyCompose(self.topdir, {})
|
|
|
|
compose.just_phases = None
|
|
|
|
compose.skip_phases = []
|
|
|
|
phase = osbs.OSBSPhase(compose)
|
|
|
|
phase.start()
|
|
|
|
phase.stop()
|
|
|
|
phase.dump_metadata()
|
|
|
|
|
|
|
|
self.assertFalse(os.path.isfile(self.topdir + '/compose/metadata/osbs.json'))
|
|
|
|
|
2019-02-07 13:17:09 +00:00
|
|
|
@mock.patch("pungi.phases.osbs.ThreadPool")
|
|
|
|
def test_request_push(self, ThreadPool):
|
|
|
|
compose = helpers.DummyCompose(self.topdir, {
|
|
|
|
"osbs": {"^Everything$": {}}
|
|
|
|
})
|
|
|
|
compose.just_phases = None
|
|
|
|
compose.skip_phases = []
|
|
|
|
compose.notifier = mock.Mock()
|
|
|
|
phase = osbs.OSBSPhase(compose)
|
|
|
|
phase.start()
|
|
|
|
phase.stop()
|
|
|
|
phase.pool.registries = {"foo": "bar"}
|
|
|
|
phase.request_push()
|
|
|
|
|
|
|
|
with open(os.path.join(self.topdir, "logs/global/osbs-registries.json")) as f:
|
|
|
|
data = json.load(f)
|
|
|
|
self.assertEqual(data, phase.pool.registries)
|
|
|
|
|
|
|
|
self.assertEqual(
|
|
|
|
compose.notifier.call_args_list,
|
|
|
|
[],
|
|
|
|
)
|
|
|
|
|
2016-06-20 13:43:55 +00:00
|
|
|
|
|
|
|
TASK_RESULT = {
|
|
|
|
'koji_builds': ['54321'],
|
|
|
|
'repositories': [
|
|
|
|
'registry.example.com:8888/rcm/buildroot:f24-docker-candidate-20160617141632',
|
|
|
|
]
|
|
|
|
}
|
|
|
|
|
|
|
|
BUILD_INFO = {
|
|
|
|
'completion_time': '2016-06-17 18:25:30',
|
|
|
|
'completion_ts': 1466187930.0,
|
|
|
|
'creation_event_id': 13227702,
|
|
|
|
'creation_time': '2016-06-17 18:25:57.611172',
|
|
|
|
'creation_ts': 1466187957.61117,
|
|
|
|
'epoch': None,
|
|
|
|
'extra': {'container_koji_task_id': '12345', 'image': {}},
|
|
|
|
'id': 54321,
|
|
|
|
'name': 'my-name',
|
|
|
|
'nvr': 'my-name-1.0-1',
|
|
|
|
'owner_id': 3436,
|
|
|
|
'owner_name': 'osbs',
|
|
|
|
'package_id': 50072,
|
|
|
|
'package_name': 'my-name',
|
|
|
|
'release': '1',
|
|
|
|
'source': 'git://example.com/repo?#BEEFCAFE',
|
|
|
|
'start_time': '2016-06-17 18:16:37',
|
|
|
|
'start_ts': 1466187397.0,
|
|
|
|
'state': 1,
|
|
|
|
'task_id': None,
|
|
|
|
'version': '1.0',
|
|
|
|
'volume_id': 0,
|
|
|
|
'volume_name': 'DEFAULT'
|
|
|
|
}
|
|
|
|
|
|
|
|
ARCHIVES = [
|
|
|
|
{'build_id': 54321,
|
|
|
|
'buildroot_id': 2955357,
|
|
|
|
'checksum': 'a2922842dc80873ac782da048c54f6cc',
|
|
|
|
'checksum_type': 0,
|
|
|
|
'extra': {
|
|
|
|
'docker': {
|
|
|
|
'id': '408c4cd37a87a807bec65dd13b049a32fe090d2fa1a8e891f65e3e3e683996d7',
|
|
|
|
'parent_id': '6c3a84d798dc449313787502060b6d5b4694d7527d64a7c99ba199e3b2df834e',
|
|
|
|
'repositories': ['registry.example.com:8888/rcm/buildroot:1.0-1']},
|
|
|
|
'image': {'arch': 'x86_64'}},
|
|
|
|
'filename': 'docker-image-408c4cd37a87a807bec65dd13b049a32fe090d2fa1a8e891f65e3e3e683996d7.x86_64.tar.gz',
|
|
|
|
'id': 1436049,
|
|
|
|
'metadata_only': False,
|
|
|
|
'size': 174038795,
|
|
|
|
'type_description': 'Tar file',
|
|
|
|
'type_extensions': 'tar tar.gz tar.bz2 tar.xz',
|
|
|
|
'type_id': 4,
|
|
|
|
'type_name': 'tar'}
|
|
|
|
]
|
|
|
|
|
|
|
|
METADATA = {
|
|
|
|
'Server': {'x86_64': [{
|
|
|
|
'name': 'my-name',
|
|
|
|
'version': '1.0',
|
|
|
|
'release': '1',
|
2018-05-28 11:15:24 +00:00
|
|
|
'nvr': 'my-name-1.0-1',
|
2016-06-20 13:43:55 +00:00
|
|
|
'creation_time': BUILD_INFO['creation_time'],
|
|
|
|
'filename': ARCHIVES[0]['filename'],
|
|
|
|
'size': ARCHIVES[0]['size'],
|
|
|
|
'docker': {
|
|
|
|
'id': '408c4cd37a87a807bec65dd13b049a32fe090d2fa1a8e891f65e3e3e683996d7',
|
|
|
|
'parent_id': '6c3a84d798dc449313787502060b6d5b4694d7527d64a7c99ba199e3b2df834e',
|
|
|
|
'repositories': ['registry.example.com:8888/rcm/buildroot:1.0-1']},
|
|
|
|
'image': {'arch': 'x86_64'},
|
|
|
|
'checksum': ARCHIVES[0]['checksum'],
|
|
|
|
}]}
|
|
|
|
}
|
|
|
|
|
2017-03-02 13:10:16 +00:00
|
|
|
SCRATCH_TASK_RESULT = {
|
|
|
|
'koji_builds': [],
|
|
|
|
'repositories': [
|
|
|
|
'registry.example.com:8888/rcm/buildroot:f24-docker-candidate-20160617141632',
|
|
|
|
]
|
|
|
|
}
|
|
|
|
|
|
|
|
SCRATCH_METADATA = {
|
|
|
|
"Server": {'scratch': [{
|
|
|
|
"koji_task": 12345,
|
|
|
|
"repositories": [
|
|
|
|
'registry.example.com:8888/rcm/buildroot:f24-docker-candidate-20160617141632',
|
|
|
|
]
|
|
|
|
}]}
|
|
|
|
}
|
|
|
|
|
2016-06-20 13:43:55 +00:00
|
|
|
|
|
|
|
class OSBSThreadTest(helpers.PungiTestCase):
|
|
|
|
|
|
|
|
def setUp(self):
|
|
|
|
super(OSBSThreadTest, self).setUp()
|
2019-02-07 13:17:09 +00:00
|
|
|
self.pool = mock.Mock(metadata={}, registries={})
|
2016-06-20 13:43:55 +00:00
|
|
|
self.t = osbs.OSBSThread(self.pool)
|
|
|
|
self.compose = helpers.DummyCompose(self.topdir, {
|
|
|
|
'koji_profile': 'koji',
|
|
|
|
'translate_paths': [
|
|
|
|
(self.topdir, 'http://root'),
|
|
|
|
]
|
|
|
|
})
|
|
|
|
|
2018-11-21 09:56:22 +00:00
|
|
|
def _setupMock(self, KojiWrapper, scratch=False):
|
2016-06-20 13:43:55 +00:00
|
|
|
self.wrapper = KojiWrapper.return_value
|
|
|
|
self.wrapper.koji_proxy.buildContainer.return_value = 12345
|
2017-03-02 13:10:16 +00:00
|
|
|
if scratch:
|
|
|
|
self.wrapper.koji_proxy.getTaskResult.return_value = SCRATCH_TASK_RESULT
|
|
|
|
else:
|
|
|
|
self.wrapper.koji_proxy.getTaskResult.return_value = TASK_RESULT
|
|
|
|
self.wrapper.koji_proxy.getBuild.return_value = BUILD_INFO
|
|
|
|
self.wrapper.koji_proxy.listArchives.return_value = ARCHIVES
|
2016-06-20 13:43:55 +00:00
|
|
|
self.wrapper.koji_proxy.getLatestBuilds.return_value = [mock.Mock(), mock.Mock()]
|
|
|
|
self.wrapper.koji_proxy.getNextRelease.return_value = 3
|
|
|
|
self.wrapper.watch_task.return_value = 0
|
|
|
|
|
2017-03-02 13:10:16 +00:00
|
|
|
def _assertCorrectMetadata(self, scratch=False):
|
2016-06-20 13:43:55 +00:00
|
|
|
self.maxDiff = None
|
2017-03-02 13:10:16 +00:00
|
|
|
if scratch:
|
|
|
|
metadata = copy.deepcopy(SCRATCH_METADATA)
|
|
|
|
metadata['Server']['scratch'][0]['compose_id'] = self.compose.compose_id
|
|
|
|
metadata['Server']['scratch'][0]['koji_task'] = 12345
|
|
|
|
else:
|
|
|
|
metadata = copy.deepcopy(METADATA)
|
|
|
|
metadata['Server']['x86_64'][0]['compose_id'] = self.compose.compose_id
|
|
|
|
metadata['Server']['x86_64'][0]['koji_task'] = 12345
|
|
|
|
self.assertEqual(self.pool.metadata, metadata)
|
|
|
|
|
|
|
|
def _assertCorrectCalls(self, opts, setupCalls=None, scratch=False):
|
2016-06-20 13:43:55 +00:00
|
|
|
setupCalls = setupCalls or []
|
2018-07-09 09:04:00 +00:00
|
|
|
options = {'yum_repourls': ['http://root/work/global/tmp-Server/compose-rpms-Server-1.repo']}
|
2017-03-02 13:10:16 +00:00
|
|
|
if scratch:
|
|
|
|
options['scratch'] = True
|
2016-06-20 13:43:55 +00:00
|
|
|
options.update(opts)
|
2017-03-02 13:10:16 +00:00
|
|
|
expect_calls = [mock.call.login()] + setupCalls
|
|
|
|
expect_calls.extend([
|
|
|
|
mock.call.koji_proxy.buildContainer(
|
|
|
|
'git://example.com/repo?#BEEFCAFE',
|
|
|
|
'f24-docker-candidate',
|
|
|
|
options,
|
|
|
|
priority=None),
|
|
|
|
mock.call.watch_task(
|
|
|
|
12345, self.topdir + '/logs/global/osbs/Server-1-watch-task.log'),
|
|
|
|
mock.call.koji_proxy.getTaskResult(12345)])
|
|
|
|
|
|
|
|
if not scratch:
|
|
|
|
expect_calls.extend([mock.call.koji_proxy.getBuild(54321),
|
|
|
|
mock.call.koji_proxy.listArchives(54321)])
|
|
|
|
self.assertEqual(self.wrapper.mock_calls, expect_calls)
|
2016-06-20 13:43:55 +00:00
|
|
|
|
2017-01-17 04:54:41 +00:00
|
|
|
def _assertRepoFile(self, variants=None, gpgkey=None):
|
2017-01-04 08:19:25 +00:00
|
|
|
variants = variants or ['Server']
|
|
|
|
for variant in variants:
|
2018-07-09 09:04:00 +00:00
|
|
|
with open(self.topdir + '/work/global/tmp-%s/compose-rpms-%s-1.repo' % (variant, variant)) as f:
|
2017-01-04 08:19:25 +00:00
|
|
|
lines = f.read().split('\n')
|
|
|
|
self.assertIn('baseurl=http://root/compose/%s/$basearch/os' % variant, lines)
|
2017-01-17 04:54:41 +00:00
|
|
|
if gpgkey:
|
|
|
|
self.assertIn('gpgcheck=1', lines)
|
|
|
|
self.assertIn('gpgkey=%s' % gpgkey, lines)
|
2016-06-20 13:43:55 +00:00
|
|
|
|
2017-01-04 08:35:31 +00:00
|
|
|
def _assertConfigCorrect(self, cfg):
|
|
|
|
config = copy.deepcopy(self.compose.conf)
|
|
|
|
config['osbs'] = {
|
|
|
|
'^Server$': cfg
|
|
|
|
}
|
2018-11-21 09:56:22 +00:00
|
|
|
self.assertEqual(([], []), checks.validate(config, offline=True))
|
2017-01-04 08:35:31 +00:00
|
|
|
|
|
|
|
def _assertConfigMissing(self, cfg, key):
|
|
|
|
config = copy.deepcopy(self.compose.conf)
|
|
|
|
config['osbs'] = {
|
|
|
|
'^Server$': cfg
|
|
|
|
}
|
2019-06-25 10:50:07 +00:00
|
|
|
errors, warnings = checks.validate(config, offline=True)
|
|
|
|
self.assertIn(
|
|
|
|
"Failed validation in osbs.^Server$: %r is not valid under any of the given schemas" % cfg,
|
|
|
|
errors,
|
|
|
|
)
|
|
|
|
self.assertIn(" Possible reason: %r is a required property" % key, errors)
|
|
|
|
self.assertEqual([], warnings)
|
2017-01-04 08:35:31 +00:00
|
|
|
|
2016-06-20 13:43:55 +00:00
|
|
|
@mock.patch('pungi.phases.osbs.kojiwrapper.KojiWrapper')
|
2018-11-21 09:56:22 +00:00
|
|
|
def test_minimal_run(self, KojiWrapper):
|
2016-06-20 13:43:55 +00:00
|
|
|
cfg = {
|
2018-11-21 09:56:22 +00:00
|
|
|
'url': 'git://example.com/repo?#BEEFCAFE',
|
2016-06-20 13:43:55 +00:00
|
|
|
'target': 'f24-docker-candidate',
|
2017-04-24 07:55:24 +00:00
|
|
|
'git_branch': 'f24-docker',
|
2016-06-20 13:43:55 +00:00
|
|
|
}
|
2018-11-21 09:56:22 +00:00
|
|
|
self._setupMock(KojiWrapper)
|
2017-01-04 08:35:31 +00:00
|
|
|
self._assertConfigCorrect(cfg)
|
2016-06-20 13:43:55 +00:00
|
|
|
|
|
|
|
self.t.process((self.compose, self.compose.variants['Server'], cfg), 1)
|
|
|
|
|
2017-04-24 07:55:24 +00:00
|
|
|
self._assertCorrectCalls({'git_branch': 'f24-docker'})
|
2016-06-20 13:43:55 +00:00
|
|
|
self._assertCorrectMetadata()
|
2017-01-04 08:19:25 +00:00
|
|
|
self._assertRepoFile()
|
2016-06-20 13:43:55 +00:00
|
|
|
|
2016-06-24 07:44:40 +00:00
|
|
|
@mock.patch('pungi.phases.osbs.kojiwrapper.KojiWrapper')
|
2018-11-21 09:56:22 +00:00
|
|
|
def test_run_failable(self, KojiWrapper):
|
2016-06-24 07:44:40 +00:00
|
|
|
cfg = {
|
2018-11-21 09:56:22 +00:00
|
|
|
'url': 'git://example.com/repo?#BEEFCAFE',
|
2016-06-24 07:44:40 +00:00
|
|
|
'target': 'f24-docker-candidate',
|
2017-04-24 07:55:24 +00:00
|
|
|
'git_branch': 'f24-docker',
|
2016-06-24 07:44:40 +00:00
|
|
|
'failable': ['*']
|
|
|
|
}
|
2018-11-21 09:56:22 +00:00
|
|
|
self._setupMock(KojiWrapper)
|
2017-01-04 08:35:31 +00:00
|
|
|
self._assertConfigCorrect(cfg)
|
2016-06-24 07:44:40 +00:00
|
|
|
|
|
|
|
self.t.process((self.compose, self.compose.variants['Server'], cfg), 1)
|
|
|
|
|
2017-04-24 07:55:24 +00:00
|
|
|
self._assertCorrectCalls({'git_branch': 'f24-docker'})
|
2016-06-24 07:44:40 +00:00
|
|
|
self._assertCorrectMetadata()
|
2017-01-04 08:19:25 +00:00
|
|
|
self._assertRepoFile()
|
2016-06-24 07:44:40 +00:00
|
|
|
|
2016-06-20 13:43:55 +00:00
|
|
|
@mock.patch('pungi.phases.osbs.kojiwrapper.KojiWrapper')
|
2018-11-21 09:56:22 +00:00
|
|
|
def test_run_with_more_args(self, KojiWrapper):
|
2016-06-20 13:43:55 +00:00
|
|
|
cfg = {
|
2018-11-21 09:56:22 +00:00
|
|
|
'url': 'git://example.com/repo?#BEEFCAFE',
|
2016-06-20 13:43:55 +00:00
|
|
|
'target': 'f24-docker-candidate',
|
2017-04-24 07:55:24 +00:00
|
|
|
'git_branch': 'f24-docker',
|
2016-06-20 13:43:55 +00:00
|
|
|
'name': 'my-name',
|
|
|
|
'version': '1.0',
|
|
|
|
}
|
2018-11-21 09:56:22 +00:00
|
|
|
self._setupMock(KojiWrapper)
|
2017-01-04 08:35:31 +00:00
|
|
|
self._assertConfigCorrect(cfg)
|
2016-06-20 13:43:55 +00:00
|
|
|
|
|
|
|
self.t.process((self.compose, self.compose.variants['Server'], cfg), 1)
|
|
|
|
|
2017-04-24 07:55:24 +00:00
|
|
|
self._assertCorrectCalls({'name': 'my-name', 'version': '1.0', 'git_branch': 'f24-docker'})
|
2016-06-20 13:43:55 +00:00
|
|
|
self._assertCorrectMetadata()
|
2017-01-04 08:19:25 +00:00
|
|
|
self._assertRepoFile()
|
2016-06-20 13:43:55 +00:00
|
|
|
|
2017-01-04 08:15:27 +00:00
|
|
|
@mock.patch('pungi.phases.osbs.kojiwrapper.KojiWrapper')
|
2018-11-21 09:56:22 +00:00
|
|
|
def test_run_with_extra_repos(self, KojiWrapper):
|
2017-01-04 08:15:27 +00:00
|
|
|
cfg = {
|
2018-11-21 09:56:22 +00:00
|
|
|
'url': 'git://example.com/repo?#BEEFCAFE',
|
2017-01-04 08:15:27 +00:00
|
|
|
'target': 'f24-docker-candidate',
|
2017-04-24 07:55:24 +00:00
|
|
|
'git_branch': 'f24-docker',
|
2017-01-04 08:15:27 +00:00
|
|
|
'name': 'my-name',
|
|
|
|
'version': '1.0',
|
2019-02-21 10:04:38 +00:00
|
|
|
"repo": ["Everything", "http://pkgs.example.com/my.repo", "/extra/repo"],
|
2017-01-04 08:15:27 +00:00
|
|
|
}
|
2019-02-21 10:04:38 +00:00
|
|
|
self.compose.conf["translate_paths"].append(("/extra", "http://example.com"))
|
2018-11-21 09:56:22 +00:00
|
|
|
self._setupMock(KojiWrapper)
|
2017-01-04 08:35:31 +00:00
|
|
|
self._assertConfigCorrect(cfg)
|
2017-01-04 08:15:27 +00:00
|
|
|
|
|
|
|
self.t.process((self.compose, self.compose.variants['Server'], cfg), 1)
|
|
|
|
|
|
|
|
options = {
|
|
|
|
'name': 'my-name',
|
|
|
|
'version': '1.0',
|
2017-04-24 07:55:24 +00:00
|
|
|
'git_branch': 'f24-docker',
|
2017-01-04 08:15:27 +00:00
|
|
|
'yum_repourls': [
|
2018-07-09 09:04:00 +00:00
|
|
|
'http://root/work/global/tmp-Server/compose-rpms-Server-1.repo',
|
|
|
|
'http://root/work/global/tmp-Everything/compose-rpms-Everything-1.repo',
|
2017-01-04 08:15:27 +00:00
|
|
|
'http://pkgs.example.com/my.repo',
|
2019-02-21 10:04:38 +00:00
|
|
|
"http://root/work/global/tmp/compose-rpms-local-1.repo",
|
2017-01-04 08:15:27 +00:00
|
|
|
]
|
|
|
|
}
|
|
|
|
self._assertCorrectCalls(options)
|
|
|
|
self._assertCorrectMetadata()
|
2017-01-04 08:19:25 +00:00
|
|
|
self._assertRepoFile(['Server', 'Everything'])
|
2017-01-04 08:15:27 +00:00
|
|
|
|
2019-02-21 10:04:38 +00:00
|
|
|
with open(os.path.join(self.topdir, "work/global/tmp/compose-rpms-local-1.repo")) as f:
|
|
|
|
self.assertIn("baseurl=http://example.com/repo\n", f)
|
|
|
|
|
2019-02-07 13:17:09 +00:00
|
|
|
@mock.patch("pungi.phases.osbs.kojiwrapper.KojiWrapper")
|
2019-04-05 08:23:37 +00:00
|
|
|
def test_run_with_deprecated_registry(self, KojiWrapper):
|
2019-02-07 13:17:09 +00:00
|
|
|
cfg = {
|
|
|
|
"url": "git://example.com/repo?#BEEFCAFE",
|
|
|
|
"target": "f24-docker-candidate",
|
|
|
|
"git_branch": "f24-docker",
|
|
|
|
"name": "my-name",
|
|
|
|
"version": "1.0",
|
|
|
|
"repo": ["Everything", "http://pkgs.example.com/my.repo"],
|
|
|
|
"registry": {"foo": "bar"},
|
|
|
|
}
|
|
|
|
self._setupMock(KojiWrapper)
|
|
|
|
self._assertConfigCorrect(cfg)
|
|
|
|
|
|
|
|
self.t.process((self.compose, self.compose.variants["Server"], cfg), 1)
|
|
|
|
|
|
|
|
options = {
|
|
|
|
"name": "my-name",
|
|
|
|
"version": "1.0",
|
|
|
|
"git_branch": "f24-docker",
|
|
|
|
"yum_repourls": [
|
|
|
|
"http://root/work/global/tmp-Server/compose-rpms-Server-1.repo",
|
|
|
|
"http://root/work/global/tmp-Everything/compose-rpms-Everything-1.repo",
|
|
|
|
"http://pkgs.example.com/my.repo",
|
|
|
|
]
|
|
|
|
}
|
|
|
|
self._assertCorrectCalls(options)
|
|
|
|
self._assertCorrectMetadata()
|
|
|
|
self._assertRepoFile(["Server", "Everything"])
|
|
|
|
self.assertEqual(self.t.pool.registries, {"my-name-1.0-1": {"foo": "bar"}})
|
|
|
|
|
2019-04-05 08:23:37 +00:00
|
|
|
@mock.patch("pungi.phases.osbs.kojiwrapper.KojiWrapper")
|
|
|
|
def test_run_with_registry(self, KojiWrapper):
|
|
|
|
cfg = {
|
|
|
|
"url": "git://example.com/repo?#BEEFCAFE",
|
|
|
|
"target": "f24-docker-candidate",
|
|
|
|
"git_branch": "f24-docker",
|
|
|
|
"name": "my-name",
|
|
|
|
"version": "1.0",
|
|
|
|
"repo": ["Everything", "http://pkgs.example.com/my.repo"],
|
|
|
|
}
|
|
|
|
self.compose.conf["osbs_registries"] = {"my-name-1.0-*": [{"foo": "bar"}]}
|
|
|
|
self._setupMock(KojiWrapper)
|
|
|
|
self._assertConfigCorrect(cfg)
|
|
|
|
|
|
|
|
self.t.process((self.compose, self.compose.variants["Server"], cfg), 1)
|
|
|
|
|
|
|
|
options = {
|
|
|
|
"name": "my-name",
|
|
|
|
"version": "1.0",
|
|
|
|
"git_branch": "f24-docker",
|
|
|
|
"yum_repourls": [
|
|
|
|
"http://root/work/global/tmp-Server/compose-rpms-Server-1.repo",
|
|
|
|
"http://root/work/global/tmp-Everything/compose-rpms-Everything-1.repo",
|
|
|
|
"http://pkgs.example.com/my.repo",
|
|
|
|
]
|
|
|
|
}
|
|
|
|
self._assertCorrectCalls(options)
|
|
|
|
self._assertCorrectMetadata()
|
|
|
|
self._assertRepoFile(["Server", "Everything"])
|
|
|
|
self.assertEqual(self.t.pool.registries, {"my-name-1.0-1": [{"foo": "bar"}]})
|
|
|
|
|
2017-01-04 08:15:27 +00:00
|
|
|
@mock.patch('pungi.phases.osbs.kojiwrapper.KojiWrapper')
|
2018-11-21 09:56:22 +00:00
|
|
|
def test_run_with_extra_repos_in_list(self, KojiWrapper):
|
2017-01-04 08:15:27 +00:00
|
|
|
cfg = {
|
2018-11-21 09:56:22 +00:00
|
|
|
'url': 'git://example.com/repo?#BEEFCAFE',
|
2017-01-04 08:15:27 +00:00
|
|
|
'target': 'f24-docker-candidate',
|
2017-04-24 07:55:24 +00:00
|
|
|
'git_branch': 'f24-docker',
|
2017-01-04 08:15:27 +00:00
|
|
|
'name': 'my-name',
|
|
|
|
'version': '1.0',
|
2017-03-27 21:53:08 +00:00
|
|
|
'repo': ['Everything', 'Client', 'http://pkgs.example.com/my.repo'],
|
2017-01-04 08:15:27 +00:00
|
|
|
}
|
2017-01-04 08:35:31 +00:00
|
|
|
self._assertConfigCorrect(cfg)
|
2018-11-21 09:56:22 +00:00
|
|
|
self._setupMock(KojiWrapper)
|
2017-01-04 08:15:27 +00:00
|
|
|
|
|
|
|
self.t.process((self.compose, self.compose.variants['Server'], cfg), 1)
|
|
|
|
|
|
|
|
options = {
|
|
|
|
'name': 'my-name',
|
|
|
|
'version': '1.0',
|
2017-04-24 07:55:24 +00:00
|
|
|
'git_branch': 'f24-docker',
|
2017-01-04 08:15:27 +00:00
|
|
|
'yum_repourls': [
|
2018-07-09 09:04:00 +00:00
|
|
|
'http://root/work/global/tmp-Server/compose-rpms-Server-1.repo',
|
|
|
|
'http://root/work/global/tmp-Everything/compose-rpms-Everything-1.repo',
|
|
|
|
'http://root/work/global/tmp-Client/compose-rpms-Client-1.repo',
|
2017-01-04 08:15:27 +00:00
|
|
|
'http://pkgs.example.com/my.repo',
|
|
|
|
]
|
|
|
|
}
|
|
|
|
self._assertCorrectCalls(options)
|
|
|
|
self._assertCorrectMetadata()
|
2017-01-04 08:19:25 +00:00
|
|
|
self._assertRepoFile(['Server', 'Everything', 'Client'])
|
2017-01-04 08:15:27 +00:00
|
|
|
|
2017-01-17 04:54:41 +00:00
|
|
|
@mock.patch('pungi.phases.osbs.kojiwrapper.KojiWrapper')
|
2018-11-21 09:56:22 +00:00
|
|
|
def test_run_with_gpgkey_enabled(self, KojiWrapper):
|
2017-01-17 04:54:41 +00:00
|
|
|
gpgkey = 'file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release'
|
|
|
|
cfg = {
|
2018-11-21 09:56:22 +00:00
|
|
|
'url': 'git://example.com/repo?#BEEFCAFE',
|
2017-01-17 04:54:41 +00:00
|
|
|
'target': 'f24-docker-candidate',
|
2017-04-24 07:55:24 +00:00
|
|
|
'git_branch': 'f24-docker',
|
2017-01-17 04:54:41 +00:00
|
|
|
'name': 'my-name',
|
|
|
|
'version': '1.0',
|
2017-03-27 21:53:08 +00:00
|
|
|
'repo': ['Everything', 'Client', 'http://pkgs.example.com/my.repo'],
|
2017-01-17 04:54:41 +00:00
|
|
|
'gpgkey': gpgkey,
|
|
|
|
}
|
|
|
|
self._assertConfigCorrect(cfg)
|
2018-11-21 09:56:22 +00:00
|
|
|
self._setupMock(KojiWrapper)
|
2017-01-17 04:54:41 +00:00
|
|
|
|
|
|
|
self.t.process((self.compose, self.compose.variants['Server'], cfg), 1)
|
|
|
|
|
|
|
|
self._assertRepoFile(['Server', 'Everything', 'Client'], gpgkey=gpgkey)
|
|
|
|
|
2017-01-04 08:15:27 +00:00
|
|
|
@mock.patch('pungi.phases.osbs.kojiwrapper.KojiWrapper')
|
2018-11-21 09:56:22 +00:00
|
|
|
def test_run_with_extra_repos_missing_variant(self, KojiWrapper):
|
2017-01-04 08:15:27 +00:00
|
|
|
cfg = {
|
2018-11-21 09:56:22 +00:00
|
|
|
'url': 'git://example.com/repo?#BEEFCAFE',
|
2017-01-04 08:15:27 +00:00
|
|
|
'target': 'f24-docker-candidate',
|
2017-04-24 07:55:24 +00:00
|
|
|
'git_branch': 'f24-docker',
|
2017-01-04 08:15:27 +00:00
|
|
|
'name': 'my-name',
|
|
|
|
'version': '1.0',
|
2017-03-27 21:53:08 +00:00
|
|
|
'repo': 'Gold',
|
2017-01-04 08:15:27 +00:00
|
|
|
}
|
2017-01-04 08:35:31 +00:00
|
|
|
self._assertConfigCorrect(cfg)
|
2018-11-21 09:56:22 +00:00
|
|
|
self._setupMock(KojiWrapper)
|
2017-01-04 08:15:27 +00:00
|
|
|
|
|
|
|
with self.assertRaises(RuntimeError) as ctx:
|
|
|
|
self.t.process((self.compose, self.compose.variants['Server'], cfg), 1)
|
|
|
|
|
|
|
|
self.assertIn('no variant Gold', str(ctx.exception))
|
|
|
|
|
2017-01-04 08:35:31 +00:00
|
|
|
def test_run_with_missing_url(self):
|
2016-06-20 13:43:55 +00:00
|
|
|
cfg = {
|
|
|
|
'target': 'f24-docker-candidate',
|
2017-04-24 07:55:24 +00:00
|
|
|
'git_branch': 'f24-docker',
|
2016-06-20 13:43:55 +00:00
|
|
|
'name': 'my-name',
|
|
|
|
}
|
2017-01-04 08:35:31 +00:00
|
|
|
self._assertConfigMissing(cfg, 'url')
|
2016-06-20 13:43:55 +00:00
|
|
|
|
2017-01-04 08:35:31 +00:00
|
|
|
def test_run_with_missing_target(self):
|
2016-06-20 13:43:55 +00:00
|
|
|
cfg = {
|
2018-11-21 09:56:22 +00:00
|
|
|
'url': 'git://example.com/repo?#BEEFCAFE',
|
2017-04-24 07:55:24 +00:00
|
|
|
'git_branch': 'f24-docker',
|
2016-06-20 13:43:55 +00:00
|
|
|
'name': 'my-name',
|
|
|
|
}
|
2017-01-04 08:35:31 +00:00
|
|
|
self._assertConfigMissing(cfg, 'target')
|
2016-06-20 13:43:55 +00:00
|
|
|
|
2017-04-24 07:55:24 +00:00
|
|
|
def test_run_with_missing_git_branch(self):
|
|
|
|
cfg = {
|
2018-11-21 09:56:22 +00:00
|
|
|
'url': 'git://example.com/repo?#BEEFCAFE',
|
2017-04-24 07:55:24 +00:00
|
|
|
'target': 'f24-docker-candidate',
|
|
|
|
}
|
|
|
|
self._assertConfigMissing(cfg, 'git_branch')
|
|
|
|
|
2016-06-20 13:43:55 +00:00
|
|
|
@mock.patch('pungi.phases.osbs.kojiwrapper.KojiWrapper')
|
2018-11-21 09:56:22 +00:00
|
|
|
def test_failing_task(self, KojiWrapper):
|
2016-06-20 13:43:55 +00:00
|
|
|
cfg = {
|
2018-11-21 09:56:22 +00:00
|
|
|
'url': 'git://example.com/repo?#BEEFCAFE',
|
2016-06-20 13:43:55 +00:00
|
|
|
'target': 'fedora-24-docker-candidate',
|
2017-04-24 07:55:24 +00:00
|
|
|
'git_branch': 'f24-docker',
|
2016-06-20 13:43:55 +00:00
|
|
|
}
|
2017-01-04 08:35:31 +00:00
|
|
|
self._assertConfigCorrect(cfg)
|
2018-11-21 09:56:22 +00:00
|
|
|
self._setupMock(KojiWrapper)
|
2016-06-20 13:43:55 +00:00
|
|
|
self.wrapper.watch_task.return_value = 1
|
|
|
|
|
|
|
|
with self.assertRaises(RuntimeError) as ctx:
|
|
|
|
self.t.process((self.compose, self.compose.variants['Server'], cfg), 1)
|
|
|
|
|
2017-10-30 08:16:18 +00:00
|
|
|
self.assertRegexpMatches(str(ctx.exception), r"task 12345 failed: see .+ for details")
|
2016-06-20 13:43:55 +00:00
|
|
|
|
|
|
|
@mock.patch('pungi.phases.osbs.kojiwrapper.KojiWrapper')
|
2018-11-21 09:56:22 +00:00
|
|
|
def test_failing_task_with_failable(self, KojiWrapper):
|
2016-06-20 13:43:55 +00:00
|
|
|
cfg = {
|
2018-11-21 09:56:22 +00:00
|
|
|
'url': 'git://example.com/repo?#BEEFCAFE',
|
2016-06-20 13:43:55 +00:00
|
|
|
'target': 'fedora-24-docker-candidate',
|
2017-04-24 07:55:24 +00:00
|
|
|
'git_branch': 'f24-docker',
|
2016-06-24 07:44:40 +00:00
|
|
|
'failable': ['*']
|
2016-06-20 13:43:55 +00:00
|
|
|
}
|
2017-01-04 08:35:31 +00:00
|
|
|
self._assertConfigCorrect(cfg)
|
2018-11-21 09:56:22 +00:00
|
|
|
self._setupMock(KojiWrapper)
|
2016-06-20 13:43:55 +00:00
|
|
|
self.wrapper.watch_task.return_value = 1
|
|
|
|
|
|
|
|
self.t.process((self.compose, self.compose.variants['Server'], cfg), 1)
|
|
|
|
|
|
|
|
@mock.patch('pungi.phases.osbs.kojiwrapper.KojiWrapper')
|
2018-11-21 09:56:22 +00:00
|
|
|
def test_scratch_metadata(self, KojiWrapper):
|
2016-06-20 13:43:55 +00:00
|
|
|
cfg = {
|
2018-11-21 09:56:22 +00:00
|
|
|
'url': 'git://example.com/repo?#BEEFCAFE',
|
2017-03-02 13:10:16 +00:00
|
|
|
'target': 'f24-docker-candidate',
|
2017-04-24 07:55:24 +00:00
|
|
|
'git_branch': 'f24-docker',
|
2016-06-20 13:43:55 +00:00
|
|
|
'scratch': True,
|
|
|
|
}
|
2018-11-21 09:56:22 +00:00
|
|
|
self._setupMock(KojiWrapper, scratch=True)
|
2017-01-04 08:35:31 +00:00
|
|
|
self._assertConfigCorrect(cfg)
|
2016-06-20 13:43:55 +00:00
|
|
|
|
|
|
|
self.t.process((self.compose, self.compose.variants['Server'], cfg), 1)
|
|
|
|
|
2017-04-24 07:55:24 +00:00
|
|
|
self._assertCorrectCalls({'git_branch': 'f24-docker'}, scratch=True)
|
2017-03-02 13:10:16 +00:00
|
|
|
self._assertCorrectMetadata(scratch=True)
|
|
|
|
self._assertRepoFile()
|