From e5227b4601a011874681b108d8943696394328dd Mon Sep 17 00:00:00 2001 From: Hao Liu <44379968+TheRealHaoLiu@users.noreply.github.com> Date: Wed, 14 Oct 2026 11:11:29 -0400 Subject: [PATCH] Warm the settings cache before measuring bulk host create queries (#16741) test_bulk_host_create_num_queries budgets 15 queries per request. The first request in a pytest process pays one extra query for each database-backed setting it reads (PROXY_IP_ALLOWED_LIST, REMOTE_HOST_HEADERS, BULK_HOST_MAX_CREATE) until the settings wrapper's in-memory cache is warm, so the budget only held when an earlier test in the same xdist worker had already warmed it. Make one untimed request first so the assertion measures steady state. --- awx/main/tests/functional/test_bulk.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/awx/main/tests/functional/test_bulk.py b/awx/main/tests/functional/test_bulk.py index a75a06a798..fcf03df180 100644 --- a/awx/main/tests/functional/test_bulk.py +++ b/awx/main/tests/functional/test_bulk.py @@ -35,6 +35,12 @@ def test_bulk_host_create_num_queries(organization, inventory, post, get, user, organization.inventory_admin_role.members.add(org_inv_admin) inventory.admin_role.members.add(inventory_admin) + # The first request in a process pays one query per database-backed + # setting it reads; later ones hit the settings wrapper's in-memory + # cache. Warm it so the budget below measures steady state regardless + # of which test ran first in this xdist worker. + post(reverse('api:bulk_host_create'), {'inventory': inventory.id, 'hosts': [{'name': uuid4()}]}, superuser, expect=201) + for u in [org_admin, inventory_admin, org_inv_admin, superuser]: hosts = [{'name': uuid4()} for i in range(num_hosts)] with django_assert_max_num_queries(num_queries):