mirror of
https://pagure.io/fm-orchestrator.git
synced 2026-04-05 11:48:33 +08:00
Merge #508 Do not start new batch in poller when new_repo is running
This commit is contained in:
@@ -191,8 +191,11 @@ class MBSProducer(PollingProducer):
|
||||
for module_build in session.query(models.ModuleBuild).filter_by(
|
||||
state=models.BUILD_STATES['build']).all():
|
||||
# If there are no components in the build state on the module build,
|
||||
# then no possible event will start off new component builds
|
||||
if not module_build.current_batch(koji.BUILD_STATES['BUILDING']):
|
||||
# then no possible event will start off new component builds.
|
||||
# But do not try to start new builds when we are waiting for the
|
||||
# repo-regen.
|
||||
if (not module_build.current_batch(koji.BUILD_STATES['BUILDING'])
|
||||
and not module_build.new_repo_task_id):
|
||||
# Initialize the builder...
|
||||
builder = GenericBuilder.create_from_module(
|
||||
session, module_build, config)
|
||||
@@ -232,5 +235,7 @@ class MBSProducer(PollingProducer):
|
||||
str(module_build.new_repo_task_id), module_build)
|
||||
taginfo = koji_session.getTag(module_build.koji_tag + "-build")
|
||||
module_build.new_repo_task_id = koji_session.newRepo(taginfo["name"])
|
||||
else:
|
||||
module_build.new_repo_task_id = 0
|
||||
|
||||
session.commit()
|
||||
|
||||
@@ -53,7 +53,7 @@ class TestPoller(unittest.TestCase):
|
||||
def tearDown(self):
|
||||
init_data()
|
||||
|
||||
def test_process_paused_module_builds(self, crete_builder,
|
||||
def test_process_paused_module_builds(self, create_builder,
|
||||
koji_get_session, global_consumer,
|
||||
dbg):
|
||||
"""
|
||||
@@ -67,7 +67,7 @@ class TestPoller(unittest.TestCase):
|
||||
koji_get_session.return_value = koji_session
|
||||
|
||||
builder = mock.MagicMock()
|
||||
crete_builder.return_value = builder
|
||||
create_builder.return_value = builder
|
||||
|
||||
# Change the batch to 2, so the module build is in state where
|
||||
# it is not building anything, but the state is "build".
|
||||
@@ -81,15 +81,14 @@ class TestPoller(unittest.TestCase):
|
||||
poller.poll()
|
||||
|
||||
# Refresh our module_build object.
|
||||
db.session.expunge(module_build)
|
||||
module_build = models.ModuleBuild.query.filter_by(id=2).one()
|
||||
db.session.refresh(module_build)
|
||||
|
||||
# Components should be in BUILDING state now.
|
||||
components = module_build.current_batch()
|
||||
for component in components:
|
||||
self.assertEqual(component.state, koji.BUILD_STATES["BUILDING"])
|
||||
|
||||
def test_trigger_new_repo_when_failed(self, crete_builder,
|
||||
def test_trigger_new_repo_when_failed(self, create_builder,
|
||||
koji_get_session, global_consumer,
|
||||
dbg):
|
||||
"""
|
||||
@@ -107,7 +106,7 @@ class TestPoller(unittest.TestCase):
|
||||
|
||||
builder = mock.MagicMock()
|
||||
builder.buildroot_ready.return_value = False
|
||||
crete_builder.return_value = builder
|
||||
create_builder.return_value = builder
|
||||
|
||||
# Change the batch to 2, so the module build is in state where
|
||||
# it is not building anything, but the state is "build".
|
||||
@@ -123,7 +122,7 @@ class TestPoller(unittest.TestCase):
|
||||
koji_session.newRepo.assert_called_once_with("module-testmodule-build")
|
||||
|
||||
|
||||
def test_trigger_new_repo_when_succeded(self, crete_builder,
|
||||
def test_trigger_new_repo_when_succeded(self, create_builder,
|
||||
koji_get_session, global_consumer,
|
||||
dbg):
|
||||
"""
|
||||
@@ -142,7 +141,7 @@ class TestPoller(unittest.TestCase):
|
||||
|
||||
builder = mock.MagicMock()
|
||||
builder.buildroot_ready.return_value = False
|
||||
crete_builder.return_value = builder
|
||||
create_builder.return_value = builder
|
||||
|
||||
# Change the batch to 2, so the module build is in state where
|
||||
# it is not building anything, but the state is "build".
|
||||
@@ -155,6 +154,44 @@ class TestPoller(unittest.TestCase):
|
||||
poller = MBSProducer(hub)
|
||||
poller.poll()
|
||||
|
||||
# Refresh our module_build object.
|
||||
db.session.refresh(module_build)
|
||||
|
||||
self.assertTrue(not koji_session.newRepo.called)
|
||||
self.assertEqual(module_build.new_repo_task_id, 0)
|
||||
|
||||
def test_process_paused_module_builds_waiting_for_repo(
|
||||
self, create_builder, koji_get_session, global_consumer, dbg):
|
||||
"""
|
||||
Tests that process_paused_module_builds does not start new batch
|
||||
when we are waiting for repo.
|
||||
"""
|
||||
consumer = mock.MagicMock()
|
||||
consumer.incoming = queue.Queue()
|
||||
global_consumer.return_value = consumer
|
||||
|
||||
koji_session = mock.MagicMock()
|
||||
koji_get_session.return_value = koji_session
|
||||
|
||||
builder = mock.MagicMock()
|
||||
create_builder.return_value = builder
|
||||
|
||||
# Change the batch to 2, so the module build is in state where
|
||||
# it is not building anything, but the state is "build".
|
||||
module_build = models.ModuleBuild.query.filter_by(id=2).one()
|
||||
module_build.batch = 2
|
||||
module_build.new_repo_task_id = 123456
|
||||
db.session.commit()
|
||||
|
||||
# Poll :)
|
||||
hub = mock.MagicMock()
|
||||
poller = MBSProducer(hub)
|
||||
poller.poll()
|
||||
|
||||
# Refresh our module_build object.
|
||||
db.session.refresh(module_build)
|
||||
|
||||
# Components should not be in building state
|
||||
components = module_build.current_batch()
|
||||
for component in components:
|
||||
self.assertEqual(component.state, None)
|
||||
|
||||
Reference in New Issue
Block a user