| |
@@ -105,8 +105,9 @@
|
| |
mmd = second_module_build.mmd()
|
| |
mmd.get_rpm_component("tangerine").set_ref("00ea1da4192a2030f9ae023de3b3143ed647bbab")
|
| |
second_module_build.modulemd = mmd_to_str(mmd)
|
| |
- second_module_changed_component = db_session.query(models.ComponentBuild).filter_by(
|
| |
- package=changed_component, module_id=3).one()
|
| |
+
|
| |
+ second_module_changed_component = models.ComponentBuild.from_component_name(
|
| |
+ db_session, changed_component, second_module_build.id)
|
| |
second_module_changed_component.ref = "00ea1da4192a2030f9ae023de3b3143ed647bbab"
|
| |
db_session.add(second_module_changed_component)
|
| |
db_session.commit()
|
| |
@@ -173,8 +174,8 @@
|
| |
db_session.commit()
|
| |
|
| |
if set_database_arch: # set architecture for build in database
|
| |
- second_module_changed_component = db_session.query(models.ComponentBuild).filter_by(
|
| |
- package="tangerine", module_id=2).one()
|
| |
+ second_module_changed_component = models.ComponentBuild.from_component_name(
|
| |
+ db_session, "tangerine", 2)
|
| |
mmd = second_module_changed_component.module_build.mmd()
|
| |
component = mmd.get_rpm_component("tangerine")
|
| |
component.reset_arches()
|
| |
@@ -810,6 +811,55 @@
|
| |
assert c.weight == 1.5
|
| |
|
| |
@patch("module_build_service.scm.SCM")
|
| |
+ def test_record_component_builds_component_exists_already(self, mocked_scm, db_session):
|
| |
+ clean_database()
|
| |
+ mocked_scm.return_value.commit = "620ec77321b2ea7b0d67d82992dda3e1d67055b4"
|
| |
+ mocked_scm.return_value.get_latest.side_effect = [
|
| |
+ "4ceea43add2366d8b8c5a622a2fb563b625b9abf",
|
| |
+ "fbed359411a1baa08d4a88e0d12d426fbf8f602c",
|
| |
+ "dbed259411a1baa08d4a88e0d12d426fbf8f6037",
|
| |
+
|
| |
+ "4ceea43add2366d8b8c5a622a2fb563b625b9abf",
|
| |
+ # To simulate that when a module is resubmitted, some ref of
|
| |
+ # its components is changed, which will cause MBS stops
|
| |
+ # recording component to database and raise an error.
|
| |
+ "abcdefg",
|
| |
+ "dbed259411a1baa08d4a88e0d12d426fbf8f6037",
|
| |
+ ]
|
| |
+
|
| |
+ original_mmd = load_mmd(read_staged_data("testmodule"))
|
| |
+
|
| |
+ # Set the module name and stream
|
| |
+ mmd = original_mmd.copy("testmodule", "master")
|
| |
+ module_build = module_build_service.models.ModuleBuild()
|
| |
+ module_build.name = "testmodule"
|
| |
+ module_build.stream = "master"
|
| |
+ module_build.version = 20170109091357
|
| |
+ module_build.state = models.BUILD_STATES["init"]
|
| |
+ module_build.scmurl = \
|
| |
+ "https://src.stg.fedoraproject.org/modules/testmodule.git?#ff1ea79"
|
| |
+ module_build.batch = 1
|
| |
+ module_build.owner = "Tom Brady"
|
| |
+ module_build.time_submitted = datetime(2017, 2, 15, 16, 8, 18)
|
| |
+ module_build.time_modified = datetime(2017, 2, 15, 16, 19, 35)
|
| |
+ module_build.rebuild_strategy = "changed-and-after"
|
| |
+ module_build.modulemd = mmd_to_str(mmd)
|
| |
+ db_session.add(module_build)
|
| |
+ db_session.commit()
|
| |
+
|
| |
+ format_mmd(mmd, module_build.scmurl)
|
| |
+ module_build_service.utils.record_component_builds(db_session, mmd, module_build)
|
| |
+
|
| |
+ mmd = original_mmd.copy("testmodule", "master")
|
| |
+
|
| |
+ from module_build_service.errors import ValidationError
|
| |
+ with pytest.raises(
|
| |
+ ValidationError,
|
| |
+ match=r"Component build .+ of module build .+ already exists in database"):
|
| |
+ format_mmd(mmd, module_build.scmurl)
|
| |
+ module_build_service.utils.record_component_builds(db_session, mmd, module_build)
|
| |
+
|
| |
+ @patch("module_build_service.scm.SCM")
|
| |
def test_format_mmd_arches(self, mocked_scm):
|
| |
with app.app_context():
|
| |
clean_database()
|
| |
@@ -1096,12 +1146,13 @@
|
| |
"""
|
| |
module_build = models.ModuleBuild.get_by_id(db_session, 3)
|
| |
module_build.batch = 1
|
| |
- plc_component = db_session.query(models.ComponentBuild).filter_by(
|
| |
- module_id=3, package="perl-List-Compare").one()
|
| |
+ plc_component = models.ComponentBuild.from_component_name(
|
| |
+ db_session, "perl-List-Compare", 3)
|
| |
plc_component.ref = "5ceea46add2366d8b8c5a623a2fb563b625b9abd"
|
| |
|
| |
builder = mock.MagicMock()
|
| |
builder.recover_orphaned_artifact.return_value = []
|
| |
+
|
| |
further_work = module_build_service.utils.start_next_batch_build(
|
| |
conf, module_build, db_session, builder)
|
| |
|
| |
@@ -1184,8 +1235,8 @@
|
| |
module_build.rebuild_strategy = "only-changed"
|
| |
module_build.batch = 1
|
| |
# perl-List-Compare changed
|
| |
- plc_component = db_session.query(models.ComponentBuild).filter_by(
|
| |
- module_id=3, package="perl-List-Compare").one()
|
| |
+ plc_component = models.ComponentBuild.from_component_name(
|
| |
+ db_session, "perl-List-Compare", 3)
|
| |
plc_component.ref = "5ceea46add2366d8b8c5a623a2fb563b625b9abd"
|
| |
|
| |
builder = mock.MagicMock()
|
| |
@@ -1215,8 +1266,8 @@
|
| |
|
| |
# Complete the build
|
| |
plc_component.state = koji.BUILD_STATES["COMPLETE"]
|
| |
- pt_component = db_session.query(models.ComponentBuild).filter_by(
|
| |
- module_id=3, package="perl-Tangerine").one()
|
| |
+ pt_component = models.ComponentBuild.from_component_name(
|
| |
+ db_session, "perl-Tangerine", 3)
|
| |
pt_component.state = koji.BUILD_STATES["COMPLETE"]
|
| |
|
| |
# Start the next build batch
|
| |
@@ -1242,11 +1293,11 @@
|
| |
"""
|
| |
module_build = models.ModuleBuild.get_by_id(db_session, 3)
|
| |
module_build.batch = 1
|
| |
- pt_component = db_session.query(models.ComponentBuild).filter_by(
|
| |
- module_id=3, package="perl-Tangerine").one()
|
| |
+ pt_component = models.ComponentBuild.from_component_name(
|
| |
+ db_session, "perl-Tangerine", 3)
|
| |
pt_component.ref = "6ceea46add2366d8b8c5a623b2fb563b625bfabe"
|
| |
- plc_component = db_session.query(models.ComponentBuild).filter_by(
|
| |
- module_id=3, package="perl-List-Compare").one()
|
| |
+ plc_component = models.ComponentBuild.from_component_name(
|
| |
+ db_session, "perl-List-Compare", 3)
|
| |
plc_component.ref = "5ceea46add2366d8b8c5a623a2fb563b625b9abd"
|
| |
|
| |
# Components are by default built by component id. To find out that weight is respected,
|
| |