Skip to content

Configurable ports for the objects and states DBs of the integration tests - #735

Open
krobipd wants to merge 3 commits into
ioBroker:masterfrom
krobipd:feat/configurable-ports
Open

Configurable ports for the objects and states DBs of the integration tests#735
krobipd wants to merge 3 commits into
ioBroker:masterfrom
krobipd:feat/configurable-ports

Conversation

@krobipd

@krobipd krobipd commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

Why

Two adapter test runs on the same machine collide: both start their objects and states DBs on the fixed ports 19001/19000, and the second run's databases never come up. That hits anyone who runs the integration tests of two adapters in parallel — two terminals, or two CI jobs on one self-hosted runner. A leftover run blocking the next one (#488) is the same fixed pair of ports from the other side.

Measured with two installed test controllers side by side: one DBConnection on the defaults comes up, a second one on the defaults does not (times out), a second one on 29001/29000 comes up next to the first — four listeners on 127.0.0.1.

What

  • New option for tests.integration(adapterDir, { ports: { objects, states } }).
  • Fallback to the environment variables IOBROKER_TESTING_OBJECTS_PORT / IOBROKER_TESTING_STATES_PORT (the option wins), then to the previous defaults 19001/19000 — nothing changes for existing users.
  • The ports are handed to DBConnection (server and client settings) and to ControllerSetup.setupSystemConfig() (the controller's iobroker.json), so the adapter under test reaches the same DBs.
  • Validation: integer between 1 and 65535, both DBs need different ports; an invalid value fails at testAdapter() time with a message naming the option or variable.
  • The debug line Moving databases to different ports... stays verbatim (the repochecker expects it in the adapter-tests job log); the chosen ports are logged on a separate line.
  • README: the option is described in its own paragraph for parallel runs on one machine (not in the main example), with the note to leave it unset in workflow-based tests on GitHub; CHANGELOG (WORK IN PROGRESS) updated; build/ rebuilt as in the other feature commits.

Tests

  • src/tests/integration/lib/ports.test.ts — defaults, environment, option over environment, partial option, empty variable, invalid values, equal ports.
  • src/tests/integration/lib/controllerSetup.test.ts — the given ports (and the defaults) land in the system config, the rest of the config stays untouched, DBConnection carries its ports.
  • npm run check, npm run lint, npm test (51 passing), npm run build — all green.

🤖 Generated with Claude Code

Two adapter test runs on one machine collide on the fixed ports 19001/19000:
the second run's databases never come up (measured with two installed test
controllers side by side). The integration tests now accept
`ports: { objects, states }`, fall back to the environment variables
IOBROKER_TESTING_OBJECTS_PORT / IOBROKER_TESTING_STATES_PORT and then to the
previous defaults, and hand the ports to the DB connection and to the
controller's system config. Both DBs must use different ports; an invalid
value fails early with a clear message. Defaults are unchanged.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@mcm1957

mcm1957 commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

NOTE: Such an option MUST NOT be used with workflow based tests at github as this would cause the external check to fail. As github uses seperated serves such a collision cannot occure in standard testing environment.

krobipd and others added 2 commits September 8, 2026 18:07
…og line

The ioBroker repochecker expects this exact line in the adapter-tests job log
(W3053), so it stays verbatim; the chosen ports are logged on a separate line.
The README describes the ports option in its own paragraph for parallel runs
on one machine and says to leave it unset in workflow-based tests on GitHub.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…rmat)

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@krobipd

krobipd commented Sep 8, 2026

Copy link
Copy Markdown
Contributor Author

Thanks, and you are right in a stronger sense than the note says: the PR also changed the debug line "Moving databases to different ports...", which is one of the lines the repochecker expects in the adapter-tests job log, so every adapter would have hit W3053 after a release. Fixed: the original line is back verbatim, the chosen ports are logged on a separate line, and the README now describes the option in its own paragraph for parallel runs on one machine, with the note that it is not to be set in workflow-based tests. GitHub jobs keep the defaults.

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