Commit Graph

7 Commits

Author SHA1 Message Date
Takashi Kajinami 2c27834add Get rid of 3rd party mock
... by replacing it by the built-in unittest.mock .

Change-Id: Ie853237d5c59730353d5ea4a7e61888e066614be
2024-02-02 11:29:25 +09:00
Ian Wienand 895fa69e75
python3.12: "fix" unittests
These are written to import the python utility into the unittest as a
module, which is then tested.  Python 3.12 removed "imp" which broke
this.

The documentation discusses using spec_from_file_location [2] for this
task, but one complication is that it only allows files with an
extension of .py to load like that ... so add an additional hack so
that the importlib loader will read the file.

[2] https://docs.python.org/3/library/importlib.html

Change-Id: I3c842b3a712ead6d2151b90171f9228caecedd11
2023-12-18 11:13:39 +11:00
Clark Boylan 788224cfe0 Don't remove packages that are requested to be installed
Recently the source-repositories element was updated [0] to set git as a
build-only dep. This is fine if you don't request to install git
elsewhere as a regular package install [1]. If you mix the two then git
gets uninstalled when you expect it to be installed.

Address this by checking if a package is already requested to be
installed when we find a removal or build-only request. Similarly remove
a package from the uninstall list if we ask for it to be installed
normally. This means that explicit installs override any cleanup
actions.

[0] https://review.opendev.org/#/c/745678/1/diskimage_builder/elements/source-repositories/package-installs.yaml
[1] https://opendev.org/openstack/project-config/src/branch/master/nodepool/elements/infra-package-needs/package-installs.yaml#L22

Change-Id: Idc1aa86f10cddcd4549066d8ea1d6df6fd906bac
2020-08-21 08:30:22 -07:00
Chris MacNaughton 8f57ed9b9e
Stop bringing the test environment into the mocks
Change-Id: I1780f186cf107242cacd6d3da7a5bc81a330b536
Closes-Bug: #1883224
2020-06-12 10:37:36 +02:00
Ian Wienand b71d1c60d2 package-installs : allow a list of parameters
The change Ia6f10741fa6be24b11d6991c8a6b6e07951ff68d introduced having
"when:" as a list of values.  However, this was actually not
sufficient to express the logic required for arm64/x86_64/xenial
kernel matching we wanted.

Because the package name is a key, we can't have multiple entires in
the package-map YAML files.  This means we can't do more advanced
matching and thus we need to be able to match through multiple
parameters.  Similar to Ia6f10741fa6be24b11d6991c8a6b6e07951ff68d we
modify the matching rules to allow a list.

A an example of using this is provided in the README.rst, and this
same example worked through by the unit tests.

This also slightly updates the matching logic to be more sequential.
After each check we either continue on or log the failure and continue
to the next check (rather than set a list of flags then check that at
the end).  This makes it much easier to understand what is being
matched in the logging output from the tool.

Change-Id: Idff7b067ad4255e6fc4138f7eff313a81b75c8ba
2020-05-27 06:17:57 +10:00
Ian Wienand 138d3f9b81 package-installs: allow when filter to be a list
Allow the "when:" statements to be a list of values, which are
effectively anded together to filter the package install.

Change-Id: Ia6f10741fa6be24b11d6991c8a6b6e07951ff68d
2020-05-21 14:03:49 +10:00
Ian Wienand c52c383f1b package-installs: provide for skip from env var
Provide a "when" option that provides for not installing packages
based on a = or != match on an environment variable.

Unit tests are added.

Change-Id: Ifa824dccaff69fd447f45d54cb4a3083bcabdd86
2018-11-30 10:02:47 +11:00