116 lines
4.4 KiB
Diff
116 lines
4.4 KiB
Diff
From 8a3a44457524f56daf0ee4b3db7dd7be9d4237c4 Mon Sep 17 00:00:00 2001
|
|
From: Tom Deseyn <tom.deseyn@gmail.com>
|
|
Date: Tue, 29 Mar 2022 11:44:28 +0200
|
|
Subject: [PATCH 12/39] Add actor that checks for obsolete .NET versions.
|
|
|
|
The actor checks for versions of .NET that are installed on the system,
|
|
and which are no longer available after the upgrade.
|
|
|
|
The unsupported versions are reported to the user.
|
|
This actor does not inhibit the upgrade.
|
|
---
|
|
.../el8toel9/actors/dotnet/actor.py | 40 +++++++++++++++++
|
|
.../actors/dotnet/tests/test_dotnet.py | 43 +++++++++++++++++++
|
|
2 files changed, 83 insertions(+)
|
|
create mode 100644 repos/system_upgrade/el8toel9/actors/dotnet/actor.py
|
|
create mode 100644 repos/system_upgrade/el8toel9/actors/dotnet/tests/test_dotnet.py
|
|
|
|
diff --git a/repos/system_upgrade/el8toel9/actors/dotnet/actor.py b/repos/system_upgrade/el8toel9/actors/dotnet/actor.py
|
|
new file mode 100644
|
|
index 00000000..d6e3e465
|
|
--- /dev/null
|
|
+++ b/repos/system_upgrade/el8toel9/actors/dotnet/actor.py
|
|
@@ -0,0 +1,40 @@
|
|
+from leapp import reporting
|
|
+from leapp.actors import Actor
|
|
+from leapp.libraries.common.rpms import has_package
|
|
+from leapp.models import InstalledRedHatSignedRPM, Report
|
|
+from leapp.tags import ChecksPhaseTag, IPUWorkflowTag
|
|
+
|
|
+UNSUPPORTED_VERSIONS = ['2.1', '3.0', '3.1', '5.0']
|
|
+
|
|
+
|
|
+class DotnetUnsupportedVersionsCheck(Actor):
|
|
+ """
|
|
+ Check for installed .NET versions that are no longer supported.
|
|
+ """
|
|
+
|
|
+ name = 'dotnet_unsupported_versions_check'
|
|
+ consumes = (InstalledRedHatSignedRPM,)
|
|
+ produces = (Report,)
|
|
+ tags = (ChecksPhaseTag, IPUWorkflowTag)
|
|
+
|
|
+ def process(self):
|
|
+ unsupported_versions_report_text = ''
|
|
+
|
|
+ for unsupported_version in UNSUPPORTED_VERSIONS:
|
|
+ runtime_package = f'dotnet-runtime-{unsupported_version}'
|
|
+ if has_package(InstalledRedHatSignedRPM, runtime_package):
|
|
+ unsupported_versions_report_text += '{0}{1}'.format('\n - ', unsupported_version)
|
|
+
|
|
+ if unsupported_versions_report_text:
|
|
+ reporting.create_report([
|
|
+ reporting.Title('Unsupported .NET versions installed on the system.'),
|
|
+ reporting.Summary(
|
|
+ (
|
|
+ 'The following versions of .NET are no longer supported :{0}\n'
|
|
+ 'Applications that use these runtimes will no longer work\n'
|
|
+ 'and must be updated to target a newer version of .NET.'
|
|
+ ).format(
|
|
+ unsupported_versions_report_text
|
|
+ )
|
|
+ ),
|
|
+ reporting.Severity(reporting.Severity.HIGH)])
|
|
diff --git a/repos/system_upgrade/el8toel9/actors/dotnet/tests/test_dotnet.py b/repos/system_upgrade/el8toel9/actors/dotnet/tests/test_dotnet.py
|
|
new file mode 100644
|
|
index 00000000..744a4e0b
|
|
--- /dev/null
|
|
+++ b/repos/system_upgrade/el8toel9/actors/dotnet/tests/test_dotnet.py
|
|
@@ -0,0 +1,43 @@
|
|
+import pytest
|
|
+
|
|
+from leapp.models import InstalledRedHatSignedRPM, Report, RPM
|
|
+
|
|
+
|
|
+def _generate_rpm_with_name(name):
|
|
+ return RPM(name=name,
|
|
+ version='0.1',
|
|
+ release='1.sm01',
|
|
+ epoch='1',
|
|
+ pgpsig='RSA/SHA256, Mon 01 Jan 1970 00:00:00 AM -03, Key ID 199e2f91fd431d51',
|
|
+ packager='Red Hat, Inc. <http://bugzilla.redhat.com/bugzilla>',
|
|
+ arch='noarch')
|
|
+
|
|
+
|
|
+@pytest.mark.parametrize('unsupported_versions', [
|
|
+ ([]), # No unsupported versions
|
|
+ ([2.1]), # Single unsupported version
|
|
+ ([3.0]), # Other unsupported version
|
|
+ ([2.1, 3.0]), # Multiple unsupported versions
|
|
+])
|
|
+def test_actor_execution(monkeypatch, current_actor_context, unsupported_versions):
|
|
+ """
|
|
+ Install one or more dotnet-runtime packages for unsupported versions
|
|
+ and verify a report is generated.
|
|
+ """
|
|
+
|
|
+ # Couple of random packages
|
|
+ rpms = [_generate_rpm_with_name('sed'),
|
|
+ _generate_rpm_with_name('htop')]
|
|
+
|
|
+ # dotnet-runtime-{version} packages
|
|
+ for version in unsupported_versions:
|
|
+ rpms += [_generate_rpm_with_name(f'dotnet-runtime-{version}')]
|
|
+
|
|
+ # Executed actor feeded with fake RPMs
|
|
+ current_actor_context.feed(InstalledRedHatSignedRPM(items=rpms))
|
|
+ current_actor_context.run()
|
|
+
|
|
+ if unsupported_versions:
|
|
+ assert current_actor_context.consume(Report)
|
|
+ else:
|
|
+ assert not current_actor_context.consume(Report)
|
|
--
|
|
2.35.3
|
|
|