features/monitor/scheduled-tasks.featureRunning behat features/monitor/scheduled-tasks.feature results in:
@rugged @workers @monitor-worker
Feature: Scheduled tasks work well together.
In order to allow unattended operation of a TUF server
As a TUF administrator
I need to ensure that scheduled tasks work reliably together.
Background:
Given I reset Rugged
And I run "sudo rm -rf /opt/post_to_tuf/*"
@scheduler @tuf-refreshing-dir
Scenario: Ensure that scheduled add-targets tasks wait until a `tuf_refreshing_expiry` directory (in `post-to-tuf`) is removed.
Given I run the Rugged command "mkdir -p /opt/post_to_tuf/tuf_refreshing_expiry/"
And I run the Rugged command "mkdir -p /opt/post_to_tuf/tuf_tmp_TIMESTAMP/"
And I run the Rugged command "fallocate -l 1K /opt/post_to_tuf/tuf_tmp_TIMESTAMP/foo.zip"
And I run the Rugged command "rugged logs --truncate"
And I wait "1" seconds
When I run the Rugged command "mv /opt/post_to_tuf/tuf_tmp_TIMESTAMP /opt/post_to_tuf/tuf_ready_TIMESTAMP"
And I wait "1" seconds
And I run the Rugged command "rugged logs --worker=monitor-worker --limit=0"
Then I should get:
"""
Received find-new-targets task.
New content found in post-to-tuf directory.
Count of post-to-tuf content: 2
Age of oldest post-to-tuf content:
List of post-to-tuf content:
tuf_ready_TIMESTAMP
tuf_refreshing_expiry
Found refresh-expiry flag at: /opt/post_to_tuf/tuf_refreshing_expiry
Detected currently processing scheduled 'refresh-expiry' task.
Monitor worker is refreshing expiry periods. Waiting for next scan to continue.
"""
'Received find-new-targets task.' was not found in command output:
------
=== Log for monitor-worker: /var/log/rugged/rugged.log ===
------
(Exception)
Then I should not get:
"""
Dispatching 'add-targets' task for:
"""
When I run the Rugged command "rugged logs --worker=targets-worker --limit=0"
Then I should not get:
"""
Received add-targets task.
"""
Given I run the Rugged command "rugged logs --worker=monitor-worker --truncate"
And I run "sudo sudo -u rugged rmdir /opt/post_to_tuf/tuf_refreshing_expiry/"
And I wait "1" seconds
When I run the Rugged command "rugged logs --worker=monitor-worker --limit=0"
Then I should not get:
"""
Detected currently processing scheduled 'refresh-expiry' task.
Waiting for current processing task to complete.
"""
Then I should get:
"""
Received find-new-targets task.
New content found in post-to-tuf directory.
Count of post-to-tuf content: 1
Age of oldest post-to-tuf content:
List of post-to-tuf content:
tuf_ready_TIMESTAMP
Dispatching 'add-targets' task for:
"""
When I run the Rugged command "rugged logs --worker=targets-worker --limit=0"
Then I should get:
"""
Received add-targets task.
"""
@refresh-expiry @tuf-processing-dir
Scenario: Ensure that scheduled refresh-expiry tasks wait until a `tuf_processing_` directory (in `post-to-tuf`) is removed.
Given I run the Rugged command "rugged pause-processing"
And I run the Rugged command "mkdir -p /opt/post_to_tuf/tuf_processing_TIMESTAMP/"
And I run the Rugged command "cp features/fixtures/config/expiry/short_snapshot_expiry.yaml /var/rugged/.config/rugged/config.yaml"
And I initialize a Rugged repo
And I record the expiry timestamp from "snapshot.json"
Given I run the Rugged command "rugged resume-processing"
And I wait "10" seconds
When I run the Rugged command "rugged logs --worker=monitor-worker --limit=0"
Then I should get:
"""
Received refresh-expiry task.
Creating 'refresh-expiry' task semaphore directory: /opt/post_to_tuf/tuf_refreshing_expiry
Detected processing directory at: /opt/post_to_tuf/tuf_processing_TIMESTAMP
Waiting for currently processing 'add-targets' task to complete.
"""
'Received refresh-expiry task.' was not found in command output:
------
=== Log for monitor-worker: /var/log/rugged/rugged.log ===
2026-06-08 18:41:29,381 INFO (monitor-worker.find_new_targets_task): New content found in post-to-tuf directory.
2026-06-08 18:41:29,382 INFO (monitor-worker.find_new_targets_task): Count of post-to-tuf content: 1
2026-06-08 18:41:29,382 INFO (monitor-worker.find_new_targets_task): Age of oldest post-to-tuf content: 3 seconds
2026-06-08 18:41:29,382 INFO (monitor-worker.find_new_targets_task): No new targets found.
2026-06-08 18:41:34,382 INFO (monitor-worker.find_new_targets_task): New content found in post-to-tuf directory.
2026-06-08 18:41:34,382 INFO (monitor-worker.find_new_targets_task): Count of post-to-tuf content: 1
2026-06-08 18:41:34,382 INFO (monitor-worker.find_new_targets_task): Age of oldest post-to-tuf content: 8 seconds
2026-06-08 18:41:34,382 INFO (monitor-worker.find_new_targets_task): No new targets found.
------
(Exception)
When I wait "6" seconds
And I run the Rugged command "rugged logs --worker=monitor-worker --limit=0"
Then I should get:
"""
Waited 5 seconds for currently processing 'add-targets' task to complete.
"""
And I should not get:
"""
Fetching expiring metadata from workers.
"""
And the expiry timestamp from "snapshot.json" has not changed
Given I run the Rugged command "rugged logs --worker=monitor-worker --truncate"
And I run the Rugged command "rmdir /opt/post_to_tuf/tuf_processing_TIMESTAMP/"
And I wait "5" seconds
When I run the Rugged command "rugged logs --worker=monitor-worker --limit=0"
Then I should not get:
"""
Detected currently processing scheduled 'add-targets' task.
Waiting for current processing task to complete.
"""
And I should get:
"""
Fetching expiring metadata from workers.
"""
And the expiry timestamp from "snapshot.json" has changed
--- Failed scenarios:
features/monitor/scheduled-tasks.feature:31
features/monitor/scheduled-tasks.feature:88
2 scenarios (2 failed)
45 steps (20 passed, 2 failed, 23 skipped)