Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Guidance for unit testing without UA_ENABLE_ALLOW_REUSEADDR #6407

Open
2 of 7 tasks
panicgh opened this issue Apr 11, 2024 · 1 comment
Open
2 of 7 tasks

Guidance for unit testing without UA_ENABLE_ALLOW_REUSEADDR #6407

panicgh opened this issue Apr 11, 2024 · 1 comment

Comments

@panicgh
Copy link
Contributor

panicgh commented Apr 11, 2024

Description

I seek guidance for running unit tests as part of packaging open62541 in a GNU/Linux distro. It seems unit tests fail if the project is configured with -DUA_BUILD_UNIT_TESTS=TRUE and without also passing -DUA_ENABLE_ALLOW_REUSEADDR=TRUE.

Background Information / Reproduction Steps

I maintain the open62541 package in NixOS. The normal procedure for building a package is basically configure, build, check, install. I.e. building and running unit tests is considered normal and increases confidence that we don't ship a broken package. Since v1.4.0, several tests fail if the project is configured with -DUA_BUILD_UNIT_TESTS=TRUE and without -DUA_ENABLE_ALLOW_REUSEADDR=TRUE. If reuseaddr is enabled, tests pass.

UA_ENABLE_ALLOW_REUSEADDR is described as an advanced option and only for tests.

  • Shall open62541 built with reuseaddr not be used in production (i.e. packaged and distributed)?
  • Would you recommend to just ignore/exclude the affected tests? Or should there be a full package build cycle with enabled unit tests and reuseaddr of which the result is thrown away? The packaged and distributed library would not be the one that was tested.
  • What about the open62541 project to enable these tests only if the project is configured with reuseaddr? This would allow as many tests as permitted by the configuration to run and you can continue using test-only builds with additional options in your CI.

The affected failing unit tests without reuseaddr are (at least):

  • check_server_reverseconnect
  • check_client_subscriptions
  • check_subscriptionWithactivateSession
  • check_client_historical_data

(Also check_eventloop_eth fails because it requires elevated permissions to use raw sockets. This is irrelevant for this issue, but a suggestion could be to check the permissions at runtime and skip the test if they are insufficient.)

Used CMake options (Nix package specific options stripped for brevity):

cmake -DCMAKE_BUILD_TYPE=Release -DOPEN62541_VERSION=v1.4.0 -DBUILD_SHARED_LIBS=ON -DUA_NAMESPACE_ZERO=FULL -DUA_BUILD_UNIT_TESTS=ON

Checklist

Please provide the following information:

  • open62541 Version (release number or git tag): v1.4.0
  • Other OPC UA SDKs used (client or server):
  • Operating system: NixOS (GNU/Linux)
  • Logs (with UA_LOGLEVEL set as low as necessary) attached
  • Wireshark network dump attached
  • Self-contained code example attached
  • Critical issue
@jpfr
Copy link
Member

jpfr commented Apr 26, 2024

You always want to have UA_ENABLE_ALLOW_REUSEADDR=TRUE for the unit tests.
Otherwise the operating systems needs a minute to release the socket after the last use.
Due to the TCP timeout.

In a productive server application it is recommended to have UA_ENABLE_ALLOW_REUSEADDR=FALSE. So that no other process can "steal the socket" of a running server.

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

No branches or pull requests

2 participants