[SSSD] [PATCH] Add integration tests
Jakub Hrozek
jhrozek at redhat.com
Mon Mar 23 09:12:24 UTC 2015
On Fri, Feb 27, 2015 at 07:13:37PM +0200, Nikolai Kondrashov wrote:
> Hi everyone,
>
> This is my attempt to add basic integration tests. There are almost no tests
> there at the moment and this is mostly about the infrastructure and the way we
> might do it.
>
> I will be glad to answer any questions and receive any comments or
> suggestions. I'm sure I did a lot of things in a wrong way :)
>
> Thank you!
>
> CI: http://sssd-ci.duckdns.org/logs/job/8/40/summary.html
>
> Nick
I checked the build system changes since Michal requested another
reviwer there.
> From a4e3c569d35e6f812ff641f38e89982d0254eaba Mon Sep 17 00:00:00 2001
> From: Nikolai Kondrashov <Nikolai.Kondrashov at redhat.com>
> Date: Mon, 24 Nov 2014 19:13:16 +0200
> Subject: [PATCH 1/1] Add integration tests
>
> Add --enable-intgcheck configure option, which enables "intgcheck" make
> target. CI is updated to use them.
>
> The "intgcheck" target configures and builds sssd in a sub-directory,
> installs it into a prefix in another sub-directory, and then makes the
> "intgcheck-installed" target from within src/tests/intg in that separate
> build.
>
> The "intgcheck-installed" target in src/tests/intg runs py.test for all
> tests it can find in that directory, under fakeroot and
> nss_wrapper/uid_wrapper environments emulating running under root.
>
> The only test in src/tests/intg at the moment - ldap_test.py sets up and
> starts a slapd instance, adds a few user and group entries, configures
> and starts sssd and verifies that those users and groups are retrieved
> correctly using various nss functions.
>
> The above only works on Red Hat distros, mostly because Debian lacks
> nss_wrapper package. The tests are very basic and error reporting on
> mismatch in data received from nss is very rudimentary, at the moment.
> There is also a good amount of duplication between rfc2307 and
> rfc2307bis cases, which might be dealt with later.
> ---
> Makefile.am | 29 ++++-
> configure.ac | 15 ++-
> contrib/ci/configure.sh | 6 +
> contrib/ci/deps.sh | 11 +-
> contrib/ci/run | 9 ++
> src/external/fakeroot.m4 | 2 +
> src/external/intgcheck.m4 | 23 ++++
> src/external/ldap.m4 | 6 +
> src/external/pytest.m4 | 3 +
> src/external/python.m4 | 49 +++++++
> src/tests/intg/Makefile.am | 59 +++++++++
> src/tests/intg/config.py.m4 | 13 ++
> src/tests/intg/ent.py | 163 +++++++++++++++++++++++
> src/tests/intg/ldap_test.py | 296 ++++++++++++++++++++++++++++++++++++++++++
> src/tests/intg/misc.py | 49 +++++++
> src/tests/intg/slapd_setup | 246 +++++++++++++++++++++++++++++++++++
> src/tests/intg/slapd_teardown | 49 +++++++
> 17 files changed, 1024 insertions(+), 4 deletions(-)
> create mode 100644 src/external/fakeroot.m4
> create mode 100644 src/external/intgcheck.m4
> create mode 100644 src/external/pytest.m4
> create mode 100644 src/tests/intg/Makefile.am
> create mode 100644 src/tests/intg/config.py.m4
> create mode 100644 src/tests/intg/ent.py
> create mode 100644 src/tests/intg/ldap_test.py
> create mode 100644 src/tests/intg/misc.py
> create mode 100755 src/tests/intg/slapd_setup
> create mode 100755 src/tests/intg/slapd_teardown
>
> diff --git a/Makefile.am b/Makefile.am
> index 8f0ce4b..647f1e8 100644
> --- a/Makefile.am
> +++ b/Makefile.am
> @@ -19,7 +19,7 @@ if HAVE_MANPAGES
> SUBDIRS += src/man
> endif
>
> -SUBDIRS += . src/tests/cwrap
> +SUBDIRS += . src/tests/cwrap src/tests/intg
>
> # Some old versions of automake don't define builddir
> builddir ?= .
> @@ -2280,6 +2280,33 @@ autofs_test_client_CFLAGS = $(AM_CFLAGS)
> autofs_test_client_LDADD = -lpopt $(CLIENT_LIBS)
> endif
>
> +#####################
> +# Integration tests #
> +#####################
> +
> +if ENABLE_INTGCHECK
> +intgcheck:
> + set -e; \
> + rm -Rf intg; \
> + $(MKDIR_P) intg/bld; \
> + : Use /hopefully/ short prefix to keep D-Bus socket path short; \
I admit I don't know what are these lines that start with a colon?
> + prefix=`mktemp --tmpdir --directory sssd-intg.XXXXXXXX`; \
> + $(LN_S) "$$prefix" intg/pfx; \
> + cd intg/bld; \
> + $(abs_top_srcdir)/configure \
> + --prefix="$$prefix" \
> + --with-ldb-lib-dir="$$prefix"/lib/ldb \
> + $(INTGCHECK_CONFIGURE_FLAGS); \
> + $(MAKE) $(AM_MAKEFLAGS); \
> + : Force single-thread install to workaround concurrency issues; \
> + $(MAKE) $(AM_MAKEFLAGS) -j1 install; \
> + : Remove .la files from LDB module directory to avoid loader warnings; \
> + rm "$$prefix"/lib/ldb/*.la; \
> + $(MAKE) $(AM_MAKEFLAGS) -C src/tests/intg intgcheck-installed; \
> + cd ../..; \
> + rm -Rf "$$prefix" intg
> +endif # ENABLE_INTGCHECK
> +
> ####################
> # Client Libraries #
> ####################
> diff --git a/configure.ac b/configure.ac
> index e30405f..225ff64 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -174,6 +174,9 @@ m4_include([src/external/configlib.m4])
> m4_include([src/external/libnfsidmap.m4])
> m4_include([src/external/cwrap.m4])
> m4_include([src/external/libresolv.m4])
> +m4_include([src/external/fakeroot.m4])
> +m4_include([src/external/pytest.m4])
> +m4_include([src/external/intgcheck.m4])
>
> if test x$build_config_lib = xyes; then
> m4_include([src/external/libaugeas.m4])
> @@ -248,8 +251,8 @@ AM_CONDITIONAL([HAVE_PROFILE_CATALOGS], [test "x$HAVE_PROFILE_CATALOGS" != "x"])
> AM_CONDITIONAL([HAVE_MANPAGES], [test "x$HAVE_MANPAGES" != "x"])
> AM_CONDITIONAL([HAVE_PO4A], [test "x$PO4A" != "xno"])
>
> +AC_PATH_PROG(PYTHON2, python2)
> if test x$HAVE_PYTHON2_BINDINGS = x1; then
> - AC_PATH_PROG(PYTHON2, python2)
> PYTHON=$PYTHON2
> AM_PATH_PYTHON([2.6])
> AM_PYTHON_CONFIG([python2])
> @@ -268,9 +271,10 @@ if test x$HAVE_PYTHON2_BINDINGS = x1; then
>
> SSS_CLEAN_PYTHON_VARIABLES
> fi
> +AM_CONDITIONAL([HAVE_PYTHON2], [test x"$PYTHON2" != x])
>
> +AC_PATH_PROG(PYTHON3, python3)
> if test x$HAVE_PYTHON3_BINDINGS = x1; then
> - AC_PATH_PROG(PYTHON3, python3)
> PYTHON=$PYTHON3
> AM_PATH_PYTHON([3.3])
> AM_PYTHON_CONFIG([python3])
> @@ -289,11 +293,15 @@ if test x$HAVE_PYTHON3_BINDINGS = x1; then
>
> SSS_CLEAN_PYTHON_VARIABLES
> fi
> +AM_CONDITIONAL([HAVE_PYTHON3], [test x"$PYTHON3" != x])
I think the HAVE_PYTHON changes should be in a separate patch.
>
> AM_CONDITIONAL([BUILD_PYTHON_BINDINGS],
> [test x"$with_python2_bindings" = xyes \
> -o x"$with_python3_bindings" = xyes])
>
> +AM_PYTHON2_MODULE([ldap])
> +AM_CONDITIONAL([HAVE_PY2MOD_LDAP], [test x"$HAVE_PY2MOD_LDAP" == xyes])
> +
> if test x$HAVE_SELINUX != x; then
> AM_CHECK_SELINUX
> AM_CHECK_SELINUX_LOGIN_DIR
> @@ -366,6 +374,8 @@ AM_CHECK_CMOCKA
> AM_CHECK_UID_WRAPPER
> AM_CHECK_NSS_WRAPPER
>
> +AM_ENABLE_INTGCHECK
[...]
> diff --git a/src/tests/intg/Makefile.am b/src/tests/intg/Makefile.am
> new file mode 100644
> index 0000000..dc1d6f0
> --- /dev/null
> +++ b/src/tests/intg/Makefile.am
> @@ -0,0 +1,59 @@
> +dist_noinst_SCRIPTS = \
> + slapd_setup \
> + slapd_teardown \
> + $(NULL)
> +
> +dist_noinst_DATA = \
> + config.py.m4 \
> + ent.py \
> + ldap_test.py \
> + misc.py \
> + $(NULL)
> +
> +config.py: config.py.m4
> + m4 -D "prefix=\`$(prefix)'" \
> + -D "sysconfdir=\`$(sysconfdir)'" \
> + -D "dbpath=\`$(dbpath)'" \
> + -D "pidpath=\`$(pidpath)'" \
> + -D "logpath=\`$(logpath)'" \
> + -D "mcpath=\`$(mcpath)'" \
> + $< > $@
> +
> +root:
> + $(MKDIR_P) -m 0700 root/.dbus-keyrings
Can we add a comment why we need the dbus-keyring directory?
> +
> +passwd: root
> + echo "root:x:0:0:root:$(abs_builddir)/root:/bin/bash" > $@
> +
> +group:
> + echo "root:x:0:" > $@
> +
> +CLEANFILES=config.py config.pyc passwd group
> +
> +clean-local:
> + rm -Rf root
> +
> +intgcheck-installed: config.py passwd group
> + pipepath="$(DESTDIR)$(pipepath)"; \
> + if test $${#pipepath} -gt 80; then \
> + echo "error: Pipe directory path too long," \
> + "D-Bus won't be able to open sockets" >&2; \
> + exit 1; \
> + fi
> + set -e; \
> + nss_wrapper=$$(pkg-config --libs nss_wrapper); \
> + uid_wrapper=$$(pkg-config --libs uid_wrapper); \
> + PATH="$$(dirname -- $(SLAPD)):$$PATH" \
Interesting ^, is slapd typically out of $PATH?
> + PATH="$(DESTDIR)$(sbindir):$(DESTDIR)$(bindir):$$PATH" \
> + PATH="$(abs_builddir):$(abs_srcdir):$$PATH" \
> + PYTHONPATH="$(abs_builddir):$(abs_srcdir)" \
> + LDB_MODULES_PATH="$(DESTDIR)$(ldblibdir)" \
> + LD_PRELOAD="$$nss_wrapper $$uid_wrapper" \
> + NSS_WRAPPER_PASSWD="$(abs_builddir)/passwd" \
> + NSS_WRAPPER_GROUP="$(abs_builddir)/group" \
> + NSS_WRAPPER_MODULE_SO_PATH="$(DESTDIR)$(nsslibdir)/libnss_sss.so.2" \
> + NSS_WRAPPER_MODULE_FN_PREFIX="sss" \
> + UID_WRAPPER=1 \
> + UID_WRAPPER_ROOT=1 \
> + fakeroot $(PYTHON2) $(PYTEST) --tb=native "$(abs_srcdir)"
> + rm -f $(DESTDIR)$(logpath)/*
> diff --git a/src/tests/intg/config.py.m4 b/src/tests/intg/config.py.m4
> new file mode 100644
> index 0000000..563127c
> --- /dev/null
> +++ b/src/tests/intg/config.py.m4
> @@ -0,0 +1,13 @@
> +"""
> +Build configuration variables.
> +"""
> +
> +PREFIX = "prefix"
> +SYSCONFDIR = "sysconfdir"
> +SSSDCONFDIR = SYSCONFDIR + "/sssd"
> +CONF_PATH = SSSDCONFDIR + "/sssd.conf"
> +DB_PATH = "dbpath"
> +PID_PATH = "pidpath"
> +PIDFILE_PATH = PID_PATH + "/sssd.pid"
> +LOG_PATH = "logpath"
> +MCACHE_PATH = "mcpath"
More information about the sssd-devel
mailing list