#1156 Set `time_completed` before calling KojiContentGenerator.
Merged a year ago by jkaluza. Opened a year ago by jkaluza.
jkaluza/fm-orchestrator fix-koji-gc  into  master

@@ -26,6 +26,7 @@ 

  import module_build_service.builder

  import logging

  import koji

+ from datetime import datetime

  from module_build_service import models, log

  from module_build_service.utils import start_next_batch_build


@@ -149,6 +150,7 @@ 



              # Tell the external buildsystem to wrap up (CG import, createrepo, etc.)

+             module_build.time_completed = datetime.utcnow()



              module_build.transition(config, state=models.BUILD_STATES['done'])

@@ -101,6 +101,20 @@ 

          get_session.return_value = mock.Mock(), 'development'

          build_fn.return_value = 1234, 1, '', None


+         # Ensure the time_completed is None, so we can test it is set to

+         # some date once the build is finalized.

+         module_build = module_build_service.models.ModuleBuild.query.get(2)

+         module_build.time_completed = None

+         db.session.commit()


+         def mocked_finalizer():

+             # Check that the time_completed is set in the time when

+             # finalizer is called.

+             module_build = module_build_service.models.ModuleBuild.query.get(2)

+             assert module_build.time_completed is not None


+         finalizer.side_effect = mocked_finalizer


          msg = module_build_service.messaging.KojiRepoChange(

              'some_msg_id', 'module-testmodule-master-20170109091357-7c29193d-build')


The KojiContentGenerator.finalize() needs the ModuleBuild.time_completed.

We currently set time_completed once the module build transitions
into done state. But we have moved the KojiContentGenerator call
to end of build state, so right now it is called before the time_completed
is set. This leads to traceback.

In this commit, the time_completed is set before the KojiContentGenerator
call, so it is defined properly.

maybe test for it?
otherwise :thumbsup:

rebased onto ac0bd8c

a year ago

Pull-Request has been merged by jkaluza

a year ago