Skip to content

Commit

Permalink
automatic: Test errors reporting and emitting
Browse files Browse the repository at this point in the history
This is a follow-up to commit 12eba2f and
6965c62 adjusted for the dnf5 behavior.
  • Loading branch information
jan-kolarik authored and kontura committed Dec 19, 2024
1 parent 85ff62c commit 67655a9
Show file tree
Hide file tree
Showing 3 changed files with 80 additions and 0 deletions.
45 changes: 45 additions & 0 deletions dnf-behave-tests/dnf/dnf-automatic/error-report.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
@dnf5
Feature: dnf-automatic reports an error when transaction failed


Background:
Given I use repository "dnf-ci-automatic-update"


# First, install the "test-1.0" package, which should proceed successfully.
# Then, attempt to update to "test-1.1", which contains a broken scriptlet.
# An error should be reported during the installation of the update.
@bz2170093
Scenario: dnf-automatic reports an error when package installation failed
Given I successfully execute dnf with args "install test-1.0"
When I execute dnf with args "automatic --installupdates"
Then the exit code is 1
And RPMDB Transaction is empty
And stdout contains "Failed to install upgrades."
And stdout contains "Error in pre-install scriptlet"
And stdout contains "Transaction failed: Rpm transaction failed."

# https://github.com/rpm-software-management/dnf/issues/1918
# https://issues.redhat.com/browse/RHEL-61882
Scenario: emitters report errors by default
Given I create and substitute file "/etc/dnf/automatic.conf" with
"""
[commands]
download_updates = yes
apply_updates = yes
[emitters]
emit_via = command_email
[command_email]
command_format = "echo {{body}} > {context.dnf.tempdir}/dnf_error"
"""
And I successfully execute dnf with args "install test-1.0"
And file "/{context.dnf.tempdir}/dnf_error" does not exist
When I execute dnf with args "automatic --installupdates"
Then the exit code is 1
And RPMDB Transaction is empty
And file "/{context.dnf.tempdir}/dnf_error" contains lines
"""
Transaction failed: Rpm transaction failed.
"""
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
Name: test
Epoch: 0
Version: 1.0
Release: 1

License: Public Domain
URL: None

Summary: The made up package for dnf-automatic updates testing.

%description
Installs correctly.

%files

%changelog
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
Name: test
Epoch: 0
Version: 1.1
Release: 1

License: Public Domain
URL: None

Summary: The made up package for dnf-automatic updates testing.

%description
Fails on pre scriptlet.

%pre -p <lua>
error("failing on pre scriptlet", 1)

%files

%changelog

0 comments on commit 67655a9

Please sign in to comment.