summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xfunc/overlord/client.py15
-rw-r--r--test/unittest/test_func_transmit.py48
2 files changed, 57 insertions, 6 deletions
diff --git a/func/overlord/client.py b/func/overlord/client.py
index 12b4c61..b0ca7df 100755
--- a/func/overlord/client.py
+++ b/func/overlord/client.py
@@ -154,6 +154,16 @@ def is_minion(minion_string):
return minions.is_minion()
+
+# from a comment at http://codecomments.wordpress.com/2008/04/08/converting-a-string-to-a-boolean-value-in-python/
+# basically excepy a string or a bool for the async arg, since func-transmit can be a bit weird about it especially
+# if we are using an older version of yaml (and we are...)
+def smart_bool(s):
+ if s is True or s is False:
+ return s
+ s = str(s).strip().lower()
+ return not s in ['false','f','n','0','']
+
class Overlord(object):
def __init__(self, server_spec, port=DEFAULT_PORT, interactive=False,
@@ -178,10 +188,12 @@ class Overlord(object):
self.interactive = interactive
self.noglobs = noglobs
self.nforks = nforks
- self.async = async
+ self.async = smart_bool(async)
+ #self.async = async
self.delegate = delegate
self.mapfile = mapfile
+
self.minions_class = Minions(self.server_spec, port=self.port, noglobs=self.noglobs,verbose=self.verbose)
self.minions = self.minions_class.get_urls()
if len(self.minions) == 0:
@@ -377,6 +389,7 @@ class Overlord(object):
minionurls = []
use_delegate = False
delegation_path = []
+
def process_server(bucketnumber, buckets, server):
diff --git a/test/unittest/test_func_transmit.py b/test/unittest/test_func_transmit.py
index 90fe598..004d9f1 100644
--- a/test/unittest/test_func_transmit.py
+++ b/test/unittest/test_func_transmit.py
@@ -12,13 +12,17 @@
import os
import socket
import subprocess
+import sys
import time
import unittest
import simplejson
import func.utils
+
+
from func import yaml
+
from func import jobthing
@@ -56,7 +60,7 @@ class BaseTest(object):
def _call_async(self, data):
data['async'] = True
- data['nforks'] = 4
+ data['nforks'] = self.nforks
job_id = self._call(data)
@@ -74,12 +78,17 @@ class BaseTest(object):
return result
def _call(self, data):
+ data['async'] = self.async
+ data['nforks'] = self.nforks
+
+
f = self._serialize(data)
p = subprocess.Popen(self.ft_cmd, shell=True,
stdin=subprocess.PIPE, stdout=subprocess.PIPE)
output = p.communicate(input=f)
- return self._deserialize(output[0])
+ ret = self._deserialize(output[0])
+ return ret
def call(self, data):
if self.async:
@@ -242,7 +251,7 @@ class TestClientGlobJSONAsync(JSONBaseTest, ClientGlobAsync):
# respect the __test__ attribute, and these modules aren't meant to be
# invoked as test classes themselves, only as bases for other tests
class T_estTest(object):
- __test__ = False
+# __test__ = False
def _echo_test(self, data):
result = self.call({'clients':'*',
@@ -262,6 +271,12 @@ class T_estTest(object):
assert result[self.th] == 3
+ def test_command_run(self):
+ result = self.call({'clients':'*',
+ 'method':'run',
+ 'module': 'command',
+ 'parameters': ['/sbin/ifconfig']})
+
def test_echo_int(self):
self._echo_test(37)
@@ -297,12 +312,27 @@ class T_estTestAsync(T_estTest):
__test__ = False
async = True
-class TestTestYaml(YamlBaseTest, T_estTest):
+class T_estTestCommandRun(T_estTest):
+ async = False
+ def test_command_run(self):
+ result = self.call({'clients':'*',
+# 'async': False,
+# 'nforks': 1,
+ 'method': 'run',
+ 'module': 'command',
+ 'parameters': 'ifconfig'})
+
+
+class TestTestYamlCommandRun(YamlBaseTest, T_estTestCommandRun):
yaml = True
def __init__(self):
super(YamlBaseTest, self).__init__()
-
+
+class TestTestYaml(YamlBaseTest, T_estTest):
+ yaml = True
+ def __init__(self):
+ super(YamlBaseTest, self).__init__()
class TestTestJSON(JSONBaseTest, T_estTest):
json = True
@@ -320,3 +350,11 @@ class TestTestAsyncYaml(YamlBaseTest, T_estTestAsync):
async = True
def __init__(self):
super(YamlBaseTest,self).__init__()
+
+# we had a bug where setting nforks or async at all
+# was causing stuff to fail, so heres the test case
+class TestTestYamlNforksOne(TestTestYaml):
+ nforks = 1
+ async = False
+
+