Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to create a solver test case #308

Merged
merged 1 commit into from
Jan 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 16 additions & 3 deletions doc/adoc/user_guide.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
[#art-suse-migration-services]

= Using the SUSE Distribution Migration System
Marcus Schäfer; Jesús Velázquez; Keith Berger
Marcus Schäfer; Jesús Velázquez; Keith Berger; Robert Schweikert

:toc:
:icons: font
:numbered:

:Authors: Marcus Schäfer, Jesús Bermúdez Velázquez, Keith Berger
:Authors: Marcus Schäfer, Jesús Bermúdez Velázquez, Keith Berger, Robert Schweikert
:Latest_Version: 1.2.0
:Contributors:
:Repo: https://github.com/SUSE/suse-migration-services[suse-migration-services]
Expand Down Expand Up @@ -312,7 +312,8 @@ verbose_migration: true|false

Enable the fix option for pre_checks::
If enabled (default), the run_pre_checks systemd process will use the `--fix`
option to automatically remediate applicable issues before the migration is started.
option to automatically remediate applicable issues before the migration
is started.
+
[listing]
----
Expand All @@ -332,6 +333,18 @@ independent initrd can be created by setting
build_host_independent_initrd: true|false
----

Configure Dependency Solver Test Case Generation::
It is possible that during the migration packages get installed that were not
on the system previously and are pulled in because of dependencies. This
setting will setup the migration such that a solver test case is generated.
The information form the test case can then be used to understand why a
given package was installed.
+
[listing]
----
debug_solver: true|false
----

== Run the Migration
Migration can be triggered either via run_migration or via reboot.

Expand Down
4 changes: 4 additions & 0 deletions suse_migration_services/defaults.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,3 +125,7 @@ def get_proxy_path():
@staticmethod
def get_zypp_config_path():
return '/etc/zypp/zypp.conf'

@staticmethod
def get_zypp_gen_solver_test_case():
return ''
3 changes: 3 additions & 0 deletions suse_migration_services/migration_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,9 @@ def get_migration_config_file_content(self):
def is_verbosity_requested(self):
return self.config_data.get('verbose_migration', False)

def is_zypp_solver_test_case_requested(self):
return self.config_data.get('debug_solver', False)

def _write_config_file(self):
with open(self.migration_config_file, 'w') as config:
yaml.dump(self.config_data, config, default_flow_style=False)
4 changes: 4 additions & 0 deletions suse_migration_services/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,9 @@
'pre_checks_fix': {
'required': False,
'type': 'boolean'
},
'debug_solver': {
'required': False,
'type': 'boolean'
}
}
8 changes: 7 additions & 1 deletion suse_migration_services/units/migrate.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,18 @@ def main():
log.info('Update env variables')
update_env(migration_config.get_preserve_info())
log_env(log)
verbose_migration = '--verbose' if migration_config.is_verbosity_requested() else '--no-verbose'
verbose_migration = '--no-verbose'
if migration_config.is_verbosity_requested():
verbose_migration = '--verbose'
solver_case = Defaults.get_zypp_gen_solver_test_case()
if migration_config.is_zypp_solver_test_case_requested():
solver_case = '--debug-solver'
if migration_config.is_zypper_migration_plugin_requested():
bash_command = ' '.join(
[
'zypper', 'migration',
verbose_migration,
solver_case,
'--non-interactive',
'--gpg-auto-import-keys',
'--no-selfupdate',
Expand Down
7 changes: 7 additions & 0 deletions test/data/migration-config-solver-case.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
debug_solver: true
preserve:
rules:
- /etc/udev/rules.d/a.rules
- /etc/udev/rules.d/b.rules
static:
- /etc/sysconfig/proxy
38 changes: 38 additions & 0 deletions test/unit/units/migrate_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ def setup(self, mock_get_migration_config_file):
mock_get_migration_config_file.return_value = \
'../data/migration-config-zypper-dup.yml'
self.migration_config_dup = MigrationConfig()
mock_get_migration_config_file.return_value = \
'../data/migration-config-solver-case.yml'
self.migration_config_solver_case = MigrationConfig()

@patch.object(Defaults, 'get_migration_config_file')
def setup_method(self, cls, mock_get_migration_config_file):
Expand Down Expand Up @@ -142,6 +145,7 @@ def test_main_zypper_migration_plugin(
'bash', '-c',
'zypper migration '
'--no-verbose '
' '
'--non-interactive '
'--gpg-auto-import-keys '
'--no-selfupdate '
Expand Down Expand Up @@ -174,6 +178,40 @@ def test_main_zypper_migration_plugin_verbose(
'bash', '-c',
'zypper migration '
'--verbose '
' '
'--non-interactive '
'--gpg-auto-import-keys '
'--no-selfupdate '
'--auto-agree-with-licenses '
'--allow-vendor-change '
'--strict-errors-dist-migration '
'--replacefiles '
'--product SLES/15/x86_64 '
'--root /system-root '
'&>> /system-root/var/log/distro_migration.log'
]
)

@patch('suse_migration_services.logger.Logger.setup')
@patch('suse_migration_services.command.Command.run')
@patch('suse_migration_services.units.migrate.log_env')
@patch('suse_migration_services.units.migrate.update_env')
@patch.object(MigrationConfig, 'get_migration_product')
@patch('suse_migration_services.units.migrate.MigrationConfig')
def test_main_zypper_migration_plugin_solver_case(
self, mock_MigrationConfig, mock_get_system_root_path,
mock_update_env, mock_log_env, mock_Command_run, mock_logger_setup
):
mock_MigrationConfig.return_value = self.migration_config_solver_case
mock_get_system_root_path.return_value = 'SLES/15/x86_64'
with patch('builtins.open', create=True):
main()
mock_Command_run.assert_called_once_with(
[
'bash', '-c',
'zypper migration '
'--no-verbose '
'--debug-solver '
'--non-interactive '
'--gpg-auto-import-keys '
'--no-selfupdate '
Expand Down
Loading