URL: https://github.com/freeipa/freeipa/pull/1346
Author: abbra
 Title: #1346: [Backport][ipa-4-6] Fix build for travis-ci
Action: opened

PR body:
"""
This PR was opened automatically because PR #1344 was pushed to master and 
backport to ipa-4-6 is required.
"""

To pull the PR as Git branch:
git remote add ghfreeipa https://github.com/freeipa/freeipa
git fetch ghfreeipa pull/1346/head:pr1346
git checkout pr1346
From 8fa87e4163f09bbc9c7c95005ee8c90e4b9bb0d9 Mon Sep 17 00:00:00 2001
From: Alexander Bokovoy <aboko...@redhat.com>
Date: Fri, 24 Nov 2017 16:55:33 +0200
Subject: [PATCH 1/3] ipa-kdb: override krb5.conf when testing KDC code in
 cmocka

When testing KDC code in cmocka we rely on libkrb5 defaults.
libkrb5 would read /etc/krb5.conf by default and would load a KDB
module from there if it is defined for the test realm (EXAMPLE.COM).

Since EXAMPLE.COM is a common name used for test realms, make sure to
not using /etc/krb5.conf from the system. Instead, force KRB5_CONFIG to
/dev/null so that only libkrb5 compiled-in defaults are in use.

In such setup libkrb5 will attempt to load KDB driver db2 for our test
realm. db2 driver doesn't fail if its database is not available (unlike
FreeIPA's one), so it survives initialization.

As result, ipa-kdb-tests pass without unexpected breakage.
---
 daemons/ipa-kdb/Makefile.am         | 2 ++
 daemons/ipa-kdb/tests/test_setup.sh | 2 ++
 2 files changed, 4 insertions(+)
 create mode 100755 daemons/ipa-kdb/tests/test_setup.sh

diff --git a/daemons/ipa-kdb/Makefile.am b/daemons/ipa-kdb/Makefile.am
index 5669349af2..d7696fc37d 100644
--- a/daemons/ipa-kdb/Makefile.am
+++ b/daemons/ipa-kdb/Makefile.am
@@ -62,6 +62,8 @@ ipadb_la_LIBADD = 		\
 	$(NULL)
 
 if HAVE_CMOCKA
+TESTS_ENVIRONMENT = . $(srcdir)/tests/test_setup.sh;
+dist_ipa_kdb_tests_SOURCES = tests/test_setup.sh
 TESTS = ipa_kdb_tests
 check_PROGRAMS = ipa_kdb_tests
 endif
diff --git a/daemons/ipa-kdb/tests/test_setup.sh b/daemons/ipa-kdb/tests/test_setup.sh
new file mode 100755
index 0000000000..b10fefce01
--- /dev/null
+++ b/daemons/ipa-kdb/tests/test_setup.sh
@@ -0,0 +1,2 @@
+KRB5_CONFIG=/dev/null
+export KRB5_CONFIG

From 94eeeda1a2bb84544fe80149d3f5ee6f5ab5a556 Mon Sep 17 00:00:00 2001
From: Alexander Bokovoy <aboko...@redhat.com>
Date: Tue, 21 Nov 2017 12:08:55 +0200
Subject: [PATCH 2/3] travis-ci: collect logs from cmocka tests

When 'make check' is run, automake produces logs for each test to be ran.
Collect all the logs from the tests.

Also prepare the template to quickly enable use of gdb with traceback
in case a test is crashing. To use it, add LOG_COMPILE definition to
the 'make' line.
---
 .test_runner_config.yaml          | 4 +++-
 .test_runner_config_py3_temp.yaml | 4 +++-
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/.test_runner_config.yaml b/.test_runner_config.yaml
index 928f64a146..febc38d126 100644
--- a/.test_runner_config.yaml
+++ b/.test_runner_config.yaml
@@ -24,11 +24,12 @@ server:
   realm: IPA.TEST
 steps:
   build:
-  - make V=0 ${make_target}
+  - make V=0 ${make_target} LOG_COMPILE='gdb -return-child-result -ex run -ex "thread apply all bt" -ex "quit" --args'
   builddep:
   - rm -rf /var/cache/dnf/*
   - "dnf makecache || :"
   - dnf builddep -y ${builddep_opts} -D "with_wheels 1" --spec freeipa.spec.in --best --allowerasing
+  - dnf install -y gdb
   cleanup:
   - chown -R ${uid}:${gid} ${container_working_dir}
   - journalctl -b --no-pager > systemd_journal.log
@@ -40,6 +41,7 @@ steps:
       /var/log/krb5kdc.log
       /var/log/pki
       systemd_journal.log
+      `find daemons -name '*.log' -print`
   - chown ${uid}:${gid} ${container_working_dir}/var_log.tar
   configure:
   - ./autogen.sh
diff --git a/.test_runner_config_py3_temp.yaml b/.test_runner_config_py3_temp.yaml
index 00d1de79ea..bdc1d0e335 100644
--- a/.test_runner_config_py3_temp.yaml
+++ b/.test_runner_config_py3_temp.yaml
@@ -26,11 +26,12 @@ server:
   realm: IPA.TEST
 steps:
   build:
-  - make V=0 ${make_target}
+  - make V=0 ${make_target} LOG_COMPILE='gdb -return-child-result -ex run -ex "thread apply all bt" -ex "quit" --args'
   builddep:
   - rm -rf /var/cache/dnf/*
   - "dnf makecache || :"
   - dnf builddep -y ${builddep_opts} --spec freeipa.spec.in --best --allowerasing
+  - dnf install -y gdb
   cleanup:
   - chown -R ${uid}:${gid} ${container_working_dir}
   - >
@@ -41,6 +42,7 @@ steps:
       /var/log/krb5kdc.log
       /var/log/pki
       systemd_journal.log
+      `find daemons -name '*.log' -print`
   - chown ${uid}:${gid} ${container_working_dir}/var_log.tar
   configure:
   - ./autogen.sh

From 035597b2d1ab18638d92daf3bf104d1d95f53f8d Mon Sep 17 00:00:00 2001
From: Alexander Bokovoy <aboko...@redhat.com>
Date: Tue, 28 Nov 2017 22:48:45 +0200
Subject: [PATCH 3/3] test_dns_plugin: cope with missing IPv6 in Travis

If IPv6 is not enabled, cope with the possibility to get incomplete
output back from the IPA CLI.

To do so, use lambda to analyze the result rather than explicit
comparison with the expected output.
---
 ipatests/test_xmlrpc/test_dns_plugin.py | 23 ++++++-----------------
 1 file changed, 6 insertions(+), 17 deletions(-)

diff --git a/ipatests/test_xmlrpc/test_dns_plugin.py b/ipatests/test_xmlrpc/test_dns_plugin.py
index 9fd5266e58..7ecb39bb94 100644
--- a/ipatests/test_xmlrpc/test_dns_plugin.py
+++ b/ipatests/test_xmlrpc/test_dns_plugin.py
@@ -1107,23 +1107,12 @@ def setup_class(cls):
                   'options' % (name1, zone1)),
             command=('dnsrecord_show', [zone1, name1],
                      {'structured': True, 'all': True}),
-            expected={
-                'value': name1_dnsname,
-                'summary': None,
-                'result': {
-                    'dn': name1_dn,
-                    'idnsname': [name1_dnsname],
-                    'objectclass': objectclasses.dnsrecord,
-                    'dnsrecords': [
-                        {u'aaaa_part_ip_address': aaaarec1,
-                         u'dnsdata': aaaarec1,
-                         u'dnstype': u'AAAA'},
-                        {u'a_part_ip_address': arec3,
-                         u'dnsdata': arec3,
-                         u'dnstype': u'A'}
-                    ],
-                },
-            },
+            expected=lambda o, x: (
+                'result' in x and
+                'dnsrecords' in x['result'] and
+                (len(x['result']['dnsrecords']) in (1, 2)) and
+                (any(y[u'dnsdata'] in (aaaarec1, arec3)
+                     for y in x['result']['dnsrecords']))),
         ),
 
         dict(
_______________________________________________
FreeIPA-devel mailing list -- freeipa-devel@lists.fedorahosted.org
To unsubscribe send an email to freeipa-devel-le...@lists.fedorahosted.org

Reply via email to