commit | dc8eaeb39a03dc2c8611aa53e3a1bb962033f175 | [log] [tgz] |
---|---|---|
author | Yunze Xu <xyzinfernity@163.com> | Fri Oct 14 04:28:44 2022 +0800 |
committer | GitHub <noreply@github.com> | Thu Oct 13 13:28:44 2022 -0700 |
tree | f23b80825be8f38f897dcca37e33a77503c02195 | |
parent | f062598f6ae7fae019ad32546d31810cf5a734ab [diff] |
Enhance developer experience for debugging tests and add related README (#16) ### Motivation When I ran `python3 ./tests/pulsar_tests.py`, I found some tests failed. However, when I went into the container that was started by `./build-support/pulsar-test-service-start.sh`, the logs are incomplete because the immediate flush is disabled by default. Finally I found the error is caused by the relative path in tests. The certs are under `tests/test-conf` directory, but `pulsar_tests.py` uses the `test-conf/` relative path. Since `tests/run-unit-tests.sh` first goes to the `tests` directory before running the tests, CI works well. But a developer might just want to run a specific test from any possible directory, e.g. ```bash python3 ./tests/pulsar_tests.py PulsarTest.test_tls_auth ``` Then it could fail and he cannot see complete logs. ### Modifications - Modify `immediateFlush` to true - Use absolute path to represent `test-conf/` in `pulsar_tests.py` - Add an initial README for quick start
cmake -B build cmake --build build -j8 cp build/_pulsar.so . ./setup.py bdist_wheel pip3 install dist/pulsar_client-*.whl --force-reinstall rm _pulsar.so
NOTE
- Here a separate
build
directory is created to store all CMake temporary files. However, thesetup.py
requires the_pulsar.so
is under the project directory.- Add the
--force-reinstall
option to overwrite the existing Python wheel in case your system has already installed a wheel before.
You can run python3 -c 'import pulsar'
to see whether the wheel has been installed successfully. If it failed, check whether dependencies (e.g. libpulsar.so
) are in the system path. If not, make sure the dependencies are in LD_LIBRARY_PATH
(on Linux) or DYLD_LIBRARY_PATH
(on macOS).
Then you can run examples as a simple end-to-end test.
# In terminal 1 python3 ./examples/consumer.py
# In terminal 2 python3 ./examples/producer.py
Before executing the commands above, you must ensure the Pulsar service is running. See here for quick start.
Before running the unit tests, you must run a Pulsar service with all things set up:
./build-support/pulsar-test-service-start.sh
The command above runs a Pulsar standalone in a Docker container. You can run ./build-support/pulsar-test-service-stop.sh
to stop it.
Run all unit tests:
./tests/run-unit-tests.sh
Run a single unit test (e.g. PulsarTest.test_tls_auth
):
python3 ./tests/pulsar_test.py 'PulsarTest.test_tls_auth'