From 75c7f97f2f8060557f6e7ed660a0a9247c9a5cda Mon Sep 17 00:00:00 2001
From: Priscila Manhaes <psilva@iff.edu.br>
Date: Thu, 25 Aug 2011 17:41:56 -0300
Subject: [PATCH] Refactor cause tests needs cloudooo started

---
 slapos/recipe/cloudooo/__init__.py         |  3 ++-
 slapos/recipe/cloudoootestnode/testnode.py | 24 +++++++++++++++++++++-
 2 files changed, 25 insertions(+), 2 deletions(-)

diff --git a/slapos/recipe/cloudooo/__init__.py b/slapos/recipe/cloudooo/__init__.py
index f40e24268..a89e0ca29 100755
--- a/slapos/recipe/cloudooo/__init__.py
+++ b/slapos/recipe/cloudooo/__init__.py
@@ -186,7 +186,8 @@ class Recipe(BaseSlapRecipe):
         email_address=ca_email,
     )
     self._writeFile(openssl_configuration,
-        self.getTemplateFilename('openssl.cnf.ca.in'))
+        self.substituteTemplate(self.getTemplateFilename('openssl.cnf.ca.in'),
+          config))
     self.path_list.extend(zc.buildout.easy_install.scripts([
       ('certificate_authority',
         'slapos.recipe.erp5.certificate_authority',
diff --git a/slapos/recipe/cloudoootestnode/testnode.py b/slapos/recipe/cloudoootestnode/testnode.py
index 6d75dec7c..cc7f97837 100755
--- a/slapos/recipe/cloudoootestnode/testnode.py
+++ b/slapos/recipe/cloudoootestnode/testnode.py
@@ -1,5 +1,5 @@
 from xml_marshaller import xml_marshaller
-import os, xmlrpclib, time, imp
+import os, xmlrpclib, time, imp, re
 from glob import glob
 import signal
 import slapos.slap
@@ -218,6 +218,28 @@ branch = %(branch)s
           process_group_pid_set.add(run_test_suite.pid)
           run_test_suite.wait()
           process_group_pid_set.remove(run_test_suite.pid)
+          while wait_serve:
+            try:
+              conf = open(cloudooo_conf).read()
+              host, port = re.findall('host=*.*.*.*\nport\ \=.*', conf)[0].split('\n')
+              serve = xmlrpclib.Server("http://%s:%s/RPC2" % 
+                        (host.split('=')[-1].lstrip(), 
+                        port.split('=')[-1].lstrip()))
+              serve.system.listMethods()
+              if len(serve.system.listMethods()) > 0:
+                wait_serve = False
+            except socket.error, e:
+              wait_serve = True
+              time.sleep(10)
+          for test in cloudooo_tests:
+            print time.strftime("%a, %d %b %Y %H:%M:%S +0000", time.gmtime())
+            invocation_list = []
+            if line[:2] == '#!':
+              invocation_list = line[2:].split()
+            invocation_list.extend([run_test_suite_path,
+                                    '--paster_path', cloudooo_paster,
+                                    cloudooo_conf,
+                                    test.split('/')[-1]])
       except SubprocessError:
         time.sleep(120)
         continue
-- 
2.30.9