ostree: Add force_new_commit option - test added

Relates: https://pagure.io/pungi/issue/811

Signed-off-by: Ondrej Nosek <onosek@redhat.com>
This commit is contained in:
Ondrej Nosek 2018-01-11 15:08:07 +01:00
parent 161b7f974b
commit 51cd359057
4 changed files with 31 additions and 3 deletions

View File

@ -1220,7 +1220,7 @@ repository with a new commit.
deliverable is not release blocking.
* ``update_summary`` -- (*bool*) Update summary metadata after tree composing.
Defaults to ``False``.
* ``force_new_commit`` -- (*bool*) Do not use rpm-ostree's built in change
* ``force_new_commit`` -- (*bool*) Do not use rpm-ostree's built-in change
detection.
Defaults to ``False``.
* ``version`` -- (*str*) Version string to be added as versioning metadata.

View File

@ -42,6 +42,8 @@ def main(args=None):
help='update summary metadata')
treep.add_argument('--ostree-ref', metavar='PATH',
help='override ref value from treefile')
treep.add_argument('--force-new-commit', action='store_true',
help='do not use rpm-ostree\'s built-in change detection')
installerp = subparser.add_parser("installer", help="Create an OSTree installer image")
installerp.set_defaults(_class=Installer, func='run')

View File

@ -126,6 +126,9 @@ class OSTreeThread(WorkerThread):
if ostree_ref:
cmd.append('--ostree-ref=%s' % ostree_ref)
if config.get('force_new_commit', False):
cmd.append('--force-new-commit')
runroot_channel = compose.conf.get("runroot_channel")
runroot_tag = compose.conf["runroot_tag"]

View File

@ -106,7 +106,7 @@ class OstreeTreeScriptTest(helpers.PungiTestCase):
self.assertItemsEqual(
run.call_args_list,
[mock.call(['rpm-ostree', 'compose', 'tree', '--repo=%s' % repo,
'--write-commitid-to=%s' % (self.topdir + '/logs/Atomic/commitid.log'),
'--write-commitid-to=%s' % (self.topdir + '/logs/Atomic/commitid.log'),
self.topdir + '/fedora-atomic-docker-host.json'],
logfile=self.topdir + '/logs/Atomic/create-ostree-repo.log', show_cmd=True, stdout=True),
mock.call(['ostree', 'summary', '-u', '--repo=%s' % repo],
@ -128,7 +128,7 @@ class OstreeTreeScriptTest(helpers.PungiTestCase):
self.assertItemsEqual(
run.call_args_list,
[mock.call(['rpm-ostree', 'compose', 'tree', '--repo=%s' % repo,
'--write-commitid-to=%s' % (self.topdir + '/logs/Atomic/commitid.log'),
'--write-commitid-to=%s' % (self.topdir + '/logs/Atomic/commitid.log'),
'--add-metadata-string=version=24',
self.topdir + '/fedora-atomic-docker-host.json'],
logfile=self.topdir + '/logs/Atomic/create-ostree-repo.log', show_cmd=True, stdout=True)])
@ -164,6 +164,29 @@ class OstreeTreeScriptTest(helpers.PungiTestCase):
# repos should stay unchanged
self.assertEqual(original_repos, new_repos)
@mock.patch('kobo.shortcuts.run')
def test_force_new_commit(self, run):
repo = os.path.join(self.topdir, 'atomic')
helpers.touch(os.path.join(repo, 'initialized'))
ostree.main([
'tree',
'--repo=%s' % repo,
'--log-dir=%s' % os.path.join(self.topdir, 'logs', 'Atomic'),
'--treefile=%s/fedora-atomic-docker-host.json' % self.topdir,
'--force-new-commit',
])
self.maxDiff = None
self.assertItemsEqual(
run.call_args_list,
[mock.call(['rpm-ostree', 'compose', 'tree', '--repo=%s' % repo,
'--write-commitid-to=%s' % (self.topdir + '/logs/Atomic/commitid.log'),
'--force-nocache',
self.topdir + '/fedora-atomic-docker-host.json'],
logfile=self.topdir + '/logs/Atomic/create-ostree-repo.log', show_cmd=True, stdout=True)])
@mock.patch('pungi.ostree.utils.datetime')
@mock.patch('kobo.shortcuts.run')
def test_extra_config_with_extra_repos(self, run, time):