Re: [Freeipa-devel] [PATCH] 0032 Move DNS test skipping to class setup

2012-04-02 Thread Rob Crittenden

Petr Viktorin wrote:

On 03/29/2012 10:18 PM, Rob Crittenden wrote:

Petr Viktorin wrote:


Currently, each DNS test case first checks if DNS is configured
by creating and deleting a test zone. This takes quite a lot of time.

This patch moves the check to the setUpClass method, so the check is
only done once for all the tests.



On my VM, this makes the DNS plugin tests 50% faster, saving about half
a minute for each test run.



This fails if the test XML-RPC server is not running. While working on
that issue I found a few other places that weren't handling this as
well. Here is my working patch on top of yours.

rob


Thank you! I see the other place is one I added recently.

This updated patch includes your diff, and also makes sure a context is
created for the DNS test skipping.




ACK, pushed to master and ipa-2-2

rob

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


Re: [Freeipa-devel] [PATCH] 0032 Move DNS test skipping to class setup

2012-03-30 Thread Petr Viktorin

On 03/29/2012 10:18 PM, Rob Crittenden wrote:

Petr Viktorin wrote:


Currently, each DNS test case first checks if DNS is configured
by creating and deleting a test zone. This takes quite a lot of time.

This patch moves the check to the setUpClass method, so the check is
only done once for all the tests.



On my VM, this makes the DNS plugin tests 50% faster, saving about half
a minute for each test run.



This fails if the test XML-RPC server is not running. While working on
that issue I found a few other places that weren't handling this as
well. Here is my working patch on top of yours.

rob


Thank you! I see the other place is one I added recently.

This updated patch includes your diff, and also makes sure a context is 
created for the DNS test skipping.



--
PetrĀ³
From 06035ac4174065cdd8c2b533a59918a1c32ac494 Mon Sep 17 00:00:00 2001
From: Petr Viktorin pvikt...@redhat.com
Date: Wed, 28 Mar 2012 04:42:23 -0400
Subject: [PATCH] Move test skipping to class setup

Currently, each DNS test case first checks if DNS is configured
by creating and deleting a test zone. This takes quite a lot of time.

This patch moves the check to the setUpClass method, so the check is
only done once for all the tests.

Similarly, if the server is not available, entire XMLRPC test classes
are now skipped.

Additionally, CLItests that hit the server are skipped if the server
isn't available.
---
 tests/test_cmdline/test_cli.py   |6 +-
 tests/test_xmlrpc/test_dns_plugin.py |8 ++--
 tests/test_xmlrpc/xmlrpc_test.py |   10 ++
 3 files changed, 17 insertions(+), 7 deletions(-)

diff --git a/tests/test_cmdline/test_cli.py b/tests/test_cmdline/test_cli.py
index 889aae4130cba4d728b1b461719767f2db9a73cb..46b33d548f07b930665ae596c69246fb478202a4 100644
--- a/tests/test_cmdline/test_cli.py
+++ b/tests/test_cmdline/test_cli.py
@@ -26,7 +26,11 @@ def run_command(self, command_name, **kw):
 Run a command on the server
 if not api.Backend.xmlclient.isconnected():
 api.Backend.xmlclient.connect(fallback=False)
-api.Command[command_name](**kw)
+try:
+api.Command[command_name](**kw)
+except errors.NetworkError:
+raise nose.SkipTest('%r: Server not available: %r' %
+(self.__module__, api.env.xmlrpc_uri))
 
 @contextlib.contextmanager
 def fake_stdin(self, string_in):
diff --git a/tests/test_xmlrpc/test_dns_plugin.py b/tests/test_xmlrpc/test_dns_plugin.py
index 1e5ab7917f47b713f226764885035ff6b4ac90cd..96639453228984cca9277facc0e88775daa1af7c 100644
--- a/tests/test_xmlrpc/test_dns_plugin.py
+++ b/tests/test_xmlrpc/test_dns_plugin.py
@@ -47,8 +47,12 @@
 
 class test_dns(Declarative):
 
-def setUp(self):
-super(test_dns, self).setUp()
+@classmethod
+def setUpClass(cls):
+super(test_dns, cls).setUpClass()
+
+if not api.Backend.xmlclient.isconnected():
+api.Backend.xmlclient.connect(fallback=False)
 try:
api.Command['dnszone_add'](dnszone1,
idnssoamname = dnszone1_mname,
diff --git a/tests/test_xmlrpc/xmlrpc_test.py b/tests/test_xmlrpc/xmlrpc_test.py
index a7cfb11b8cb5e4438764bcd26aceacec5ac00c88..28f5fac7be7334cfc8735d891979f63943ca7e67 100644
--- a/tests/test_xmlrpc/xmlrpc_test.py
+++ b/tests/test_xmlrpc/xmlrpc_test.py
@@ -122,11 +122,13 @@ class XMLRPC_test(object):
 Base class for all XML-RPC plugin tests
 
 
-def setUp(self):
+@classmethod
+def setUpClass(cls):
 if not server_available:
-raise nose.SkipTest(
-'Server not available: %r' % api.env.xmlrpc_uri
-)
+raise nose.SkipTest('%r: Server not available: %r' %
+(cls.__module__, api.env.xmlrpc_uri))
+
+def setUp(self):
 if not api.Backend.xmlclient.isconnected():
 api.Backend.xmlclient.connect(fallback=False)
 
-- 
1.7.7.6

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

Re: [Freeipa-devel] [PATCH] 0032 Move DNS test skipping to class setup

2012-03-29 Thread Rob Crittenden

Petr Viktorin wrote:


Currently, each DNS test case first checks if DNS is configured
by creating and deleting a test zone. This takes quite a lot of time.

This patch moves the check to the setUpClass method, so the check is
only done once for all the tests.



On my VM, this makes the DNS plugin tests 50% faster, saving about half
a minute for each test run.



This fails if the test XML-RPC server is not running. While working on 
that issue I found a few other places that weren't handling this as 
well. Here is my working patch on top of yours.


rob

diff --git a/tests/test_cmdline/test_cli.py b/tests/test_cmdline/test_cli.py
index 889aae4..7e40cf0 100644
--- a/tests/test_cmdline/test_cli.py
+++ b/tests/test_cmdline/test_cli.py
@@ -26,7 +26,11 @@ class TestCLIParsing(object):
 Run a command on the server
 if not api.Backend.xmlclient.isconnected():
 api.Backend.xmlclient.connect(fallback=False)
-api.Command[command_name](**kw)
+try:
+api.Command[command_name](**kw)
+except errors.NetworkError:
+raise nose.SkipTest(
+'%r: Server not available: %r' % (self.__module__, 
api.env.xmlr

pc_uri))

 @contextlib.contextmanager
 def fake_stdin(self, string_in):
diff --git a/tests/test_xmlrpc/test_dns_plugin.py 
b/tests/test_xmlrpc/test_dns_p

lugin.py
index 911c773..2d7a6ea 100644
--- a/tests/test_xmlrpc/test_dns_plugin.py
+++ b/tests/test_xmlrpc/test_dns_plugin.py
@@ -49,6 +49,10 @@ class test_dns(Declarative):

 @classmethod
 def setUpClass(cls):
+if not api.Backend.xmlclient.isconnected():
+raise nose.SkipTest(
+'%r: Server not available: %r' % (cls.__module__, 
api.env.xmlrp

c_uri))
+
 try:
api.Command['dnszone_add'](dnszone1,
idnssoamname = dnszone1_mname,
diff --git a/tests/test_xmlrpc/xmlrpc_test.py 
b/tests/test_xmlrpc/xmlrpc_test.py

index a7cfb11..c0a43ff 100644
--- a/tests/test_xmlrpc/xmlrpc_test.py
+++ b/tests/test_xmlrpc/xmlrpc_test.py
@@ -130,6 +130,13 @@ class XMLRPC_test(object):
 if not api.Backend.xmlclient.isconnected():
 api.Backend.xmlclient.connect(fallback=False)

+@classmethod
+def setUpClass(cls):
+if not server_available:
+raise nose.SkipTest(
+'%r: Server not available: %r' % (cls.__module__, 
api.env.xmlrp

c_uri)
+)
+
 def tearDown(self):
 
 nose tear-down fixture.

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


[Freeipa-devel] [PATCH] 0032 Move DNS test skipping to class setup

2012-03-28 Thread Petr Viktorin


Currently, each DNS test case first checks if DNS is configured
by creating and deleting a test zone. This takes quite a lot of time.

This patch moves the check to the setUpClass method, so the check is
only done once for all the tests.



On my VM, this makes the DNS plugin tests 50% faster, saving about half 
a minute for each test run.


--
PetrĀ³
From a9098f77bf89d1f44ea9ec335e55f05f086e373b Mon Sep 17 00:00:00 2001
From: Petr Viktorin pvikt...@redhat.com
Date: Wed, 28 Mar 2012 04:42:23 -0400
Subject: [PATCH] Move DNS test skipping to class setup

Currently, each DNS test case first checks if DNS is configured
by creating and deleting a test zone. This takes quite a lot of time.

This patch moves the check to the setUpClass method, so the check is
only done once for all the tests.
---
 tests/test_xmlrpc/test_dns_plugin.py |4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/tests/test_xmlrpc/test_dns_plugin.py b/tests/test_xmlrpc/test_dns_plugin.py
index 1e5ab7917f47b713f226764885035ff6b4ac90cd..911c77371950df863d797f4f01efd4bd46084797 100644
--- a/tests/test_xmlrpc/test_dns_plugin.py
+++ b/tests/test_xmlrpc/test_dns_plugin.py
@@ -47,8 +47,8 @@
 
 class test_dns(Declarative):
 
-def setUp(self):
-super(test_dns, self).setUp()
+@classmethod
+def setUpClass(cls):
 try:
api.Command['dnszone_add'](dnszone1,
idnssoamname = dnszone1_mname,
-- 
1.7.7.6

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