Commit fa3b3465 authored by Marek Vavruša's avatar Marek Vavruša

tests: fixed deckard integration, doc, travis

parent 241270b1
...@@ -35,6 +35,7 @@ script: ...@@ -35,6 +35,7 @@ script:
- make -j2 install COVERAGE=1 PREFIX=${HOME}/.local - make -j2 install COVERAGE=1 PREFIX=${HOME}/.local
- ./daemon/kresd -h - ./daemon/kresd -h
- make check COVERAGE=1 PREFIX=${HOME}/.local - make check COVERAGE=1 PREFIX=${HOME}/.local
- make check-integration COVERAGE=1 PREFIX=${HOME}/.local
after_success: after_success:
- test $TRAVIS_OS_NAME = linux && coveralls -i lib -i daemon -x ".c" --gcov-options '\-lp' - test $TRAVIS_OS_NAME = linux && coveralls -i lib -i daemon -x ".c" --gcov-options '\-lp'
sudo: false sudo: false
......
...@@ -151,6 +151,22 @@ Building extras ...@@ -151,6 +151,22 @@ Building extras
The project can be built with code coverage tracking using the ``COVERAGE=1`` variable. The project can be built with code coverage tracking using the ``COVERAGE=1`` variable.
Running unit and integration tests
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The unit tests require cmocka_ and are executed with ``make check``.
The integration tests use Deckard, the `DNS test harness <deckard>`_.
.. code-block:: bash
$ make check-integration
Note that the daemon and modules must be installed first before running integration tests, the reason is that the daemon
is otherwise unable to find and load modules.
Read the `documentation <deckard_doc>`_ for more information about requirements, how to run it and extend it.
.. _Docker images: https://registry.hub.docker.com/u/cznic/knot-resolver .. _Docker images: https://registry.hub.docker.com/u/cznic/knot-resolver
.. _libuv: https://github.com/libuv/libuv .. _libuv: https://github.com/libuv/libuv
.. _MSVC: https://msdn.microsoft.com/en-us/vstudio/hh386302.aspx .. _MSVC: https://msdn.microsoft.com/en-us/vstudio/hh386302.aspx
...@@ -172,3 +188,6 @@ The project can be built with code coverage tracking using the ``COVERAGE=1`` va ...@@ -172,3 +188,6 @@ The project can be built with code coverage tracking using the ``COVERAGE=1`` va
.. _Python: https://www.python.org/ .. _Python: https://www.python.org/
.. _boot2docker: http://boot2docker.io/ .. _boot2docker: http://boot2docker.io/
.. _deckard: https://gitlab.labs.nic.cz/knot/deckard
.. _deckard_doc: https://gitlab.labs.nic.cz/knot/resolver/blob/master/tests/README.rst
Unit tests Unit tests
========== ==========
The tests depend on cmocka_. The unit tests depend on cmocka_.
.. code-block:: bash .. code-block:: bash
$ make check-unit $ make check
.. todo:: Writing tests. .. todo:: Writing tests.
Integration tests Integration tests
================= =================
The tests depend on cwrap's `socket_wrapper`_, libfaketime_ and Python. The integration tests are using Deckard, the `DNS test harness <deckard>`_.
The libfaketime is included in ``contrib/libfaketime`` as it depends on rather latest version of it, It requires Jinja2_ and Python, `socket_wrapper`_, libfaketime_ are embedded in the build (cmake is required for `socket_wrapper`_).
it is automatically synchronised with ``make``.
Execute the tests by: Execute the tests by:
...@@ -23,8 +21,9 @@ Execute the tests by: ...@@ -23,8 +21,9 @@ Execute the tests by:
$ make check-integration $ make check-integration
.. todo:: Writing tests. See deckard_ documentation on how to write additional tests.
.. _cmocka: https://cmocka.org/ .. _cmocka: https://cmocka.org/
.. _`socket_wrapper`: https://cwrap.org/socket_wrapper.html .. _`socket_wrapper`: https://cwrap.org/socket_wrapper.html
.. _libfaketime: https://cwrap.org/socket_wrapper.html .. _libfaketime: https://cwrap.org/socket_wrapper.html
.. _deckard: https://gitlab.labs.nic.cz/knot/deckard
# # Config
# Integration tests
#
# Path to scenario files
TESTS=tests/integration/sets/resolver TESTS=tests/integration/sets/resolver
# Path to daemon
DAEMON=kresd
# Template file name
TEMPLATE=template/kresd.j2 TEMPLATE=template/kresd.j2
# Config file name
CONFIG=config
# Targets # Targets
deckard_DIR := tests/integration deckard_DIR := tests/integration
deckard := $(libfaketime_DIR)/deckard.py deckard := $(libfaketime_DIR)/deckard.py
libfaketime_DIR := contrib/libfaketime libfaketime_DIR := contrib/libfaketime
libfaketime := $(abspath $(libfaketime_DIR))/src/libfaketime$(LIBEXT).1 libfaketime := $(abspath $(libfaketime_DIR))/src/libfaketime$(LIBEXT).1
libswrap_DIR := contrib/libswrap libswrap_DIR := contrib/libswrap
libswrap_cmake_DIR := $(libswrap_DIR)/obj libswrap_cmake_DIR := $(libswrap_DIR)/obj
libswrap=$(abspath $(libswrap_cmake_DIR))/src/libsocket_wrapper$(LIBEXT).0 libswrap=$(abspath $(libswrap_cmake_DIR))/src/libsocket_wrapper$(LIBEXT).0
...@@ -36,19 +25,21 @@ $(deckard): ...@@ -36,19 +25,21 @@ $(deckard):
@git submodule update --init @git submodule update --init
$(libfaketime_DIR)/Makefile: $(libfaketime_DIR)/Makefile:
@git submodule update --init @git submodule update --init
# Build libfaketime contrib
# Build contrib libraries
$(libfaketime): $(libfaketime_DIR)/Makefile $(libfaketime): $(libfaketime_DIR)/Makefile
@CFLAGS="" $(MAKE) -C $(libfaketime_DIR) @CFLAGS="" $(MAKE) -C $(libfaketime_DIR)
$(libswrap_DIR): $(libswrap_DIR):
@git submodule update --init @git submodule update --init
$(libswrap_cmake_DIR):$(libswrap_DIR) $(libswrap_cmake_DIR): $(libswrap_DIR)
mkdir $(libswrap_cmake_DIR) @mkdir $(libswrap_cmake_DIR)
$(libswrap_cmake_DIR)/Makefile: $(libswrap_cmake_DIR) $(libswrap_cmake_DIR)/Makefile: $(libswrap_cmake_DIR)
@cd $(libswrap_cmake_DIR); cmake .. @cd $(libswrap_cmake_DIR); cmake ..
$(libswrap): $(libswrap_cmake_DIR)/Makefile $(libswrap): $(libswrap_cmake_DIR)/Makefile
@CFLAGS="-O2 -g" $(MAKE) -C $(libswrap_cmake_DIR) @CFLAGS="-O2 -g" $(MAKE) -s -C $(libswrap_cmake_DIR)
deckard: check-integration
check-integration: $(deckard) $(libswrap) $(libfaketime) check-integration: $(deckard) $(libswrap) $(libfaketime)
$(preload_syms) tests/integration/deckard.py $(TESTS) $(DAEMON) $(TEMPLATE) $(CONFIG) $(ADDITIONAL) @$(preload_LIBS) $(preload_syms) python tests/integration/deckard.py $(TESTS) $(abspath daemon/kresd) $(TEMPLATE) config
.PHONY: check-integration .PHONY: deckard check-integration
...@@ -17,12 +17,10 @@ endif ...@@ -17,12 +17,10 @@ endif
# Integration tests # Integration tests
ifeq ($(HAS_python)|$(HAS_socket_wrapper), yes|yes) ifeq ($(HAS_python)|$(HAS_socket_wrapper), yes|yes)
include tests/integration.mk include tests/integration.mk
else
$(warning python or socket_wrapper not found, skipping integration tests)
endif endif
# Targets # Targets
tests: check-unit check-integration tests: check-unit
tests-clean: $(foreach test,$(tests_BIN),$(test)-clean) tests-clean: $(foreach test,$(tests_BIN),$(test)-clean)
.PHONY: tests tests-clean .PHONY: tests tests-clean
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment