features/monitor/monitor_worker.featureRunning behat features/monitor/monitor_worker.feature results in:
@rugged @workers @monitor-worker
Feature: A worker to dispatch `add-targets` tasks based on monitoring a directory for target files.
In order to allow a packaging pipeline not to hold credentials for the task queue,
As a TUF administrator
I need to ensure that a monitor worker can check a shared directory and dispatch `add-targets` tasks.
Background:
Given I reset Rugged
@scheduler
Scenario: Ensure that monitor worker is polling.
Given I wait "1" seconds
When I run the Rugged command "rugged logs --worker=monitor-worker --limit=0"
Then I should get:
"""
Received find-new-targets task.
"""
'Received find-new-targets task.' was not found in command output:
------
=== Log for monitor-worker: /var/log/rugged/rugged.log ===
------
(Exception)
Given I run the Rugged command "rugged logs --truncate --worker=monitor-worker"
And I wait "1" seconds
When I run the Rugged command "rugged logs --worker=monitor-worker --limit=0"
Then I should get:
"""
Received find-new-targets task.
"""
@scheduler
Scenario: Notice when post-to-tuf directory has new files or directories.
Given I run the Rugged command "rugged logs --worker=monitor-worker --truncate"
And I wait "1" seconds
When I run the Rugged command "rugged logs --worker=monitor-worker --limit=0"
Then I should get:
"""
Received find-new-targets task.
No new content found.
"""
'Received find-new-targets task.' was not found in command output:
------
=== Log for monitor-worker: /var/log/rugged/rugged.log ===
------
(Exception)
And I should not get:
"""
New content found in post-to-tuf directory.
Count of post-to-tuf content:
Age of oldest post-to-tuf content:
"""
Given I run the Rugged command "rugged logs --worker=monitor-worker --truncate"
And I run "sudo sudo -u rugged mkdir -p /opt/post_to_tuf/tuf_tmp_TIMESTAMP/"
And I run "sudo fallocate -l 1K /opt/post_to_tuf/tuf_tmp_TIMESTAMP/foo.zip"
And I wait "1" seconds
When 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: 1
Age of oldest post-to-tuf content:
List of post-to-tuf content:
tuf_tmp_TIMESTAMP
No new targets found.
"""
@scheduler @tuf-ready-dir
Scenario: Notice when a new set of targets is ready to add.
Given I run "sudo sudo -u rugged mkdir -p /opt/post_to_tuf/tuf_tmp_TIMESTAMP/"
And I run "sudo fallocate -l 1K /opt/post_to_tuf/tuf_tmp_TIMESTAMP/foo.zip"
And I run the Rugged command "rugged logs --worker=monitor-worker --truncate"
When I run "sudo mv /opt/post_to_tuf/tuf_tmp_TIMESTAMP /opt/post_to_tuf/tuf_ready_TIMESTAMP"
And I wait "2" seconds
And I run the Rugged command "rugged logs --worker=monitor-worker --limit=0"
Then I should get:
"""
Received find-new-targets task.
New targets found in post-to-tuf directory:
tuf_ready_TIMESTAMP
"""
'Received find-new-targets task.' was not found in command output:
------
=== Log for monitor-worker: /var/log/rugged/rugged.log ===
2026-06-08 18:43:44,382 INFO (monitor-worker.find_new_targets_task): New content found in post-to-tuf directory.
2026-06-08 18:43:44,383 INFO (monitor-worker.find_new_targets_task): Count of post-to-tuf content: 1
2026-06-08 18:43:44,383 INFO (monitor-worker.find_new_targets_task): Age of oldest post-to-tuf content: 1 seconds
2026-06-08 18:43:44,383 INFO (monitor-worker.find_new_targets_task): New targets found in post-to-tuf directory:
2026-06-08 18:43:44,383 INFO (monitor-worker.find_new_targets_task): tuf_ready_TIMESTAMP
2026-06-08 18:43:44,383 INFO (monitor-worker.find_new_targets_task): Processing: tuf_ready_TIMESTAMP
2026-06-08 18:43:44,385 INFO (monitor-worker.find_new_targets_task): Dispatching 'add-targets' task for: tuf_processing_TIMESTAMP
------
(Exception)
@scheduler @tuf-ready-dir
Scenario: Ensure that multiple `tuf_ready_` directories (in `post-to-tuf`) do not stop further targets being processed.
Given I run "sudo sudo -u rugged mkdir -p /opt/post_to_tuf/tuf_tmp_TIMESTAMP/"
And I run "sudo fallocate -l 1K /opt/post_to_tuf/tuf_tmp_TIMESTAMP/foo.zip"
And I run "sudo sudo -u rugged mkdir -p /opt/post_to_tuf/tuf_tmp_TIMESTAMP2/"
And I run "sudo fallocate -l 1K /opt/post_to_tuf/tuf_tmp_TIMESTAMP2/foo2.zip"
And I run the Rugged command "rugged logs --worker=monitor-worker --truncate"
And I wait "1" seconds
When I run "sudo mv /opt/post_to_tuf/tuf_tmp_TIMESTAMP /opt/post_to_tuf/tuf_ready_TIMESTAMP"
And I run "sudo mv /opt/post_to_tuf/tuf_tmp_TIMESTAMP2 /opt/post_to_tuf/tuf_ready_TIMESTAMP2"
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 targets found in post-to-tuf directory:
tuf_ready_TIMESTAMP
tuf_ready_TIMESTAMP2
"""
'Received find-new-targets task.' was not found in command output:
------
=== Log for monitor-worker: /var/log/rugged/rugged.log ===
2026-06-08 18:43:49,383 INFO (monitor-worker.find_new_targets_task): New content found in post-to-tuf directory.
2026-06-08 18:43:49,383 INFO (monitor-worker.find_new_targets_task): Count of post-to-tuf content: 2
2026-06-08 18:43:49,383 INFO (monitor-worker.find_new_targets_task): Age of oldest post-to-tuf content: 1 seconds
2026-06-08 18:43:49,383 INFO (monitor-worker.find_new_targets_task): No new targets found.
------
(Exception)
@scheduler @tuf-tmp-dir
Scenario: Ensure that `tuf_tmp_` directory (in `post-to-tuf`) does not stop further targets being processed.
Given I run "sudo sudo -u rugged mkdir -p /opt/post_to_tuf/tuf_tmp_TIMESTAMP/"
And I run "sudo fallocate -l 1K /opt/post_to_tuf/tuf_tmp_TIMESTAMP/foo.zip"
And I run "sudo sudo -u rugged mkdir -p /opt/post_to_tuf/tuf_tmp_TIMESTAMP2/"
And I run "sudo fallocate -l 1K /opt/post_to_tuf/tuf_tmp_TIMESTAMP2/foo2.zip"
And I run the Rugged command "rugged logs --worker=monitor-worker --truncate"
And I wait "1" seconds
When I run "sudo mv /opt/post_to_tuf/tuf_tmp_TIMESTAMP2 /opt/post_to_tuf/tuf_ready_TIMESTAMP2"
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.
List of post-to-tuf content:
tuf_tmp_TIMESTAMP
New targets found in post-to-tuf directory:
tuf_ready_TIMESTAMP
"""
'Received find-new-targets task.' was not found in command output:
------
=== Log for monitor-worker: /var/log/rugged/rugged.log ===
------
(Exception)
@scheduler @tuf-processing-dir
Scenario: Ensure that `tuf_processing_` directory (in `post-to-tuf`) stops further targets being processed.
Given I run "sudo sudo -u rugged mkdir -p /opt/post_to_tuf/tuf_processing_TIMESTAMP/"
And I run "sudo sudo -u rugged mkdir -p /opt/post_to_tuf/tuf_tmp_TIMESTAMP2/"
And I run "sudo fallocate -l 1K /opt/post_to_tuf/tuf_tmp_TIMESTAMP2/foo2.zip"
And I run the Rugged command "rugged logs --truncate"
And I wait "1" seconds
When I run "sudo mv /opt/post_to_tuf/tuf_tmp_TIMESTAMP2 /opt/post_to_tuf/tuf_ready_TIMESTAMP2"
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_processing_TIMESTAMP
tuf_ready_TIMESTAMP2
Monitor worker is already processing targets. 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.
"""
--- Failed scenarios:
features/monitor/monitor_worker.feature:30
features/monitor/monitor_worker.feature:49
features/monitor/monitor_worker.feature:82
features/monitor/monitor_worker.feature:97
features/monitor/monitor_worker.feature:117
features/monitor/monitor_worker.feature:138
6 scenarios (6 failed)
64 steps (44 passed, 6 failed, 14 skipped)