MCPcopy Create free account
hub / github.com/FastLED/FastLED / test_orphan_detection

Function test_orphan_detection

ci/docker_utils/test_container_db.py:87–114  ·  view source on GitHub ↗

Test orphan detection with dead PIDs.

()

Source from the content-addressed store, hash-verified

85
86
87def test_orphan_detection():
88 """Test orphan detection with dead PIDs."""
89 print("Testing orphan detection...")
90
91 with tempfile.TemporaryDirectory() as tmpdir:
92 db_path = Path(tmpdir) / "test.db"
93 db = ContainerDatabase(db_path)
94
95 # Insert a record with a dead PID (99999 is unlikely to exist)
96 dead_pid = 99999
97 container_id = "orphan_container_456"
98 container_name = "orphan-container"
99 image_name = "test-image:latest"
100
101 db.insert(container_id, container_name, image_name, dead_pid)
102
103 # Verify process_exists returns False for dead PID
104 assert not process_exists(dead_pid), "Dead PID incorrectly detected as alive"
105
106 # Get all records - should include our orphan
107 all_records = db.get_all()
108 assert len(all_records) == 1, "Expected 1 record"
109 assert all_records[0].owner_pid == dead_pid
110
111 # Note: We can't test actual cleanup_orphaned_containers here because
112 # it tries to interact with Docker. Just verify the logic detects orphans.
113
114 print("✓ Orphan detection test passed")
115
116
117def test_process_exists():

Callers 1

mainFunction · 0.85

Calls 5

insertMethod · 0.95
get_allMethod · 0.95
ContainerDatabaseClass · 0.90
process_existsFunction · 0.90
printFunction · 0.50

Tested by

no test coverage detected