Skip to content

Test foreman.target stops and starts IOP services - #701

Open
vsedmik wants to merge 2 commits into
theforeman:masterfrom
vsedmik:iop-target-lifecycle-test
Open

Test foreman.target stops and starts IOP services#701
vsedmik wants to merge 2 commits into
theforeman:masterfrom
vsedmik:iop-target-lifecycle-test

Conversation

@vsedmik

@vsedmik vsedmik commented Jul 23, 2026

Copy link
Copy Markdown

Summary

  • Adds a test under tests/feature/iop/ verifying that systemctl stop foreman.target brings down all IOP containers and systemctl start foreman.target brings them back.
  • Auto-skipped when IOP is not enabled (feature guarding via conftest).
  • Marked as slow since it involves a full stop/start cycle (~2 min).

Context

Companion test for #592 which adds PartOf=foreman.target and WantedBy=foreman.target to all IOP quadlet units.

🤖 Generated with Claude Code

Verify that systemctl stop foreman.target brings down all IOP
containers and that starting it brings them back.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@sjha4

sjha4 commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Looks good to me..Covers start and stop :)

@ehelms

ehelms commented Jul 24, 2026

Copy link
Copy Markdown
Member

Is there a cheaper way to test this? Can we verify that the iop services are correctly part of the foreman.target and then trust that systemd is going to do the right thing?

@vsedmik

vsedmik commented Jul 24, 2026

Copy link
Copy Markdown
Author

Is there a cheaper way to test this? Can we verify that the iop services are correctly part of the foreman.target and then trust that systemd is going to do the right thing?

Probably we could dynamically discover all iop-core-* and iop-service-* services via systemctl list-units, skip timer-triggered ones (cleanup, vmaas-sync), and assert that each remaining service has PartOf=foreman.target. This verifies the unit file wiring without touching any running services and takes ~21 seconds (instead of ~2 minutes).

Comment on lines +11 to +18
for service in services:
# Skip timer-triggered services (cleanup, vmaas-sync)
triggered_by = server.run(f"systemctl show {service} -p TriggeredBy --value")
if triggered_by.stdout.strip():
continue
result = server.run(f"systemctl show {service} -p PartOf --value")
if "foreman.target" not in result.stdout:
missing.append(service)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

testinfra has service.systemd_properties, so I assume (untested) the following should work:

for service_name in services:
    service = server.service(service_name)
    if service.systemd_properties.get("TriggeredBy"):
        continue
    assert "foreman.target" in service.systemd_properties.get("PartOf")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants