Skip to content

Commit 4aa045f

Browse files
feat(rally): Adds custom rally plugin to wait for Nautobot tenant sync
1 parent 77c88a0 commit 4aa045f

File tree

3 files changed

+37
-1
lines changed

3 files changed

+37
-1
lines changed

containers/understack-tests/Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ COPY --from=ghcr.io/astral-sh/uv:latest /uv /bin/uv
88
COPY python/understack-tests/uv.lock python/understack-tests/pyproject.toml /code/
99
RUN --mount=type=cache,target=/root/.cache/uv uv sync --verbose --locked --no-dev
1010
COPY python/understack-tests /code
11-
11+
RUN mkdir -p /opt/rally/plugins
12+
COPY python/understack-tests/rally-plugins /opt/rally/plugins
1213

1314
FROM builder AS prod
1415
WORKDIR /code

python/understack-tests/build_a_single_gp2small_with_network.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ subtasks:
1212
config_drive: true
1313
force_delete: false
1414
contexts:
15+
users_custom:
16+
tenants: 1
17+
users_per_tenant: 1
1518
network:
1619
start_cidr: 192.168.91.0/24
1720
dns_nameservers: [8.8.8.8]
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import time
2+
3+
from rally.common import logging
4+
from rally.task import context
5+
from rally_openstack.task.contexts.keystone import users
6+
7+
LOG = logging.getLogger(__name__)
8+
9+
10+
@context.configure(name="users_custom", order=100)
11+
class UsersCustom(users.UserGenerator):
12+
"""Custom users context that sleeps 60s after creating projects."""
13+
14+
def setup(self):
15+
LOG.debug("UsersCustom: setup starting...")
16+
17+
# Call the original setup (creates projects and users normally)
18+
super().setup()
19+
20+
# Add the custom behavior to sleep allowing fofor Nautobot to sync
21+
self.context["users_override_note"] = "Sleep for Nautobot sync"
22+
23+
# After we create a project, sleep for 60 seconds, allowing some
24+
# time for it to sync to Nautobot
25+
LOG.debug("UsersCustom: sleeping for 60 seconds...")
26+
time.sleep(60)
27+
28+
LOG.debug("UsersCustom: completed")
29+
30+
def cleanup(self):
31+
# Run the default cleanup
32+
super().cleanup()

0 commit comments

Comments
 (0)