mirror of
https://github.com/ansible/awx.git
synced 2026-08-03 19:40:00 -02:30
AAP-72269 Change fact processing loop to use file listing (#16403)
* Change fact processing loop to use file listing * Fix some test * Address coderabbit comments * Handle saving facts in batches to keep memory low * Improve log about mismatch in response to review comment
This commit is contained in:
@@ -112,7 +112,9 @@ def test_finish_job_fact_cache_clear(hosts, mocker, ref_time, tmpdir):
|
||||
os.remove(os.path.join(fact_cache_dir, hosts[1].name))
|
||||
|
||||
hosts_qs = mock.MagicMock()
|
||||
hosts_qs.filter.return_value.order_by.return_value.iterator.return_value = iter(hosts)
|
||||
# The new code calls host_qs.filter(name__in=...).select_related('inventory')
|
||||
# Only hosts[1] needs clearing (its file was removed), so return just that host
|
||||
hosts_qs.filter.return_value.select_related.return_value = [hosts[1]]
|
||||
|
||||
finish_fact_cache(hosts_qs, artifacts_dir=artifacts_dir, inventory_id=inventory_id)
|
||||
|
||||
@@ -145,10 +147,8 @@ def test_finish_job_fact_cache_with_bad_data(hosts, mocker, tmpdir):
|
||||
os.utime(filepath, (new_modification_time, new_modification_time))
|
||||
|
||||
hosts_qs = mock.MagicMock()
|
||||
hosts_qs.filter.return_value.order_by.return_value.iterator.return_value = iter(hosts)
|
||||
|
||||
finish_fact_cache(hosts_qs, artifacts_dir=artifacts_dir, inventory_id=inventory_id)
|
||||
|
||||
# Invalid JSON should be skipped — no hosts updated
|
||||
updated_hosts = bulk_update.call_args[0][1]
|
||||
assert updated_hosts == []
|
||||
# Invalid JSON should be skipped — no hosts updated, bulk_update never called
|
||||
bulk_update.assert_not_called()
|
||||
|
||||
Reference in New Issue
Block a user