711 Commits

Author SHA1 Message Date
mprahl
749f186524 Add conflicts in module-build-macros for NEVRAs found in handle_collisions_with_base_module_rpms
PR #1331 made the assumption that the Ursa Major ursine RPMs were at
xmd["mbs"]["ursine_rpms"], but they are actually at
xmd["mbs"]["buildrequires"]["platform"]["ursine_rpms"]. This commit
handles the ursine RPMs generated by handle_collisions_with_base_module_rpms
separately since the base module the RPMs came from are not tracked in
that function.
2019-09-19 13:31:10 +00:00
Mike McLean
e2939c80a1 use patch.object 2019-09-18 17:22:59 -04:00
Mike McLean
e1cf07c038 extend unit test 2019-09-18 20:21:14 +00:00
mprahl
235d4cd457 Fix the test_handle_collisions_with_base_module_rpms unit test 2019-09-18 12:04:18 -04:00
Chenxiong Qi
3fb079f23d Add more tests for mbs-manager command build_module_locally
Signed-off-by: Chenxiong Qi <cqi@redhat.com>
2019-09-18 13:42:42 +00:00
Chenxiong Qi
e3f91dd8a8 Add missing keyword assert to test
Signed-off-by: Chenxiong Qi <cqi@redhat.com>
2019-09-18 16:49:21 +08:00
mprahl
1a05d59a4d Use double quotes instead of single quotes 2019-09-17 13:11:22 -04:00
Chenxiong Qi
065abe3c45 Fix DetachedInstanceError in command module_build_locally
Update test test_build_module_locally_set_stream accordingly by not
mocking database session object in order to test against the real
SQLAlchemy Session scope.

Resolves: RHBZ#1752075

Signed-off-by: Chenxiong Qi <cqi@redhat.com>
2019-09-17 23:09:14 +08:00
mprahl
d2e7c0cf90 Don't check for compatibile modules during component reuse if allow_only_compatible_base_modules is false
Addresses #1409
2019-09-13 13:06:35 +00:00
Jan Kaluza
52e88ba3ff Handle the conflicts between base module modular Koji tags everytime.
Currently, we generate `Conflicts` for ursine RPMs conflicting with
modular RPMs only when Ursa Prime is used for the base module. This
commit changes it, so these Conflicts are generated everytime.

The reason is that modular RPMs should always be preferred in the
buildroot over the ursine RPMs no matter what is their NVR. So far,
this has been guarded on Koji side by using external repos, but
we need to move away from external repo or at least use "bare"
merge mode which basically means we won't get this feature for free
from Koji.

The reason why we need to move away from external repos or use "bare"
merge mode is that without this, the Koji removes RPMs sharing the same
name but different version/release from the buildroot and only keeps
the latest one. This is an issue in situation when you need two
versions of single RPM in a buildroot comming from two modules.
2019-09-12 11:08:57 +02:00
mprahl
00e78494d9 Refactor handling of default buildroot modules (Ursa Prime)
This removes support for default_modules_url in the Platform XMD and
gets the list of default name:stream combinations to include in the buildroot
from https://pagure.io/releng/fedora-module-defaults.

Addresses #1402
2019-09-11 12:20:35 -04:00
Jan Kaluža
457b16daff Merge #1395 Reuse the latest module build found. 2019-08-30 05:48:25 +00:00
Jan Kaluza
00ad20dfcd Reuse the latest module build found.
Before this commit, the base modules used in the `get_reusable_module` have
not been sorted and therefore when `get_reusable_module` tried to find out
the reusable module built against some base module, it could find a module
built against some old version of base module.

This could lead to situation when MBS tried to reuse components from quite
old module despite the fact that newer module build existed.

This commit fixes this by sorting the base modules by stream_version,
so MBS always tries to get the reusable module built against the latest
base module.
2019-08-29 15:35:21 +02:00
Valerij Maljulin
c4a95d0673 Add a check for non-ready builds (siblings) in requires resolver
Signed-off-by: Valerij Maljulin <vmaljuli@redhat.com>
2019-08-28 15:34:46 +02:00
Jan Kaluža
9d40a9b9cb Merge #1390 Fix --add-local-build with MBS Resolver. 2019-08-26 05:33:40 +00:00
Jan Kaluza
cc5aaf90c1 Fix --add-local-build with MBS Resolver.
The `MBSResolver.get_buildrequired_modulemds` did not try to load
local module builds and always just queried the remote MBS instance.

This commit fixes it by using local module if available.
2019-08-23 14:58:15 +02:00
mprahl
f3db9a0ac2 Fix a typo in an error message 2019-08-22 17:15:55 -04:00
Jan Kaluža
13a18d1d5a Merge #1384 Add "scratch_build_only_branches" configuration options. 2019-08-21 11:18:34 +00:00
Jan Kaluza
80fca557af Do not check Greenwave gating status for scratch builds.
Scratch builds cannot be gated. They stay in the `done` state forever.
Therefore it is useless to query Greenwave for its status in the Poller.
2019-08-21 13:17:04 +02:00
Chenxiong Qi
e6aa47e02a Use set literal to create a set
Signed-off-by: Chenxiong Qi <cqi@redhat.com>
2019-08-15 21:14:02 +08:00
Jan Kaluza
796a367457 Add "scratch_build_only_branches" configuration options.
The goal here is to define certain branches from which only scratch
module builds can be submitted. The main use case is for "private-*"
branches which can be created and maintained by anyone, but there
must not be production-ready module build created from them.

This commit adds new `scratch_build_only_branches` config option
to define the list of regexes to match such branches.
2019-08-15 10:49:03 +02:00
Valerij Maljulin
a6e7741553 Fix tests failing on 1 sec time differences
Signed-off-by: Valerij Maljulin <vmaljuli@redhat.com>
2019-08-14 13:52:39 +02:00
Chenxiong Qi
6f1d0b3ad9 Return empty result if short=true is specified on empty list of builds
Fixes #1376

Signed-off-by: Chenxiong Qi <cqi@redhat.com>
2019-08-11 22:18:38 +08:00
Valerij Maljulin
e5735efc76 Skip prefix validation for modules in allowed_privileged_module_names and base_module_names
Signed-off-by: Valerij Maljulin <vmaljuli@redhat.com>
2019-08-07 14:17:39 +02:00
Jan Kaluža
758cf9c112 Merge #1365 Allow components to be reused from module builds even if the buildrequires commit hashes changed for the changed-and-after rebuild strategy 2019-08-06 11:08:46 +00:00
mprahl
a6bf9f88dd Allow components to be reused from module builds even if the buildrequires commit hashes changed for the changed-and-after rebuild strategy
This behavior was not documented, and it was confusing to users since module builds
in a stream should always have a compatible API.
2019-08-05 09:23:44 -04:00
Chenxiong Qi
9c6c4da80f Rewrite import_mmd
* xmd/mbs is always set if it is not present in xmd, so move the code on
  the top of function. This change is also helpful for accessing keys
  under xmd/mbs.
* By setting xmd/mbs in the beginning, code is simplified to get
  disttag_marking and virtual_streams. The result is much straightforwar
  for getting a default value for them.
* Move disttag_marking validation code next to the line getting
  disttag_marking from xmd/mbs. As a result, the code structure is
  easier to read as getting disttag_marking and validate it, getting
  virtual_streams and validate.
* Rewrite the part of code for check_buildrequires. Always set
  xmd/mbs/buildrequires if it is not present and check_buildrequires is
  set to True, as it is required by
  ModuleBuild.get_buildrequired_base_modules.
* Using in operator instead of dict.get to check if key koji_tag exists.
  Using dict.get would be ambiguous because even if koji_tag exists
  under xmd/mbs, but due to its value is set to None occasionally, there
  is still a message logged to tell koji_tag is not set.
* Rwrite all lines of code for updating virtual streams. A new method
  update_virtual_streams is added to ModuleBuild. This also fixes
  FACTORY-4561.
* Tests are added for the rewrite of virtual streams update.

Signed-off-by: Chenxiong Qi <cqi@redhat.com>
2019-08-05 16:10:57 +08:00
Jan Kaluža
8dd65a79fa Merge #1340 Added an REST endpoint to display log messages 2019-07-31 12:49:03 +00:00
Martin Curlej
c5d484fb81 Added an REST endpoint to display log messages
The issue is that users don't get feedback from MBS about why a
component was not reused. There was added logic which enables to
store log messages in the database and can be viewed through the
REST api of MBS.

Ticket-ID: #1284

Signed-off-by: Martin Curlej <mcurlej@redhat.com>
2019-07-31 13:32:33 +02:00
Valerij Maljulin
5fb6a2f28a Check dependencies in reuse
Signed-off-by: Valerij Maljulin <vmaljuli@redhat.com>
2019-07-31 11:23:52 +02:00
Chenxiong Qi
308f5bc7cf Serialize component build state trace correctly if state is None
Fixes #1179

Signed-off-by: Chenxiong Qi <cqi@redhat.com>
2019-07-29 15:56:30 +08:00
Jan Kaluža
26c816f04c Merge #1356 Refactor make_module for tests 2019-07-23 10:50:19 +00:00
Qixiang Wan
ab8abef058 Fix recover_orphaned_artifact for module-build-macros
When recover_orphaned_artifact is called for module-build-macros
and the module-build-macros is not tagged in the -build Koji tag,
then the tag_artifacts() is called to tag it there.

This is correct, but the issue is that module-build-macros need
to be added to "build" and "srpm-build" Koji tag groups, otherwise
it is not installed in the buildroot by default.
2019-07-23 16:11:27 +08:00
Chenxiong Qi
b242b12136 Remove handling of negative deps in _deps2reqs
Fixes #1338

Signed-off-by: Chenxiong Qi <cqi@redhat.com>
2019-07-22 15:24:07 +08:00
Chenxiong Qi
5017fbae7f Refactor make_module for tests
The original motivation for this refactor is to reuse make_module and
drop TestMMDResolver._make_mmd. Some tests require a modulemd created
and some tests also require those modulemd to be stored into database as
a module build. The problem is db_session has to be passed to
make_module even if no need to store into database.

Major changes in this patch:

* Argument db_session is optional.
* Arguments requires_list and build_requires_list are replaced by a
  single argument dependencies which is a list of group of requires and
  buildrequires
* A new make_module_in_db is created for creating and storing the new
  modulemd into database conveniently.
* Tests are updated with the new make_module and make_module_in_db.

Signed-off-by: Chenxiong Qi <cqi@redhat.com>
2019-07-22 10:07:53 +08:00
Chenxiong Qi
f5717e3469 Fix incorrect error message and method call on ComponentRpm
When resubmitting a module build, if some component is found out that
its attributes have changed, MBS will raise an error to stop the work to
recording components. The problem is original code tells a module build
exists in database already rather than a component build, meanwhile
get_module_name() call on an ComponentRpm object is also incorrect.

Signed-off-by: Chenxiong Qi <cqi@redhat.com>
2019-07-18 22:09:45 +08:00
Chenxiong Qi
26033bd8f7 Reuse ComponentBuild.from_component_name in tests
Signed-off-by: Chenxiong Qi <cqi@redhat.com>
2019-07-18 22:09:41 +08:00
Chenxiong Qi
3878affa41 Separate use of database sessions
This patch separates the use of database session in different MBS components
and do not mix them together.

In general, MBS components could be separated as the REST API (implemented
based on Flask) and non-REST API including the backend build workflow
(implemented as a fedmsg consumer on top of fedmsg-hub and running
independently) and library shared by them. As a result, there are two kind of
database session used in MBS, one is created and managed by Flask-SQLAlchemy,
and another one is created from SQLAclhemy Session API directly. The goal of
this patch is to make ensure session object is used properly in the right
place.

All the changes follow these rules:

* REST API related code uses the session object db.session created and
  managed by Flask-SQLAlchemy.
* Non-REST API related code uses the session object created with SQLAlchemy
  Session API. Function make_db_session does that.
* Shared code does not created a new session object as much as possible.
  Instead, it accepts an argument db_session.

The first two rules are applicable to tests as well.

Major changes:

* Switch tests back to run with a file-based SQLite database.
* make_session is renamed to make_db_session and SQLAlchemy connection pool
  options are applied for PostgreSQL backend.
* Frontend Flask related code uses db.session
* Shared code by REST API and backend build workflow accepts SQLAlchemy session
  object as an argument. For example, resolver class is constructed with a
  database session, and some functions accepts an argument for database session.
* Build workflow related code use session object returned from make_db_session
  and ensure db.session is not used.
* Only tests for views use db.session, and other tests use db_session fixture
  to access database.
* All argument name session, that is for database access, are renamed to
  db_session.
* Functions model_tests_init_data, reuse_component_init_data and
  reuse_shared_userspace_init_data, which creates fixture data for
  tests, are converted into pytest fixtures from original function
  called inside setup_method or a test method. The reason of this
  conversion is to use fixture ``db_session`` rather than create a
  new one. That would also benefit the whole test suite to reduce the
  number of SQLAlchemy session objects.

Signed-off-by: Chenxiong Qi <cqi@redhat.com>
2019-07-18 21:26:50 +08:00
Jan Kaluža
64698fbde8 Merge #1348 Reset FakeModuleBuilder.on_get_task_info_cb properly for TestBuild 2019-07-18 10:48:48 +00:00
Jan Kaluža
1c76f1223e Merge #1335 Call _get_base_module_stream_overrides when the module is not the input module 2019-07-18 10:38:27 +00:00
Chenxiong Qi
f4c5334894 Reset FakeModuleBuilder.on_get_task_info_cb properly for TestBuild
Signed-off-by: Chenxiong Qi <cqi@redhat.com>
2019-07-17 22:12:41 +08:00
mprahl
1bcb40d4d0 Allow specifying a specific module build to reuse components from
This resolves #1296.
2019-07-16 11:40:59 +00:00
mprahl
0466ac394b Call _get_base_module_stream_overrides when the module is not the input module
This just simplifies the code. It doesn't change the functionality
at all. The tests had to be changed because it assumed that the
xmd.mbs.buildrequires section would be filled out for the input
module which isn't true.
2019-07-15 13:17:36 -04:00
mprahl
ec8946af05 Use get instead of filter_by in test_poller.py to be consistent
This is based on the feedback in PR #1341
2019-07-15 11:22:24 -04:00
mprahl
18def28d2b Fix the unit tests when running with Postgresql 2019-07-15 11:06:52 -04:00
Luiz Carvalho
e35596b6f2 Remove duplicated build refresh from tests
Signed-off-by: Luiz Carvalho <lucarval@redhat.com>
2019-07-12 14:12:15 -04:00
Luiz Carvalho
302e905f49 Rename trigger_new_repo_when_stalled accurately
Signed-off-by: Luiz Carvalho <lucarval@redhat.com>
2019-07-12 14:12:15 -04:00
Luiz Carvalho
9e50e9e268 Do not start newRepo task if one in progress
Signed-off-by: Luiz Carvalho <lucarval@redhat.com>

Check task status on producer - to be squashed

Signed-off-by: Luiz Carvalho <lucarval@redhat.com>
2019-07-12 14:12:15 -04:00
mprahl
82ec6944c6 Prevent overlapping RPMs from buildrequired base modules from being available when using default modules
When using default modules, this feature will add conflicts to
module-build-macros for every RPM in a buildrequired base module
that overlaps with RPMs in the buildrequired modules. This will
prevent them from being available in the buildroot, and thus
ensure that the RPMs from the buildrequired modules (non-base
modules) are used even if they have a lower NVR.
2019-07-11 09:21:09 -04:00
Jan Kaluža
b3c32ec859 Merge #1294 Allow modules built against platform in 'garbage' state to be used as build dependency. 2019-07-10 09:21:30 +00:00