Skip to content

Fix unstable AudioConsoleTest - #5781

Merged
holgerfriedrich merged 1 commit into
openhab:mainfrom
wborn:3405-fix-audio-console-test
Aug 18, 2026
Merged

Fix unstable AudioConsoleTest#5781
holgerfriedrich merged 1 commit into
openhab:mainfrom
wborn:3405-fix-audio-console-test

Conversation

@wborn

@wborn wborn commented Aug 16, 2026

Copy link
Copy Markdown
Member

Description

This fixes the unstable AudioConsoleTest reported in #3405.

The stream tests currently create their local HTTP test stream with a five-second lifetime. That timeout starts when the stream URL is created, not when URLAudioStream actually connects to it. On a sufficiently slow or loaded CI runner, the stream can therefore expire before the connection is made.

When that happens, AudioServlet removes the expired stream and the HTTP request fails. Constructing URLAudioStream then throws an AudioException, which is caught by AudioConsoleCommandExtension. Because the audio manager never reaches the sink, AudioSinkFake.audioStream remains null, and the test subsequently fails with the misleading NullPointerException reported in the issue.

The previous increase of this timeout from one to five seconds only reduced the likelihood of the failure; it did not remove the timing dependency.

Changes

  • Use the one-shot serveStream(audioStream) overload in the two console stream tests instead of an arbitrarily expiring stream.
  • Remove the now-unused five-second test timeout.
  • Assert that the sink actually received a URLAudioStream before checking its URL, so a future failure reports the real state instead of producing an NPE.
  • Close the captured URLAudioStream after verification.

The one-shot stream is a better fit for these tests because they only need a single HTTP access and are not testing stream expiration behavior.

Fixes #3405

Testing

The change is limited to AudioConsoleTest. The commit and diff were verified against current main. A local Maven test run could not be performed in the execution environment because direct outbound access to GitHub is unavailable; the pull request CI will run the repository checks.

Use a one-shot test stream instead of a stream with an arbitrary five-second expiration. This prevents slow CI runners from expiring the stream before URLAudioStream connects to it.

Assert the captured stream type explicitly and close it after verification so failures are clearer and resources are released.

Fixes openhab#3405

Signed-off-by: Wouter Born <github@maindrain.net>
@wborn
wborn force-pushed the 3405-fix-audio-console-test branch from 41764ee to 35abb49 Compare August 16, 2026 09:58
@wborn wborn added the test label Aug 16, 2026
@wborn
wborn marked this pull request as ready for review August 16, 2026 10:14
@wborn
wborn requested a review from a team as a code owner August 16, 2026 10:14

@holgerfriedrich holgerfriedrich left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks for fixing unstable tests!

@holgerfriedrich
holgerfriedrich merged commit dc36cf7 into openhab:main Aug 18, 2026
6 checks passed
@holgerfriedrich holgerfriedrich added this to the 5.3 milestone Aug 18, 2026
@wborn
wborn deleted the 3405-fix-audio-console-test branch August 18, 2026 20:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

AudioConsoleTest unstable

2 participants