Skip to content

Let tests take their DDS domain from RUSTDDS_TEST_DOMAIN_ID - #448

Merged
jhelovuo merged 1 commit into
Atostek:masterfrom
johannesschrimpf:test/domain-id-from-env
Oct 16, 2026
Merged

jhelovuo merged 1 commit into
Atostek:masterfrom
johannesschrimpf:test/domain-id-from-env

Conversation

@johannesschrimpf

@johannesschrimpf johannesschrimpf commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

The tests create their DomainParticipants on fixed domain ids, most on
domain 0. On a machine that shares a network with other DDS systems,
cargo test joins their domain 0; a robot on my network discovered the
test participants, could not reach the addresses they advertised, and
logged a failed send per sample.

RUSTDDS_TEST_DOMAIN_ID now sets a base added to the domain id of each
test participant. Unset or empty means 0, so CI is unchanged. Tests keep
their current id as an offset (0, or 11, 51, 52 for the ones that stay
apart), so they remain on separate domains after the shift. A value that
is not a u16, or above 147, fails the test with a message naming the
variable; 147 keeps the highest test domain (147 + 52) below the
lock-order test's scratch domains 200-229.

  • src/test/test_domain.rs: the helper and parser, included by the
    integration tests through tests/common/mod.rs.
  • 23 participant constructions in unit and integration tests use it.
  • The raw-socket unit tests (four of which also create a participant)
    derive their fixed ports from the test domain too: the ports of domains
    5, 12, 14, 15 and 16 shift with the participants and stay off their
    ports, and 7412 (participant 1's discovery port) moves to the shifted
    domain.
  • Doc tests are not moved: 57 of the 58 doc tests create a participant on
    domain 0, so plain cargo test still joins domain 0; cargo test --tests leaves them out. Letting the doc examples read the variable
    too would change the rendered examples, so that is left as a possible
    follow-up.
  • Not touched: tests/lock_order_discovery_db.rs, which already picks its
    own scratch domains (200-229, never 0) and passes them to its child
    through RUSTDDS_LOCK_ORDER_DOMAIN; and the programs in examples/,
    which are not tests.
  • README: a short "Running the tests" section.
  • Do not drop pending SEDP samples when a new participant is discovered #447 adds a test on domain 47; whichever lands second switches it to
    test_domain_id(47).

Validation (macOS): cargo test --tests -- --test-threads=1 without the
variable and with 12, 14, 16, 42 and 147 (694 unit, 2 + 2 integration
tests), with 42 also with --features security and --features mio_08,
all green; 148 and abc fail with the message; cargo test --doc (58)
green; lsof during the run with 14 showed no port of domain 0 open;
cargo clippy --all-targets and cargo +nightly fmt --check clean.

Developed with assistance from Claude Fable 5.1 and OpenAI Codex (gpt-6-astra).

The tests create their DomainParticipants on fixed domain ids, most of
them on domain 0. On a developer machine that shares a network with
other DDS systems, a test run therefore joins those systems' domain 0.
They discover the short-lived test participants and try to send to the
addresses these advertise.

RUSTDDS_TEST_DOMAIN_ID now sets a base that is added to the domain id
of each test participant. Unset or empty means 0, so without the
variable each test uses the same domain as before and CI is unchanged.
Each test keeps its current id as an offset (0, or 11, 51 and 52 for
the tests that keep apart from the others), so the tests stay on
separate domains after the shift. The unit tests that send raw packets
to the ports of domains 5, 12, 14, 15 and 16 shift those domains the
same way, so they stay off the ports of the shifted participants. A
value that is not a u16, or that is above 147, fails the test with a
message: the highest test domain, 147 + 52, stays below the lock-order
test's scratch domains (200-229).

The helper is in src/test/test_domain.rs, which the integration tests
include through tests/common/mod.rs. Not moved: the lock-order test's
scratch domains, examples/, and the doc examples, which still create
their participants on domain 0. `cargo test --tests` leaves the doc
tests out.

Assisted-by: Claude Fable 5.1
Assisted-by: OpenAI Codex (gpt-6-astra)
@jhelovuo

Copy link
Copy Markdown
Member

Thank you!

@jhelovuo
jhelovuo merged commit 9b665f8 into Atostek:master Oct 16, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants