From c46ca62627d3a6ccd431f58bdb9d4f76694db9f9 Mon Sep 17 00:00:00 2001 From: Adrian Likins Date: Fri, 31 Oct 2008 12:39:38 -0400 Subject: Fix a bug with "func-transmit --yaml" send bools as strings and causing weird things to happen to async. Add a "smart_bool" method to client.py that will take the string and/or bool it gets and make a bool of it. test_func_transmit.py: add option to specify async/nfork params for the non async test calls for testing add a couple test cases that call methods with "async=True, nforks=1" to make sure they do the right thing --- test/unittest/test_func_transmit.py | 48 +++++++++++++++++++++++++++++++++---- 1 file changed, 43 insertions(+), 5 deletions(-) (limited to 'test') 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 + + -- cgit