Commit Graph

2397 Commits

Author SHA1 Message Date
Chenxiong Qi
9d6a34a8e4 Show state name in state transition log
This will show log like "State transition: init -> wait, ...", which is
much straightforward than showing state number "state 1->2".

Signed-off-by: Chenxiong Qi <cqi@redhat.com>
2019-07-18 22:57:42 +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
Jan Kaluža
d041805986 Merge #1326 improve the reliability of the integration tests 2019-07-18 10:34:50 +00:00
mprahl
dae4f10189 Clean up the change log 2019-07-17 15:52:38 -05: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
1cb1e65767 Release v2.25.0 v2.25.0 2019-07-17 08:24:26 -05:00
mprahl
f2f033e66f Use mmd_to_str in _createrepo to reduce code duplication 2019-07-17 07:11:34 -05:00
Owen W. Taylor
886bd34c55 MockModuleBuilder.py: Fix for libmodulemd v2
With v2 of the libmodulemd API, writing a module to a string requires
creating a Modulemd.ModuleIndex object.
2019-07-17 07:11:34 -05:00
mprahl
280a25b939 Support base modules with virtual streams and no stream version 2019-07-16 14:21:49 +00: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
6c4d6ee2b4 Alphabetize the build parameters in the documentation 2019-07-16 11:40:59 +00:00
Chenxiong Qi
bd0a2bbdc2 Give a unique name to postgres database container
Signed-off-by: Chenxiong Qi <cqi@redhat.com>
2019-07-16 09:51:02 +08:00
Chenxiong Qi
5baaeb2fc7 Give a unique name to container running tests inside
Signed-off-by: Chenxiong Qi <cqi@redhat.com>
2019-07-16 09:44:32 +08: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
mprahl
4891716c2d Default the cache directory to the "mbs" directory under tempfile.gettempdir() 2019-07-10 19:01:43 -04:00
Mike Bonnet
3681b66ff8 remove Declarative options from Scripted pipelines
These options don't work in Scripted pipelines, and cause tracebacks.
2019-07-10 08:29:22 -07:00
mprahl
ddafbb86ff Allow the poller to clean up module builds without arches 2019-07-10 13:29:58 +00: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
Jan Kaluza
8301aeb9eb Return the latest base module in case stream_version_lte is used, but stream is not in x.y.z format.
This seems to be better behaviour than simply rejecting the module build
completely. MBS still shows warning in the log that it cannot find
any compatible module, but the build continues with the base module
requested in the submitted modulemd.
2019-07-10 10:41:21 +02:00
Jan Kaluza
e9f5b4e2db Fix unreliable test in test_module_init.py. 2019-07-09 11:26:02 +02:00
Jan Kaluza
95febc2e1b Allow modules built against platform in 'garbage' state to be used as build dependency. 2019-07-09 07:35:01 +02:00
mprahl
96d44d049e Add the ability to automatically buildrequire default modules defined by the buildrequired base module
A base module can set xmd.mbs.default_modules_url, which contains a
URL to a list of modules in the format of name:stream separated by
new lines. When a module buildrequires this base module, the list
of default modules are added as buildrequires of the module automatically
unless there are conflicting streams or the default module is not
in the MBS database.
2019-07-05 14:52:50 -04:00
Mike Bonnet
934bc4bd05 wrap checkouts in retry(5)
Avoid failing jobs due to temporary errors when checking out from Pagure. This
should help work around transient DNS/network failures.
2019-07-03 18:16:52 -07:00
Mike Bonnet
30df0a82ca optimize checkouts
Only checkout exactly the code we need to run the tests. This should help work around
errors and timeouts (early EOF/index-pack failed) from Pagure. Jenkins seems to require
a minimum of depth=2 or it fails when walking the revision history.

Using a shallow clone is safe for PRs because we're always building from the head of
the PR branch (OpenShift doesn't have a way to specify a non-head commit on a PR branch).

When building from the master branch we use depth=10 to avoid a race condition in case
multiple commits have been pushed in quick succession. The integration test job is
launched using the exact revision of the code that was used to build the images, to
ensure the results are valid.
2019-07-03 18:16:30 -07:00
Mike Bonnet
e91cf37bf7 ignore PRs that aren't Open
Sometimes it is necessary recreate the Jenkins PR polling job, or
cleanup old runs. This can cause Jenkins to lose the record of which
PRs it has already seen, and retest old PRs which are long closed.
This change causes the polling job to check the state of the PR, and
ignore it if it isn't Open. Testing PRs which are in any other state
doesn't provide any value.
2019-07-03 11:55:18 -07:00
mprahl
9f55ce724d Add a global requests session with retry logic configured
This also replaces the usage of other request sessions.
2019-07-03 09:00:49 -04:00
mprahl
db03f0a7f5 Promote resolver._get_module to a public method 2019-07-02 10:45:31 -04:00
Matt Prahl
1585d6b97c Merge #1319 Reuse method read_staged_data and ModuleBuild.get_by_id 2019-07-02 14:15:44 +00:00
Chenxiong Qi
60b0e8da5c Wait for Postgres to be running before starting the unit tests
Fixes #1314

Signed-off-by: Chenxiong Qi <cqi@redhat.com>
2019-07-02 20:54:26 +08:00
Chenxiong Qi
16bf4e945b Reuse ModuleBuild.get_by_id
Signed-off-by: Chenxiong Qi <cqi@redhat.com>
2019-07-02 20:52:12 +08:00
Chenxiong Qi
c15a7cadf3 Reuse function read_staged_data
In addition, reuse staged_data_filename to construct file and directory name.

Signed-off-by: Chenxiong Qi <cqi@redhat.com>
2019-07-02 20:52:12 +08:00
Valerij Maljulin
a80f15a6d3 Release v2.24.0 v2.24.0 2019-07-02 13:43:47 +02:00
Valerij Maljulin
7277ac480f Release v2.22.0 2019-07-01 17:26:31 +02:00
mprahl
50f0a60ec1 Allow configuring the number of parallel submissions to Koji
When NUM_CONCURRENT_BUILDS is 0, then multi-threading is disabled
when submitting builds to Koji. This is not acceptable, so this
commit makes the number of threads configurable.
2019-07-01 08:12:12 -04:00
Chenxiong Qi
fadbc26994 Enable PostgreSQL for running tests
Signed-off-by: Chenxiong Qi <cqi@redhat.com>
2019-06-28 21:35:00 +08:00
Matt Prahl
f3fecf5089 Merge #1309 Fix tests in order to run with PostgreSQL 2019-06-28 13:21:08 +00:00
Matt Prahl
1282a775a0 Merge #1310 Fix type error preventing inclusion of custom SRPMs when running on F31/Rawhide. 2019-06-28 12:49:10 +00:00
Chenxiong Qi
e49f69f7b5 Fix tests in order to run with PostgreSQL
Most of the issues are caused by the use of SQLAlchemy database session. Some
inline comments describe the issues in detail.

Signed-off-by: Chenxiong Qi <cqi@redhat.com>
2019-06-28 14:48:37 +08:00
Merlin Mathesius
9f269c39e1 Older versions of kobo.rpmlib.get_header_field() return bytes, newer versions
return str. Decode as necessary.

Signed-off-by: Merlin Mathesius <mmathesi@redhat.com>
2019-06-27 10:44:58 -05:00
Mike Bonnet
302c76b90f add more information to the Pagure commit flags and PR status
This makes them more consistent with CentOS CI flags.

Also add the commit hash to the uid, so updates are commit-specific.
2019-06-25 21:41:38 -04:00
Valerij Maljulin
f0dc0b851d Add state_reason on GW failure
Signed-off-by: Valerij Maljulin <vmaljuli@redhat.com>
2019-06-25 17:39:40 +02:00
Matt Prahl
cde8d8058d Merge #1304 Add additional documentation about rebuild strategies 2019-06-25 14:29:52 +00:00