From e45712bec63c554ed2ff6b28ac0e1f87cb4e6bda Mon Sep 17 00:00:00 2001 From: Nicholas Kuechler Date: Wed, 27 Aug 2025 13:52:00 -0500 Subject: [PATCH] feat(rally): Adds custom rally plugin to wait for Nautobot tenant sync --- containers/understack-tests/Dockerfile | 3 +- .../build_a_single_gp2small_with_network.yaml | 3 ++ .../rally-plugins/users_custom.py | 32 +++++++++++++++++++ 3 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 python/understack-tests/rally-plugins/users_custom.py diff --git a/containers/understack-tests/Dockerfile b/containers/understack-tests/Dockerfile index a2b334faf..5b3f321e7 100644 --- a/containers/understack-tests/Dockerfile +++ b/containers/understack-tests/Dockerfile @@ -8,7 +8,8 @@ COPY --from=ghcr.io/astral-sh/uv:latest /uv /bin/uv COPY python/understack-tests/uv.lock python/understack-tests/pyproject.toml /code/ RUN --mount=type=cache,target=/root/.cache/uv uv sync --verbose --locked --no-dev COPY python/understack-tests /code - +RUN mkdir -p /opt/rally/plugins +COPY python/understack-tests/rally-plugins /opt/rally/plugins FROM builder AS prod WORKDIR /code diff --git a/python/understack-tests/build_a_single_gp2small_with_network.yaml b/python/understack-tests/build_a_single_gp2small_with_network.yaml index 86faf07e9..3518abac1 100644 --- a/python/understack-tests/build_a_single_gp2small_with_network.yaml +++ b/python/understack-tests/build_a_single_gp2small_with_network.yaml @@ -12,6 +12,9 @@ subtasks: config_drive: true force_delete: false contexts: + users_custom: + tenants: 1 + users_per_tenant: 1 network: start_cidr: 192.168.91.0/24 dns_nameservers: [8.8.8.8] diff --git a/python/understack-tests/rally-plugins/users_custom.py b/python/understack-tests/rally-plugins/users_custom.py new file mode 100644 index 000000000..7acecc43d --- /dev/null +++ b/python/understack-tests/rally-plugins/users_custom.py @@ -0,0 +1,32 @@ +import time + +from rally.common import logging +from rally.task import context +from rally_openstack.task.contexts.keystone import users + +LOG = logging.getLogger(__name__) + + +@context.configure(name="users_custom", order=100) +class UsersCustom(users.UserGenerator): + """Custom users context that sleeps 60s after creating projects.""" + + def setup(self): + LOG.debug("UsersCustom: setup starting...") + + # Call the original setup (creates projects and users normally) + super().setup() + + # Add the custom behavior to sleep allowing fofor Nautobot to sync + self.context["users_override_note"] = "Sleep for Nautobot sync" + + # After we create a project, sleep for 60 seconds, allowing some + # time for it to sync to Nautobot + LOG.debug("UsersCustom: sleeping for 60 seconds...") + time.sleep(60) + + LOG.debug("UsersCustom: completed") + + def cleanup(self): + # Run the default cleanup + super().cleanup()