On 09/24/2013 05:34 PM, Petr Viktorin wrote:
On 06/04/2013 05:48 PM, Simo Sorce wrote:
On Tue, 2013-06-04 at 17:24 +0200, Petr Viktorin wrote:
On 06/04/2013 02:53 PM, Simo Sorce wrote:
On Tue, 2013-06-04 at 13:48 +0200, Petr Viktorin wrote:
Hardcoding the in-tree location for ipa-getkeytab makes testing
outside
the source tree impossible. This patch makes the tests use the
installed
location.

In other places the test suite assumes IPA is installed system-wide,
even if running from the source tree.
I know I frequently forget to run `make` before testing, which
makes the
ipa-getkeytab tests fail. So this patch would work well for me (and
probably other Python devs), but I guess others might be used to `make
test` checking what `make` built.

C developers, are you OK with e.g. adding `cp ipa-client/ipa-getkeytab
/usr/sbin/ipa-getkeytab` to your testing workflow?

Absolutely not.

   Or should this be made configurable (or auto-detected)?

You must not break a machine just to do make test.

I often do make test, then make rpms and install rpms, I *never*
directly install on my development machine or VMs, I always go through
RPM in order to keep the system clean, and tests repeatable.

I do the same except I never run make test on the development machine --
without IPA installed the tests don't work.

ipa-getkeytab specifically do not need root to be tested so I really do
not see that copying over a system path would ever be a good idea.

Simo.


With this version of the patch, the tests use ipa-getkeytab from $PATH,
and the in-tree directory is added to PATH in make-test. Out-of-tree
tests don't use make-test so they will use the system PATH.
Is that OK?


Sounds good to me.

Simo.


Ping, could someone look at this patch?
It should fix 7 of the 11 failures that happen when running the test
suite out of tree.


Attaching a slightly updated version. Any takers?


--
PetrĀ³

From 154ddde3d3baf4cd106055beeca9bf72adc196b6 Mon Sep 17 00:00:00 2001
From: Petr Viktorin <pvikt...@redhat.com>
Date: Mon, 3 Jun 2013 15:04:58 +0200
Subject: [PATCH] Do not hardcode path to ipa-getkeytab in tests

Using the in-tree binary makes testing outside the source tree
impossible.
Use ipa-getkeytab from $PATH, and add the directory to $PATH when
running the in-tree tests.

Part of the work for https://fedorahosted.org/freeipa/ticket/3654
---
 ipatests/test_cmdline/cmdline.py           | 13 ++++++++++---
 ipatests/test_cmdline/test_ipagetkeytab.py |  2 +-
 make-test                                  |  3 +++
 3 files changed, 14 insertions(+), 4 deletions(-)

diff --git a/ipatests/test_cmdline/cmdline.py b/ipatests/test_cmdline/cmdline.py
index 6f3541d27081f2180f3f7b1da85d7bcd42eed353..0ef0137a67d9b51fa445b0b52b2c80a2a877dd08 100644
--- a/ipatests/test_cmdline/cmdline.py
+++ b/ipatests/test_cmdline/cmdline.py
@@ -23,12 +23,13 @@
 
 import nose
 import krbV
+import distutils.spawn
+import os
 
 from ipalib import api
 from ipalib import errors
 from ipatests.test_xmlrpc.xmlrpc_test import XMLRPC_test
 from ipaserver.plugins.ldap2 import ldap2
-from ipapython import ipautil
 
 # See if our LDAP server is up and we can talk to it over GSSAPI
 ccache = krbV.default_context().default_ccache()
@@ -51,11 +52,17 @@ class cmdline_test(XMLRPC_test):
     command = '/bin/ls'
 
     def setUp(self):
+        # Find the executable in $PATH
+        # This is neded because ipautil.run resets the PATH to
+        # a system default.
+        original_command = self.command
+        if not os.path.isabs(self.command):
+            self.command = distutils.spawn.find_executable(self.command)
         # raise an error if the command is missing even if the remote
         # server is not available.
-        if not ipautil.file_exists(self.command):
+        if not self.command:
             raise AssertionError(
-                'Command %r not available' % self.command
+                'Command %r not available' % original_command
             )
         super(cmdline_test, self).setUp()
         if not server_available:
diff --git a/ipatests/test_cmdline/test_ipagetkeytab.py b/ipatests/test_cmdline/test_ipagetkeytab.py
index cb46fd23bf320f59c30e53ceaa85d09aa7a3e2b4..ee2fdecf041c2af14c435db0f93493cd49a3999b 100644
--- a/ipatests/test_cmdline/test_ipagetkeytab.py
+++ b/ipatests/test_cmdline/test_ipagetkeytab.py
@@ -59,7 +59,7 @@ class test_ipagetkeytab(cmdline_test):
     """
     Test `ipa-getkeytab`.
     """
-    command = "ipa-client/ipa-getkeytab"
+    command = "ipa-getkeytab"
     host_fqdn = u'ipatest.%s' % api.env.domain
     service_princ = u'test/%s@%s' % (host_fqdn, api.env.realm)
     [keytabfd, keytabname] = tempfile.mkstemp()
diff --git a/make-test b/make-test
index 1cf5bb32975df76574726d5da4522517e5e12eed..2a48ab18181fe313b413b8c64f300533215380bc 100755
--- a/make-test
+++ b/make-test
@@ -29,6 +29,9 @@ cmd += sys.argv[1:]
 # This must be set so ipalib.api gets initialized property for tests:
 os.environ['IPA_UNIT_TEST_MODE'] = 'cli_test'
 
+# Add in-tree client binaries to PATH
+os.environ['PATH'] = './ipa-client:' + os.environ['PATH']
+
 if not path.isfile(nose):
     print 'ERROR: need %r' % nose
     sys.exit(100)
-- 
1.8.5.3

_______________________________________________
Freeipa-devel mailing list
Freeipa-devel@redhat.com
https://www.redhat.com/mailman/listinfo/freeipa-devel

Reply via email to