942 Commits

Author SHA1 Message Date
Owen W. Taylor
ad4927fd01 Add a script to check the dist tarball, and use it to fix the dist tarball
* Add a script make-dist-tarball.py that runs 'setup.py sdist' and compares
  what gets distributed with git and with a set of patterns of extra files
  added during distribution, and with git files that we don't want to
  distribute.

* Extend MANIFEST.in or add __init__.py files to distribute:

   run-unittests.sh
   tox.in
   conf/client_secrets.json
   tests/test_builder
   tests/integration

* Don't include all of module_build_service - this is too prone to backup
  files and development trash files; instead add just the files we need
  that aren't *.py

* Move global-excludes to the end - they modify the existing list of files;
  and add *.db - for some reason, .mbs_local_build.db files were
  getting disted.
2023-04-04 16:07:10 +00:00
Mike McLean
38c42c5156 use double quotes 2023-03-23 13:26:11 +00:00
Mike McLean
1870748249 provide missing fields in api 2023-03-23 13:26:11 +00:00
Owen W. Taylor
113e806ae5 test_mock.py: fix NVR's in fake rpm -qf output
The rpm -qf call in KojiContentGenerator.__get_rpms has VERSION and
RELEASE separated by a space, not a -.
2023-03-20 16:30:52 +00:00
Owen W. Taylor
ba82e8b5a6 test_mock.py: refactor test case setup
To clean things up and facilitate future changes to test cases, split
the method for creating a builder apart from the fixture so that it can
be used independently.
2023-03-20 16:30:52 +00:00
Owen W. Taylor
e776a77048 Redirect createrepo_c output to the build logs
It's more useful to have the createrepo_c output in the build logs
than cluttering the build stdout.
2023-03-20 10:58:59 -04:00
Owen W. Taylor
cff90e587a builder/utils/execute_cmd: remove useless return value and add a test
Since we never pass in subprocess.PIPE for stdin/stdout/stderr,
subprocess.communicate() does nothing, and the return out/err tuple
was always empty.
2023-03-20 10:57:52 -04:00
Owen W. Taylor
35086174ba Pass koji_tag to get_built_rpms_in_module_build()
For local builds, required modules are not necessarily in the local
database, so the method of looking up the build to find the koji tag
doesn't work reliably. However, the caller has the koji_tag - so just
pass it in.
2023-03-15 17:53:38 +00:00
Owen W. Taylor
646b0590ee MBSConsoleHandler: show status of ongoing repository downloads
When downloading files from Koji to make a local repository, display
a temporary status of which files are being displayed to the console
appended after any log messages. Updates are done by erasing the status
that was written, adding a log message, then writing the status again.
2023-03-15 17:16:24 +00:00
Owen W. Taylor
f5100609aa Filter console output through a special handler
When running in local mode, add a special handler that filters log
messages to the console to produce attractive output. Implemented
behaviors include:

 - INFO level messages are only displayed if done through
   MBSLogger.console() rather than MBSLogger.info().
 - Timestamps and thread names are omitted unless the local build
   is started with the -d option
 - Warning/error messages have the level highlighted in red
 - Special handling can be added to log messages, initially:
    - Long running operations can be displayed to the console as
      "Doing foo ... <pause>done"
2023-03-15 17:16:24 +00:00
Mike McLean
f6dcf6c346 switch to using gssapi_login for koji
Fixes https://pagure.io/fm-orchestrator/issue/1777

koji recently dropped this old call
https://pagure.io/koji/pull-request/3599

Previously, koji was ignoring the ctx arg and wrapping gssapi_login,
so this change is completely equivalent to the old behavior.
2023-02-22 10:22:53 -05:00
Owen W. Taylor
88c138084c Test more code paths in create_local_repo_from_koji_tag 2023-02-21 16:47:24 +00:00
Owen W. Taylor
8ab293dc9e test_start_next_batch_build_repo_building: actually try to start the batch 2023-02-21 16:47:24 +00:00
Brendan Reilly
f12fc9c969 Use click instead of flask script 2022-12-13 13:31:56 -05:00
Mike McLean
9287297943 fix unit test 2022-11-08 19:23:33 -05:00
Mike McLean
46f4f449a8 partial work 2022-11-08 14:39:24 -05:00
Mike McLean
d1180871de fix unit test 2022-11-08 14:39:24 -05:00
Brendan Reilly
79e3eae43e Add delay to missed new repo check 2022-09-02 12:01:34 -04:00
Brendan Reilly
3231d3584c Merge #1675 Don't traceback on failed builds 2022-05-19 18:30:20 +00:00
Brendan Reilly
687191681d Merge #1673 Improve exception and SIGINT handling for tests/test_build 2022-05-16 18:33:59 +00:00
Brendan Reilly
c24038198e Merge #1672 Don't pass SQLAlchemy objects between threads 2022-05-13 16:47:07 +00:00
Brendan Reilly
f4040c09f4 Merge #1670 Go back to using a file-backed SQLite database for tests 2022-05-03 18:35:13 +00:00
Brendan Reilly
1da34c1649 Merge #1662 Improve test coverage for MockModuleBuilder 2022-05-03 16:43:27 +00:00
Brendan Reilly
6b76877d6d Merge #1661 MBSResolver - caching, tests, fixes 2022-05-03 16:42:22 +00:00
Owen W. Taylor
d050108d13 MBSResolver: cache results of MBS queries
Use dogpile.cache to avoid repeatedly making the same queries to the MBS.

We frequently query a list of modules, and then later in the build go
back and ask for details of those modules again by nsvc, so special case
querying a single module by nsvc and prime the cache for this from lists
of results.
2022-04-29 15:49:19 -04:00
Owen W. Taylor
c27e77c59d MBSResolver: improve efficiency of querying latest version
Only get 5 results at a time, and if we see that we're already
retrieving an old versions, stop requesting more pages.
2022-04-29 15:47:08 -04:00
Owen W. Taylor
31fca9a962 100% test coverage for MBSResolver.py
Add new tests and modify existing tests so that test_mbs.py entirely
covers MBSResolver.py. To make the tests simpler, change from
explicitly expectations about the MBS API request => response sequence
to a stub local implementatin of the MBS API.
2022-04-29 15:47:08 -04:00
Owen W. Taylor
7761bbf5b4 Tweak behavior of get_compatible_base_module_modulemds
Fix some oddities in the DBResolver implementation of
get_compatible_base_module_modulemds() and make the MBSResolver version -
which was previously just buggy - match that. (Tests for the MBSResolver
version are added in a subsequent commit.)

 * If an empty virtual_streams argument was passed in, *all* streams
   were considered compatible. Throw an exception in this case - it
   should be considered an error.
 * If stream_version_lte=True, but the stream from the base module
   wasn't in the form FOOx.y.z, then throw an exception. This was
   previously treated like stream_version_lte=False, which is just
   a recipe for confusion and mistakes.

test_get_reusable_module_use_latest_build() is rewritten to
comprehensively test all possibilities, including the case that changed
above.

test_add_default_modules_compatible_platforms() is changed to run
under allow_only_compatible_base_modules=False, since it expected
Fedora-style virtual streams (versions not in FOOx.y.z form, all
share the same stream), which doesn't make sense with
allow_only_compatible_base_modules=True.
2022-04-29 15:47:08 -04:00
Owen W. Taylor
e5c51d924f Don't traceback on failed builds
Just failing a build isn't a reason to die with a traceback - exit with
a status instead.

Fixes: #1364
2022-04-26 17:20:49 -04:00
Owen W. Taylor
0d0d8091ac test_build: leave Control-C working
Two problems occurred with the moksha/twisted handling of SIGINT:

 * While KeyboardInterrupt caused the moksha loop to exit, it just
   left the test in a confused state, instead of triggering standard
   pytest behavior and aborting the entire test run.
 * The handler was left-over for remaining tests that prevent Control-C
   from working at all.

Fix that by using mock.patch to override moksha's signal handler with
our own signal handler that stores the KeyboardInterrupt in the
current EventTrap, and restores the default signal handler after
the loop ends.

Note that since the KeyboardInterrupt is always handled in the main thread,
we don't get a useful backtrace from the child thread.
2022-04-26 17:12:16 -04:00
Owen W. Taylor
4ddd3c2637 test_build: exit rather than hanging on event handler exception
Event handlers decorated with @celery_app_task don't raise an exception -
they just log the exception, leaving the Moksha hub running. This meant
that any failures in test_build would result in the test suite hanging
rather than failing usefully.

We solve this by adding a new class EventTrap which acts as a context
manager. Any exceptions that occur in event handlers are set on the
current EventTrap, and the test_build tests re-raise the exception.
2022-04-26 17:12:16 -04:00
Owen W. Taylor
5dcd63ebf9 batches.py: Don't pass SQLAlchemy objects between threads
SQLAlchemy objects can't be used from multiple threads - so when starting
threads for builds, pass the ComponentBuild id rather than the object.
(Note that despite the comment that the threads were sharing a session,
they weren't - what was passed to the thread was a scoped_session that
acts as a separate thread-local session per-thread.)

BUILD_COMPONENT_DB_SESSION_LOCK - a threading.Lock() object that was used
in a few places - but not nearly enough places to effectively lock usage
of a shared session - is removed.
2022-04-26 17:04:40 -04:00
Owen W. Taylor
a96774a1fd Go back to using a file-backed SQLite database for tests
Using a memory database causes tests/test_build to intermittently
fail, because using the same pysqlite3 connection object from multiple
threads - as was done so that the threads shared the same memory database
- is not, in the end, thread safe. One thread will stomp on the transaction
state of other threads, resulting in errors from starting a new transaction
when another is already in progress, or trying to commit a transaction
that is not in progress.

To avoid a significant speed penalty, the session-scope fixture sets up
a database in the pytest temporary directory, which will typically be on
tmpfs. Time to complete all tests:

 memory backend:               38 seconds
 file on tmpfs:                40 seconds
 file on nvme ssd with btrfs: 137 seconds

MBSSQLAlchemy, which attempted to make the memory backend work, is removed.

Session hooks are installed on the Session class rather than on the
scoped_session instance - this works better when we're changing from
one database to another at test setup time.
2022-04-26 16:59:59 -04:00
Owen W. Taylor
9c1fc386ff Improve test coverage for MockModuleBuilder
Test coverage for this file improves from 55% => 89%
2022-04-26 16:58:30 -04:00
Owen W. Taylor
1f2fbca7d4 Check dnf version before skipping base module conflicts
The base module conflict generation was skipped for local builds
in 6b2e5be93a because libdnf wasn't ported to libmodulemd yet -
that was done in libdnf-0.45, so only warn and skip for versions of
dnf too old to require libdnf-0.45.

(Don't just unconditionally skip check/warning in case someone is
doing local module builds on RHEL 8.)
2022-04-25 12:25:19 -04:00
Brendan Reilly
4a30847bea Remove Greenwave Code
No implementations of MBS are using Greenwave, and there are no current plans
to do so. Koji Resolver will be sufficient for any usecase dependent on gating.
2022-03-30 14:27:34 -04:00
Brendan Reilly
e7016b25ae Replace dashes with underscore in stream name integration test 2021-10-29 11:40:35 -04:00
Mike McLean
2f324d2ba1 fix unit test 2021-08-26 17:07:23 -04:00
Joe Talbott
06d31786e8 Improve error messaging for module submission.
Fixes: https://pagure.io/fm-orchestrator/issue/1098
2021-07-29 16:34:03 -04:00
Joe Talbott
933c4fd8dd Update error message. 2021-07-29 16:21:55 -04:00
Joe Talbott
6b42102cc6 Fail if requested side tag is not available for any base modules. 2021-07-29 16:21:55 -04:00
Brendan Reilly
669318f1fd Exclude specific platform streams from stream expansion
Fixes: #1639
2021-07-29 15:15:03 -04:00
Jan Kaluza
bfd9a13205 Allow overriding RPM components refs while submitting the module build.
There is a need to rebuild the module builds done in CentOS 9 Stream
internally in MBS to include them in RHEL. This is currenly a hard task,
because the RPM components included in a module are usually
taken from HEAD of the branch defined by their `ref` value.

For the rebuild task, it means we would have to ensure that the HEAD
of all RPM components points to right commit hash right before we start
rebuilding CentOS 9 Stream module in internal MBS. This is very hard
and fragile thing to do, especially if there are two different modules
using the RPM component from the same branch. This is prone to race
condition and makes the rebuilds quite complex and in some cases
not possible to do without force pushes to RPM component repositories
which is not acceptable by internal dist-git policy.

This commit fixes it by allowing overriding the commit hash while
submitting the module build. This helps in the mentioned situation,
because we can keep internal RPM components branches in 1:1 sync with
CentOS 9 Stream branches and HEAD can always point to the same commit
in both internal and CentOS 9 Stream repositories.

When the module rebuild is submitted in internal MBS,
we can use this new feature to override the `ref` for each RPM component
so it points to particular commit and the requirement for HEAD to point
to this commit is no longer there.

The `ref` is overriden only internally in MBS (but it is recorded in logs
and in XMD section), so the input modulemd file is not altered. This is
the same logic as used for other overrides (`buildrequire_overrides` or
`side_tag`).

This does not bring any security problem, because it is already possible
to use commit hash in `ref`, so the package maintainer can already change
the commit hash to any particular commit by using this `ref` value.

Signed-off-by: Jan Kaluza <jkaluza@redhat.com>
2021-07-28 08:48:12 +02:00
Joe Talbott
b3203caf76 List missing streams in exception message.
Fixes: https://pagure.io/fm-orchestrator/issue/1574
2021-06-25 15:49:09 -04:00
Martin Curlej
71a44bdfb6 Fixed scratch build suffix bug
When building a scratch build of a module with static context
the scratch suffix was added twice.

Signed-off-by: Martin Curlej <mcurlej@redhat.com>
2021-06-16 12:06:14 -04:00
Mike McLean
af97a23bca additional unit tests for strict_module_state_transitions 2021-06-15 15:05:06 -04:00
Mike McLean
fcd662468f fix unit tests 2021-06-15 15:05:06 -04:00
Mike McLean
d6185e806e new unit test 2021-05-06 13:43:30 -04:00
Mike McLean
53000c0783 fix unit test 2021-05-06 12:05:07 -04:00
Mike McLean
22ffe54b63 more flake8 fixes: integration tests 2021-04-21 16:31:48 -04:00