Skupper Router is a high-performance, lightweight AMQP 1.0 message router. It provides flexible and scalable interconnect between any AMQP endpoints, and is forked from the qpid-dispatch project to focus on the Skupper use case.
Note
|
Skupper router only supports the Linux OS. |
To build skupper router on a yum-based Linux system, you need the following packages installed:
-
qpid-proton-c-devel
-
python3-qpid-proton
-
cmake
-
make
-
gcc
-
gcc-c++
-
python3-devel
-
cyrus-sasl-plain
-
cyrus-sasl-devel
-
libnghttp2-devel
-
asciidoc (for building docs)
-
asciidoctor (for building docs)
To build formatted documentation (man pages, HTML, PDF) see the requirements in doc/README.adoc
From the skupper-router
directory:
$ mkdir my_build # or directory of your choice.
$ cd my_build
$ cmake ..
$ make
From the <build>
directory you can run all the system- and unit-tests with:
$ ctest -VV
The ctest
tool uses the script <build>/test/run.py
to set up the correct environment for tests.
You can use it to run tests individually from the <build>/tests
directory.
$ ./run.py unit_tests_size 3
$ ./run.py -m unittest system_tests_qdstat
Run it without arguments to get a summary of how it can be used:
$ ./run.py
This project uses the pre-commit git hook management framework.
$ dnf install pre-commit
$ pre-commit install
The second command will install the pre-commit script into your ./.git/hooks/pre-commit
.
Hooks are configured in .pre-commit-config.yaml
.
The git clang-format
hook enforces code-conventions for modified C code upon git commit
.
Every time a user attempts a commit, clang-format is run for the staged files and if an incorrectly formatted line is detected, the commit aborts.
The changed lines are automatically formatted during this operation, so after reviewing the changes, the user can then repeat the commit.
Read this git hooks article on redhat.com (as well as documentation for pre-commit) to learn more.
The HTTP2 system tests (tests/system_tests_http2.py
) use the Python Quart and hyper-h2 frameworks to start a HTTP2 server.
The HTTP2 system tests only runs if
-
Python version >= 3.7
-
Python Web Microframework Quart version >= 0.13
-
curl is available
-
hyper-h2 is available (pure-Python implementation of a HTTP/2 protocol stack)
The TCP system tests (tests/system_tests_tcp_adaptor.py) use the Python selectors module when running echo clients and servers.
The TCP system tests run only if Python selectors is available.
Several tests require the nc
(ncat) binary to be present.
dnf install curl nmap-ncat
pip3 install --user quart h2 selectors
Websocket system tests use the Python websockets
asyncio module.
pip3 install --user websockets
The gRPC system tests (tests/system_tests_grpc.py) use grpcio
and protobuf
modules.
pip3 install --user grpcio protobuf
In order to regenerate the auto generated pb2 files used by system_tests_grpc.py, you must also install the following dependency:
pip3 install --user grpcio-tools
And run the following command to generate grpc code:
python -m grpc_tools.protoc -I. --python_out=. --grpc_python_out=. ./friendship.proto
The system tests are implemented using Python’s unittest library.
This library is used to run the tests by default.
The tests can be also run using xmlrunner
or pytest
.
Pytest can generate a JUnit-compatible XML report containing an entry for each Python test method.
After running the tests, all XML reports can be found under tests/junitxmls
in your build directory:
cmake .. -DPYTHON_TEST_COMMAND='-m;pytest;-vs;--junit-xml=junitxmls/${py_test_module}.xml;--pyargs;${py_test_module}'
System tests can be configured to run skrouterd
processes with an arbitrary wrapper.
To do this, set the QDROUTERD_RUNNER
CMake option to a string that will be prepended before all skrouterd
invocations during testing.
The following example illustrates how to run the router under gdb
, to obtain a backtrace if the router crashes.
cmake .. -DQDROUTERD_RUNNER="gdb -quiet -iex 'set pagination off' -iex 'set debuginfod enabled on' -ex run -ex 'thread apply all bt' -ex 'quit $_exitcode' --batch --args"
Use coverage analysis to ensure that all code paths are exercised by the test suite. To run the tests and perform code coverage analysis:
-
Install the lcov package
$ yum install lcov
-
Configure and build for the Coverage build type (from the <build> directory):
$ cmake -DCMAKE_BUILD_TYPE=Coverage .. && make
-
Run the test suite and generate the coverage html output
$ ctest && make coverage
-
Use your browser to navigate to
<build>/coverage_results/html/index.html
Warning
|
Any preexisting directories 'build' and 'install' are deleted. |
Run the following command:
$ source config.sh; test.sh
This script then does the following:
-
performs a fresh cmake and make in directory 'build'
-
runs unit tests (not system tests) in 'build'
-
performs 'make install' into the directory 'install'
-
runs system tests on the installation in 'install'.
The CTest test suite can be configured to enable extra run time validation checks against the skupper router.
Since run time validation slows down skrouterd
considerably it is disabled by default.
It can be enabled by setting the RUNTIME_CHECK
build flag via the cmake
command.
Note
|
Depending on your environment the ctest suite may time out if validation is enabled due to the additional run time overhead it adds.
You can extend the default test time via the ctest --timeout
option.
|
ctest --timeout 1500 -VV
The Skupper Router test suite supports the following run time validation tools:
Memcheck runs skrouterd
under Valgrind’s memcheck leak checker during the CTest suite.
This causes tests to fail if a memory error is encountered.
Use the grinder tool (in the bin directory) to create a summary of the errors found during the test run.
The valgrind toolset must be installed in order to use memcheck.
To enable memcheck set the RUNTIME_CHECK build flag to "memcheck":
cmake .. -DRUNTIME_CHECK=memcheck
If valgrind detects errors, the skrouterd
process exits with an exit code of 42
and a message is displayed in the CTest output.
For example:
RuntimeError: Errors during teardown:
Process XXXX error: exit code 42, expected 0
This option turns on extra run time threading verification.
Note
|
Applicable only to GCC versions >= 7.4 and Clang versions >= 6.0. |
To enable the thread sanitizer set the RUNTIME_CHECK build flag to tsan
:
cmake .. -DRUNTIME_CHECK=tsan
The TSAN library (libtsan) must be installed in order to use this option.
If threading violations are detected during the CTest suite the skrouterd
process exits with an exit code of 66
and a message is displayed in the CTest output. For example:
RuntimeError: Errors during teardown:
Process XXXX error: exit code 66, expected 0
False positives can be suppressed via the tsan.supp
file in the tests directory.
This option turns on extra run time memory verification, including leak checks.
Note
|
Applicable only to GCC versions >= 5.4 and Clang versions >= 6.0. |
To enable the address sanitizer set the RUNTIME_CHECK build flag to "asan":
cmake .. -DCMAKE_C_FLAGS=-DQD_MEMORY_DEBUG -DRUNTIME_CHECK=asan
On Aarch64, a hardware-assisted address sanitizer is enabled with hwasan
.
The ASAN (libasan) and UBSAN (libubsan) libraries must be installed in order to use this option.
cmake .. -DCMAKE_C_FLAGS=-DQD_MEMORY_DEBUG -DRUNTIME_CHECK=hwasan
Note
|
The memory pool produces false leak reports unless QD_MEMORY_DEBUG is also defined.
|
False positive leak errors can be suppressed by using the lsan.supp
file in the tests
directory.
Use cmake-gui
to explore the CMake build options available.
Existing build directory can be opened with cmake-gui -S .. -B .
CMake option | Description |
---|---|
|
Skupper router defaults to building with the |
|
Setting this to |
|
Enables C/C++ runtime checkers. See "Run Time Validation" chapter above. |
|
Enables Leak Sanitizer suppressions for libpython3. Use it to disable sanitization with older Python version (< 3.9). |
|
Compiles the project with LTO (Link Time Optimization) enabled. |
|
Skupper router immediately frees memory, instead of returning it to memory pool.
This option breaks safe pointers, resulting in crashes, therefore is suitable only for debugging.
When combined with |
|
Excludes project’s tests from the build. |
|
Sets the version of skupper-router. E.g. |
|
Benchmarking tests will be built.
The |
|
Build will be allowed to succeed when compilation warnings are present. |