mirror of
https://pagure.io/fm-orchestrator.git
synced 2026-02-02 20:59:06 +08:00
fix unit tests
This commit is contained in:
@@ -409,7 +409,7 @@ def _populate_data(data_size=10, contexts=False, scratch=False):
|
||||
db_session.commit()
|
||||
|
||||
|
||||
def scheduler_init_data(tangerine_state=None, scratch=False):
|
||||
def scheduler_init_data(tangerine_state=None, scratch=False, module_state="build"):
|
||||
""" Creates a testmodule in the building state with all the components in the same batch
|
||||
"""
|
||||
clean_database()
|
||||
@@ -421,7 +421,7 @@ def scheduler_init_data(tangerine_state=None, scratch=False):
|
||||
name="testmodule",
|
||||
stream="master",
|
||||
version='20170109091357',
|
||||
state=BUILD_STATES["build"],
|
||||
state=BUILD_STATES[module_state],
|
||||
scratch=scratch,
|
||||
build_context="ac4de1c346dcf09ce77d38cd4e75094ec1c08eb0",
|
||||
runtime_context="ac4de1c346dcf09ce77d38cd4e75094ec1c08eb0",
|
||||
|
||||
@@ -1152,16 +1152,24 @@ class TestBuild(BaseTestBuild):
|
||||
|
||||
from module_build_service.scheduler.db_session import db_session
|
||||
|
||||
# module should be in wait state for this test
|
||||
module_build = models.ModuleBuild.get_by_id(db_session, 3)
|
||||
module_build.state = models.BUILD_STATES["wait"]
|
||||
db_session.commit()
|
||||
|
||||
# Create a dedicated database session for scheduler to avoid hang
|
||||
self.run_scheduler(
|
||||
msgs=[{
|
||||
"msg_id": "local module build",
|
||||
"event": events.MBS_MODULE_STATE_CHANGE,
|
||||
"module_build_id": 3,
|
||||
"module_build_state": 1
|
||||
"module_build_id": module_build.id,
|
||||
"module_build_state": module_build.state,
|
||||
}]
|
||||
)
|
||||
|
||||
# commit so that our assertions see the updates
|
||||
db_session.commit()
|
||||
|
||||
reused_component_ids = {
|
||||
"module-build-macros": None,
|
||||
"tangerine": 3,
|
||||
@@ -1239,6 +1247,11 @@ class TestBuild(BaseTestBuild):
|
||||
|
||||
FakeModuleBuilder.on_buildroot_add_artifacts_cb = on_buildroot_add_artifacts_cb
|
||||
|
||||
# module should be in wait state for this test
|
||||
module_build = models.ModuleBuild.get_by_id(db_session, 3)
|
||||
module_build.state = models.BUILD_STATES["wait"]
|
||||
db_session.commit()
|
||||
|
||||
self.run_scheduler(
|
||||
msgs=[{
|
||||
"msg_id": "local module build",
|
||||
@@ -1248,6 +1261,9 @@ class TestBuild(BaseTestBuild):
|
||||
}]
|
||||
)
|
||||
|
||||
# commit so that our assertions see the updates
|
||||
db_session.commit()
|
||||
|
||||
# All components should be built and module itself should be in "done"
|
||||
# or "ready" state.
|
||||
for build in models.ModuleBuild.get_by_id(db_session, 3).component_builds:
|
||||
|
||||
@@ -21,7 +21,7 @@ base_dir = os.path.dirname(os.path.dirname(__file__))
|
||||
|
||||
class TestModuleWait:
|
||||
def setup_method(self, test_method):
|
||||
scheduler_init_data()
|
||||
scheduler_init_data(module_state="wait")
|
||||
|
||||
self.config = conf
|
||||
self.session = mock.Mock()
|
||||
|
||||
Reference in New Issue
Block a user