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

Backport dnf-automatic reboot tests from rhel-9.6 branch #1610

Merged
merged 1 commit into from
Dec 12, 2024
Merged
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
114 changes: 114 additions & 0 deletions dnf-behave-tests/dnf/dnf-automatic/reboot.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
@no_installroot
Feature: dnf-automatic reboots


Background:
Given I delete file "/etc/yum.repos.d/*.repo" with globs
And I create file "/etc/dnf/dnf.conf" with
"""
[main]
plugins=0
"""
And I use repository "simple-base"
And I successfully execute dnf with args "install labirinto"
And I use repository "simple-updates"

Scenario: dnf-automatic does not reboot when reboot = never
Given I create file "/etc/dnf/automatic.conf" with
"""
[commands]
reboot = never
reboot_command = "echo 'I LOVE REBOOTING'"

[emitters]
emit_via = stdio
"""
When I execute dnf-automatic with args "--installupdates"
Then the exit code is 0
And Transaction is following
| Action | Package |
| upgrade | labirinto-0:2.0-1.fc29.x86_64 |
And stdout does not contain lines:
"""
I LOVE REBOOTING
"""

Scenario: dnf-automatic reboots when packages changed and reboot = when-changed
Given I create file "/etc/dnf/automatic.conf" with
"""
[commands]
reboot = when-changed
reboot_command = "echo 'I LOVE REBOOTING'"

[emitters]
emit_via = stdio
"""
When I execute dnf-automatic with args "--installupdates"
Then the exit code is 0
And Transaction is following
| Action | Package |
| upgrade | labirinto-0:2.0-1.fc29.x86_64 |
And stdout contains lines:
"""
I LOVE REBOOTING
"""

Scenario: dnf-automatic reboots when reboot = when-needed and important package changed
Given I create file "/etc/dnf/automatic.conf" with
"""
[commands]
reboot = when-needed
reboot_command = "echo 'I LOVE REBOOTING'"

[emitters]
emit_via = stdio
"""
And I use repository "dnf-ci-fedora"
And I successfully execute dnf with args "install kernel"
And I use repository "dnf-ci-fedora-updates"
When I execute dnf-automatic with args "--installupdates"
Then the exit code is 0
And stdout contains lines:
"""
I LOVE REBOOTING
"""

Scenario: dnf-automatic does not reboot when reboot = when-needed and nothing important changed
Given I create file "/etc/dnf/automatic.conf" with
"""
[commands]
reboot = when-needed
reboot_command = "echo 'I LOVE REBOOTING'"

[emitters]
emit_via = stdio
"""
When I execute dnf-automatic with args "--installupdates"
Then the exit code is 0
And Transaction is following
| Action | Package |
| upgrade | labirinto-0:2.0-1.fc29.x86_64 |
And stdout does not contain lines:
"""
I LOVE REBOOTING
"""

Scenario: dnf-automatic shows error message when reboot command failed
Given I create file "/etc/dnf/automatic.conf" with
"""
[commands]
reboot = when-changed
reboot_command = "false"

[emitters]
emit_via = stdio
"""
When I execute dnf-automatic with args "--installupdates"
Then the exit code is 1
And Transaction is following
| Action | Package |
| upgrade | labirinto-0:2.0-1.fc29.x86_64 |
And stderr contains lines:
"""
Error: reboot command returned nonzero exit code: 1
"""
Loading