Skip to content

Commit 4627bd2

Browse files
committed
docs: reflect splent_framework 1.7.1
The framework now drives the Selenium Grid itself and discovers every feature's locustfile, so the pages describing it as incapable of either, and tests/selenium_support.py as a temporary replacement, were out of date the moment 1.7.1 shipped. The selenium sections now document SELENIUM_GRID_URL, SELENIUM_TARGET_URL and SELENIUM_BROWSER, and describe the local module as what it became: a thin wrapper that defaults those variables to this stack's container names and pins the viewport. The load-testing page drops the note explaining why Rosemary had to resolve locustfiles itself, because it no longer does: the whole-project run defers to the framework bootstrap, and SPLENT_LOCUSTFILES is documented for products that keep load tests elsewhere. Version pins move to 1.7.1.
1 parent 76d85a2 commit 4627bd2

4 files changed

Lines changed: 38 additions & 50 deletions

File tree

architecture/project_structure.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,11 +101,11 @@ Fixtures that only concern one feature belong in `app/features/<feature>/tests/c
101101

102102
## tests
103103

104-
Cross-feature test support that does not belong to any single feature. It currently holds `selenium_support.py`, the helper that resolves the WebDriver and the target host for the end-to-end layer.
104+
Cross-feature test support that does not belong to any single feature. It currently holds `selenium_support.py`, the e2e layer's single import point for the WebDriver and the target host.
105105

106-
Both helpers branch on `WORKING_DIR`. Inside Docker (`WORKING_DIR=/workspace/`), `selenium_support.initialize_driver()` returns a `webdriver.Remote` attached to the Selenium Grid started by `docker/docker-compose.dev.yml`, and `get_host_for_selenium_testing()` returns the URL of the app *as the browser sees it* — the nginx container, not `localhost`, because `localhost` inside the browser container resolves to the browser itself. Run outside Docker, `initialize_driver()` falls back to a local `webdriver.Chrome()` or `webdriver.Firefox()` and the host becomes `http://localhost:5000`.
106+
Since `splent_framework` 1.7.1 the driver itself comes from the framework, which attaches to the Selenium Grid named by `SELENIUM_GRID_URL` and honours `SELENIUM_TARGET_URL` for the URL the browser opens — the nginx container, not `localhost`, because `localhost` inside the browser container resolves to the browser itself. The wrapper defaults both variables to this stack's container names when running under Docker, and pins a 1920x1080 window so both grid browsers see the same responsive layout. Run outside Docker, neither variable is defaulted and the framework launches a local browser against `http://localhost:5000`.
107107

108-
This module exists because the framework's own Selenium helper builds a local Chrome through `webdriver_manager`, and no browser is installed inside `web_app_container`. Every `test_selenium.py` in the project imports from here:
108+
Every `test_selenium.py` in the project imports from here:
109109

110110
```python
111111
from tests.selenium_support import close_driver, get_host_for_selenium_testing, initialize_driver
@@ -217,7 +217,7 @@ A list of files and directories that Git should ignore. This prevents certain fi
217217
The pinned list of Python dependencies, installed with `pip`. Every version is pinned exactly. The entry that matters most to the architecture is the framework the product is built on:
218218

219219
```
220-
splent_framework==1.7.0
220+
splent_framework==1.7.1
221221
```
222222

223223
See [splent_framework]({{site.baseurl}}/architecture/splent_framework) for what that package provides.

architecture/splent_framework.md

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ nav_order: 4
2323
The framework is a normal pinned dependency in `requirements.txt`:
2424

2525
```
26-
splent_framework==1.7.0
26+
splent_framework==1.7.1
2727
```
2828

2929
Installing the project's dependencies installs it:
@@ -205,23 +205,21 @@ The four fixtures differ in how aggressively they reset the database. `test_clie
205205

206206
## Things to know
207207

208-
Two parts of the framework do not cover what {% include uvlhub.html %} needs, and the repository works around both. Reaching for the framework helper in these places will not work, so it is worth knowing where the seams are.
208+
A few framework behaviours are worth knowing before you reach for them, because they shape how this repository is wired.
209209

210210
### Selenium
211211

212-
The end-to-end layer is driven by the repository-local helper `tests/selenium_support.py`, not by `splent_framework.selenium.common`:
212+
Since 1.7.1 the framework itself can drive a Selenium Grid. `initialize_driver` attaches to the hub named by `SELENIUM_GRID_URL` through `webdriver.Remote`, so the browser runs in a grid node container; without that variable it launches a local browser through `webdriver_manager`, as before. It accepts chrome (the default) and firefox, chosen per call or through `SELENIUM_BROWSER`, and `get_host_for_selenium_testing` honours `SELENIUM_TARGET_URL` — needed because the URL a test opens is resolved *by the browser*, and inside a grid node `localhost` is the node itself.
213+
214+
The e2e layer still imports from the repository-local `tests/selenium_support.py`:
213215

214216
```python
215217
from tests.selenium_support import close_driver, get_host_for_selenium_testing, initialize_driver
216218
```
217219

218-
The framework's `initialize_driver` builds a *local* Chrome through `webdriver_manager`, and no browser is installed inside `web_app_container`, so every e2e test would fail before reaching the app. It also takes no arguments, so there is no way to ask it for Firefox. When `WORKING_DIR` is `/workspace/`, the local helper instead returns a `webdriver.Remote` attached to the Selenium Grid that `docker/docker-compose.dev.yml` starts, so the browser runs in the `selenium_chrome_container` or `selenium_firefox_container`. Outside Docker it builds a local browser, as the framework does.
219-
220-
The browser choice travels by environment variable. `rosemary selenium --driver firefox` sets `SELENIUM_BROWSER`, which `initialize_driver` reads. Earlier versions of that command tried to call a `set_service_driver` helper on `splent_framework.selenium.common`; no such function exists, so do not reintroduce that call.
221-
222-
The host differs too. The framework's `get_host_for_selenium_testing` returns `http://localhost` under `/workspace/`, but the host name is resolved *by the browser*, and inside the browser container `localhost` is the browser itself. The local helper returns the nginx container URL instead. `get_host_for_locust_testing` already gets this right, which is why the load tests do import it from the framework.
220+
but that module is now a thin wrapper over the framework helpers. It defaults `SELENIUM_GRID_URL` and `SELENIUM_TARGET_URL` to this stack's container names when running under Docker, and pins a 1920x1080 window so the responsive layout is identical whichever browser the grid hands out. The driver itself comes from the framework.
223221

224-
Both differences are recorded in the docstring of `tests/selenium_support.py`. If the framework grows grid support, the local helper can be dropped.
222+
The browser choice travels by environment variable: `rosemary selenium --driver firefox` sets `SELENIUM_BROWSER`, which the framework reads.
225223

226224
### Feature assets
227225

rosemary_cli/testing/gui_tests.md

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -62,30 +62,29 @@ run and what makes `--e2e` able to select them.
6262

6363
## The driver helpers
6464

65-
The imports come from `tests/selenium_support.py`, a repo-local module, not from
66-
`splent_framework`. Read that file's docstring for the full reasoning; the short version is that
67-
the framework's `selenium.common` cannot drive the grid:
65+
The imports come from `tests/selenium_support.py`, which since `splent_framework` 1.7.1 is a thin
66+
wrapper over the framework's own helpers. The framework drives the grid natively: when
67+
`SELENIUM_GRID_URL` is set, `initialize_driver` attaches to that hub through `webdriver.Remote`, so
68+
the browser runs in the `selenium-chrome` or `selenium-firefox` container; without it, a local
69+
browser is launched through `webdriver_manager`. `get_host_for_selenium_testing` honours
70+
`SELENIUM_TARGET_URL`, which matters because the URL is resolved **by the browser**, and inside a
71+
grid node `localhost` is the node itself.
6872

69-
- its `initialize_driver` builds a **local** Chrome through `webdriver_manager`, and there is no
70-
browser installed inside `web_app_container`, so every test raises before it reaches the app;
71-
- its `get_host_for_selenium_testing` returns `localhost`, but the host is resolved **by the
72-
browser**, and inside the browser container `localhost` is the browser itself.
73-
74-
`tests/selenium_support.py` fixes both. It builds a `webdriver.Remote` pointed at the grid so the
75-
browser runs in the `selenium-chrome` or `selenium-firefox` container, and it targets the nginx
76-
container rather than `localhost`:
73+
What the wrapper adds on top:
7774

7875
```python
79-
GRID_URL = os.getenv("SELENIUM_GRID_URL", "http://selenium_hub_container:4444")
80-
DOCKER_HOST_URL = os.getenv("SELENIUM_TARGET_URL", "http://nginx_web_server_container")
81-
LOCAL_HOST_URL = "http://localhost:5000"
76+
if os.getenv("WORKING_DIR", "") == "/workspace/":
77+
os.environ.setdefault("SELENIUM_GRID_URL", "http://selenium_hub_container:4444")
78+
os.environ.setdefault("SELENIUM_TARGET_URL", "http://nginx_web_server_container")
8279
```
8380

84-
Outside Docker the same helper falls back to a local `webdriver.Firefox()` or `webdriver.Chrome()`
85-
and to `http://localhost:5000`, so the identical test file works in both environments.
81+
so the grid and the target default to this stack's container names under Docker, plus a pinned
82+
1920x1080 window. Browser defaults differ (chrome nodes open at about 945px, firefox at about
83+
1280px), and below the responsive breakpoint the sidebar collapses off-canvas, so an unpinned
84+
viewport makes the same test pass on one browser and fail on the other.
8685

87-
This module is meant to be temporary. Drop it and go back to the framework helpers once
88-
`splent_framework` grows grid support.
86+
Outside Docker neither variable is defaulted, so the framework launches a local browser against
87+
`http://localhost:5000` and the identical test file works in both environments.
8988

9089
---
9190

rosemary_cli/testing/load_tests.md

Lines changed: 10 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -151,25 +151,16 @@ and picks up `WORKING_DIR` from the environment already there.
151151
rosemary locust
152152
```
153153

154-
With no argument, every feature that has a `locustfile.py` is loaded at once. Locust accepts a
155-
comma-separated list, so Rosemary collects the files under `app/features/*/tests/locustfile.py` and
156-
passes them together. The web interface then lets you pick which user classes to run, or swarm all of
157-
them.
158-
159-
{: .note-title }
160-
> Why Rosemary resolves the list itself
161-
>
162-
> It would be natural to defer to the default bootstrap that ships with `splent_framework`, and
163-
> Rosemary used to. That bootstrap has not followed the `app/features/` rename: version 1.7.0 still globs
164-
> `app/modules/*/tests/locustfile.py`, a directory this repository no longer has, so it collected zero
165-
> `HttpUser` classes and raised `ValueError: No User class found!` at import time, before Locust
166-
> started. You can still see it fail on its own:
167-
>
168-
> ```bash
169-
> docker exec web_app_container python -c "from splent_framework.bootstraps import locustfile_bootstrap"
170-
> ```
171-
>
172-
> Resolving the paths in Rosemary sidesteps it until the framework catches up.
154+
With no argument, every feature that has a `locustfile.py` is loaded at once. Discovery is done by
155+
`splent_framework`'s locustfile bootstrap, which since 1.7.1 finds
156+
`app/features/*/tests/locustfile.py` on its own: in Docker, Rosemary simply omits `-f` and the
157+
locust entrypoint resolves the bootstrap from site-packages; outside Docker, Rosemary points locust
158+
at the bootstrap module directly. The web interface then lets you pick which user classes to run, or
159+
swarm all of them. Loaded class names carry a per-feature suffix, `AuthUser_splent_locustfile_auth`
160+
for example, so two features' classes can never shadow each other.
161+
162+
To load from somewhere else entirely, set `SPLENT_LOCUSTFILES` to a comma-separated list of glob
163+
patterns, relative to `WORKING_DIR` unless absolute.
173164

174165
## How it runs per environment
175166

0 commit comments

Comments
 (0)