uatools 1.0.0
 
Loading...
Searching...
No Matches
client_itest.cpp File Reference

Integration tests for eso::uatools::Client. More...

#include <atomic>
#include <chrono>
#include <cstdint>
#include <cstdlib>
#include <filesystem>
#include <fstream>
#include <mutex>
#include <set>
#include <string>
#include <thread>
#include <vector>
#include <arpa/inet.h>
#include <fcntl.h>
#include <netinet/in.h>
#include <signal.h>
#include <sys/socket.h>
#include <sys/wait.h>
#include <unistd.h>
#include <gtest/gtest.h>
#include <eso/uatools/ualib/client.hpp>
#include <ifw/fnd/defs/iCommAdapter.hpp>
#include <ifw/fnd/defs/logger.hpp>

Classes

class  eso::uatools::itest_tests::ItestLoggerEnvironment
 
class  eso::uatools::itest_tests::IntegrationTest
 

Namespaces

namespace  eso
 
namespace  eso::uatools
 
namespace  eso::uatools::itest_tests
 

Functions

std::uint16_t eso::uatools::itest_tests::FindFreePort ()
 
bool eso::uatools::itest_tests::WaitForPort (const std::string &host, std::uint16_t port, std::chrono::milliseconds timeout)
 
std::string eso::uatools::itest_tests::LocateItestYaml ()
 
std::string eso::uatools::itest_tests::LocateItestServer ()
 
std::string eso::uatools::itest_tests::LocateBuildLibDir ()
 
 eso::uatools::itest_tests::TEST_F (IntegrationTest, ReadInitialValueOfCounter)
 
 eso::uatools::itest_tests::TEST_F (IntegrationTest, WriteThenReadBack)
 
 eso::uatools::itest_tests::TEST_F (IntegrationTest, CallReturnsInt32Zero)
 
 eso::uatools::itest_tests::TEST_F (IntegrationTest, TwoClientsSameEndpointShareConnection)
 
 eso::uatools::itest_tests::TEST_F (IntegrationTest, PerNodeHandlerIsolationOnSameClient)
 
 eso::uatools::itest_tests::TEST_F (IntegrationTest, WriteTriggersSubscriptionNotification)
 
 eso::uatools::itest_tests::TEST_F (IntegrationTest, HandlerCanCallReadFromInsideHandler)
 
 eso::uatools::itest_tests::TEST_F (IntegrationTest, SlowHandlerDoesNotStallDataPlane)
 

Detailed Description

Integration tests for eso::uatools::Client.

These tests spawn a real OPC UA server (the UaItestServer CLI binary, with its stdout/stderr redirected to /dev/null) as a child process, then exercise ualib's Client against it. Complements the unit-test suite in ualib/test/ which covers contract-shape only (no network).

Why subprocess and not in-thread? open62541's UA_ServerConfig_setMinimal emits ~12 chatty lines during startup (info/eventloop, warn/server AccessControl, info/session AddNode) BEFORE we can install a custom UA_Logger on the server config. In-process embedding of the server thus leaks those lines into gtest's own stdout. Subprocess execution redirects the child's stdout/stderr to /dev/null so the parent sees nothing — at the cost of ~100 ms fork/exec/wait-for-port overhead per test (acceptable given total runtime <20 s).

Coverage focus: things Robot tests cannot easily express.

  • Connection sharing — two Clients on the same (endpoint, user) attach to the same OpcuaConnection (verified via shared_ptr use_count on the registry).
  • Per-node SubscriptionHandler isolation — two Subscribe calls with different handlers and disjoint nodes; each handler must only see its own notifications.
  • Round-trip Read/Write.
  • Subscribe end-to-end with notification delivery.
  • Handler-can-Read-from-inside-handler (deadlock-free re-entry).

Each test uses an ephemeral port so parallel runs don't collide. UATOOLS_ITEST_LOG_LEVEL (env) is forwarded to the child's -l flag so debugging can crank the SDK output up without rebuilding.