nemo_gym.server_runtime.testing.session_conformance
nemo_gym.server_runtime.testing.session_conformance
Integration test for a resources server’s episode session lifecycle.
check_resources_session_contract drives the app a server builds through its real HTTP routes and middleware,
in process, the way an environment server calls a deployed server: episode seed, repeated seed, a conflicting seed,
close, repeated close, a close that names another episode, close of a never-seeded session, a seed after close, a
close without the session cookie after a seed whose reply was lost, and optionally a verify after close. Call it from
the server’s own tests. Because it goes through the routes, it also catches a route that another registration
shadows.
Module Contents
Functions
API
Seed, re-seed, and close a session through app, and raise AssertionError on a contract violation.
seed must use a resources_session_id the app has not seen. With keeps_state:
- a seed that names the open session’s ID with another episode is refused with 409;
- a close of the closed session that names another episode is refused with 409;
- a seed that arrives after its session closed, or after a close for an ID that was never seeded, is refused
with 409 while the session is fenced (
session_close_retry_window_seconds). A server that keeps no state has nothing such a seed could recreate.
The check also seeds a second session and drops its cookie, as when the seed’s reply is lost, then closes it
without a cookie, as the Environment Server does. That close must succeed. With holds_state, a callable that
reports whether the server holds state for a resources_session_id, both closes must release that state.
With verify_body (requires keeps_state), a /verify sent with the closed session’s cookie must
return a masked sample whose failure_kind is session_lost or session_expired, not a reward of 0.
Pass it for a server whose score depends on per-rollout state.