92 Commits

Author SHA1 Message Date
Chenxiong Qi
2101f38e63 Run tests in in-memory SQLite db
Signed-off-by: Chenxiong Qi <cqi@redhat.com>
2019-11-14 15:20:21 +08:00
mprahl
8c6cfb702d Use small license headers in the Python files
This also removes the outdated comments around authorship of each
file. If there is still interest in this information, one can just
look at the git history.
2019-10-03 08:47:24 -04: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
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
mprahl
4891716c2d Default the cache directory to the "mbs" directory under tempfile.gettempdir() 2019-07-10 19:01:43 -04:00
Chenxiong Qi
630f7b4e18 Allow to run tests with PostgreSQL inside container
This patch introduces a new environment variable in order to allow running
tests with different database backend. This is useful particularly for running
tests inside container. With this change, it is possible run tests in following
combinations:

* Python 2 and SQLite
* Python 3 and SQLite
* Python 2 and PostgreSQL
* Python 3 and PostgreSQL

Package python-psycopg2 is installed in both Dockerfile-tests and
Dockerfile-tests-py3 in case of running tests with PostgreSQL.

A new script contrib/run-unittests.sh is added to make it easy to run tests. An
example:

    contrib/run-unittests.sh --py3 --with-pgsql

that runs tests with Python 3 and PostgreSQL.

Signed-off-by: Chenxiong Qi <cqi@redhat.com>
2019-06-17 22:47:23 +08:00
Valerij Maljulin
1b486b1625 Greenwave query class and configuration update
Signed-off-by: Valerij Maljulin <vmaljuli@redhat.com>
2019-04-29 18:15:23 +02:00
mprahl
66c3f82160 Format the coding style across the codebase using "black" and manual tweaks
The main benefit of this commit is that the use of double quotes
is now consistent.
2019-04-26 00:32:13 -04:00
Chenxiong Qi
7c993f9165 Handle streams in base module stream
A base module's stream (the platform for RHEL) could have Z-stream suffix, e.g.
el8.0.0.z, this patch handles this Z-stream suffix and other potential streams
by returning the stream version as a float with configured suffix value. For
example, el8.1.0.z would be parsed as 080100.1. Note that, the 0.1 is totally
configured in config and it actually could be any value according to concrete
cases in practice.

Config STREAM_SUFFIXES is enabled in TestConfiguration so that tests depending
on the return value from ModuleBuild.get_stream_version are covered.

Part fixture of test TestMMDResolver.test_solve_virtual_streams is updated by
adding Z-stream suffix to platform:el8.2.0 in order to ensure this patch does
not break the MMD resolver.

Addresses FACTORY-4307

Signed-off-by: Chenxiong Qi <cqi@redhat.com>
2019-04-23 11:21:46 +08:00
mprahl
d6d0c870fc Disable Greenwave gating by default 2019-04-04 13:16:33 -04:00
Jan Kaluza
4bc6e7ed65 Set the $releasever variable in Mock config. 2019-04-02 14:04:16 +00:00
Jan Kaluza
1c535fa755 Set the module_platform_id in the yum.conf 2019-04-01 13:13:08 +00:00
Jan Kaluza
360a8f3b84 Add support for local component repository using file://.
This is needed for offline local builds to build a component which is
stored on local git repository.

This PR also adds OfflineLocalBuildConfiguration configuration class
for offline local builds to set the RESOLVER.
2019-04-01 13:13:08 +00:00
Jan Kaluza
67a5a9d1b0 Allow building module in --offline module with dependencies from local repositories.
There are following changes introduced in this commit:

- The `koji_tag` of module builds imported from the local repositories
  is now in `repofile:///etc/yum.repos.d/some.repo` format to store the
  repository from which the module was imported to local MBS DB.
- The `koji_tag` of fake base module is set to empty `repofile://`
  and in `MockModuleBuilder` the `conf.base_module_repofiles` list
  is used as source for the repositories defining platform. We can't
  simply use single repository, because there might be fedora.repo
  and fedora-update.repo and so on.
- The list of default .repo files for platform are passed using the
  `-r` switch in `build_module_locally` `mbs-manager` command.
- The LocalResolver (subclass of DBResolver) is added which is used
  to resolve the build dependencies when building modules offline
  locally.
- The `MockModuleBuilder` enables the buildrequired modules and
  repositories from which they come in the mock config.

With this commit, it is possible to build testmodule locally
without any external infra.
2019-04-01 13:13:08 +00:00
Merlin Mathesius
dd950857ec Update koji tagging for scratch modules.
Signed-off-by: Merlin Mathesius <mmathesi@redhat.com>
2019-03-01 10:27:04 -06:00
Merlin Mathesius
f2e7a8db07 Add web request options 'scratch' and 'srpms' for module scratch builds.
Signed-off-by: Merlin Mathesius <mmathesi@redhat.com>
2019-03-01 10:27:04 -06:00
mprahl
9f9a025958 Use the https protocol to clone dist-git repos instead of the git protocol
You can read about this at:
https://fedoraproject.org/wiki/Infrastructure/HTTPS-commits

The bug was reported at:
https://bugzilla.redhat.com/show_bug.cgi?id=1666257
2019-01-16 19:00:25 +00:00
mprahl
7f82275114 Force the use of a separte Kerberos cache per thread
When using a single Kerberos cache that is shared among threads,
Koji logins start failing because the cache gets corrupt. This uses
the Linux kernel keyring to store a Kerberos cache per MBS thread.

See https://web.mit.edu/kerberos/krb5-1.12/doc/basic/ccache_def.html
2018-12-12 19:04:00 -05:00
Valerij Maljulin
6b7ea33d18 limit Koji build architectures
Fixes issue #869

Signed-off-by: Valerij Maljulin <vmaljuli@redhat.com>
2018-11-12 12:44:52 +01:00
Valerij Maljulin
7f60db545a renaming koji_arches to arches
Signed-off-by: Valerij Maljulin <vmaljuli@redhat.com>
2018-10-15 15:29:50 +02:00
Filip Valder
598347e1b6 Import module API 2018-09-07 17:12:01 +02:00
Ralph Bean
e7089d7be0 Rename this to be PDC-agnostic. 2018-09-04 09:51:56 -04:00
Ralph Bean
0aff640ef3 Optionally, block building modules with EOL streams.
Requested by @mboddu in:

- https://pagure.io/fm-orchestrator/issue/960
- https://pagure.io/modularity/issue/102
2018-08-31 15:23:04 -04:00
Martin Curlej
dfe7660519 Removed PDC dependency from MBS and replaced it with MBS prod instance.
Signed-off-by: Martin Curlej <mcurlej@redhat.com>

Removed pdc from comments.

Signed-off-by: Martin Curlej <mcurlej@redhat.com>

Adding missing files.

Signed-off-by: Martin Curlej <mcurlej@redhat.com>

Updated PR according to review.

Signed-off-by: Martin Curlej <mcurlej@redhat.com>

Local modules builds now

Signed-off-by: Martin Curlej <mcurlej@redhat.com>

Removed copr from config

Signed-off-by: Martin Curlej <mcurlej@redhat.com>

Fixed bugs

Signed-off-by: Martin Curlej <mcurlej@redhat.com>
2018-07-04 10:13:18 +02:00
mprahl
36a9026ca8 Remove references to COPR 2018-06-28 10:00:06 -04:00
mprahl
bed9bf7a87 Remove the dependency on python-systemd 2018-04-03 09:58:57 -04:00
mprahl
eb0b2e1c38 Add the database resolver plugin 2018-04-03 09:58:57 -04:00
Matt Prahl
e1ed09d0a2 Merge #860 Decrease time.sleep times in tests to save 60 seconds for test-suite run. 2018-02-08 15:40:45 +00:00
Jan Kaluza
683056de0a Decrease time.sleep times in tests to save 60 seconds for test-suite run. 2018-02-08 09:03:32 +01:00
Jan Kaluza
4001d3c488 Use in-memory SQLite database in tests to make them 40% faster. 2018-02-08 08:01:24 +01:00
mprahl
df594da8a5 Remove the Koji proxyuser functionality 2018-01-30 11:49:03 -05:00
Ralph Bean
c21f1d34a3 Faster SCM tests.
Fixes #832.

The slow tests there are hobbled by this `retry(...)` decorator with hardcoded
timeouts.  We want those to be relatively long in prod and relatively short in
test and dev.
2018-01-15 16:30:52 -05:00
mprahl
0e401cdab9 Default dev configuration to build modules locally 2017-11-13 14:09:07 -05:00
Jakub Kadlcik
f098e6e3b7 Make the module build log name configurable 2017-11-07 00:04:14 +01:00
Martin Curlej
60b3d97c97 flake8 cleanup
Signed-off-by: Martin Curlej <mcurlej@redhat.com>

removed some noqa tags
2017-10-25 12:13:59 +02:00
Igor Gnatenko
6f408111ac allow any SCM URLs for local builds
Signed-off-by: Igor Gnatenko <ignatenkobrain@fedoraproject.org>
2017-10-04 17:18:23 +02:00
Ralph Bean
0e9ccb1895 Remove old SSL config options.
We used to do x509 authn a long time ago.  We have since stopped doing
that, but we kept all of thise confusing SSL/TLS support stuff.

This removes all that, and fixes #685.
2017-10-04 11:37:17 +02:00
Jan Kaluza
54a80a677a Fix wrong escaping in mock.cfg - fixes the local builds 2017-09-18 13:28:15 +02:00
Ralph Bean
fa8ac2001d Merge #681 Add Kerberos + LDAP Authentication 2017-09-15 16:10:22 +00:00
mprahl
0f6d7a55c5 Add Kerberos + LDAP authentication support 2017-09-15 12:02:57 -04:00
Filip Valder
be7c8d7aff Fix #661: mbs hard-codes x86_64 as the local architecture 2017-09-15 15:18:02 +02:00
Filip Valder
f86654c655 Fix #641 - mock configuration is hardcoded 2017-09-13 15:09:56 +02:00
Ralph Bean
6cb836c862 Nope.
Dead.
2017-09-08 14:49:58 -04:00
Filip Valder
7ef2975984 PEP8 fixes 2017-07-17 18:29:10 +02:00
Ralph Bean
932dc09c2a No reason for this default. 2017-07-10 20:13:58 -04:00
Stanislav Ochotnicky
747b60f4b4 Add build logs into the koji content generator
This change adds another output next to the mmd file - a build.log which
will contain builds collected during the module build
2017-07-03 13:07:43 +02:00
Jan Kaluza
4b16cf9a64 Fix various bugs in 'mbs-build local' 2017-06-07 13:16:26 +02:00
Ralph Bean
2ab6193987 Rename consecutive to concurrent.
Fixes #574.
2017-05-31 13:54:11 -04:00
Stanislav Ochotnicky
b33beb0cef Enable koji content generator code
If the koji_enable_content_generator is configured to True koji instance
has to be configured as follows:
koji call addBType module
koji grant-cg-access <mbs-user> module-build-service --new

Without the above configuration MBS will start failing the builds
2017-05-31 14:48:34 +02:00
Jan Kaluža
f441077706 Merge #515 Add config option for allowing custom scmurls 2017-05-02 12:57:48 +00:00