diff options
author | Aldur <adrianodl@hotmail.it> | 2014-09-19 13:07:55 +0200 |
---|---|---|
committer | Aldur <adrianodl@hotmail.it> | 2014-09-23 11:44:56 +0200 |
commit | ee01a0f76392eb89d0e3e10384687dbaf6e1b4d6 (patch) | |
tree | 5be5f770f07a2f48b001b7991df2e5a596390660 /t | |
parent | d8fb5a9a3bcd0908d5172de7460c29b3806611f3 (diff) | |
download | uwsgi-ee01a0f76392eb89d0e3e10384687dbaf6e1b4d6.tar.gz |
add spooler_decorator tests
Diffstat (limited to 't')
-rw-r--r-- | t/python/spooler_decorators/spooler_decorator_test.ini | 17 | ||||
-rw-r--r-- | t/python/spooler_decorators/spooler_decorator_tests.py | 31 | ||||
-rw-r--r-- | t/python/spooler_decorators/spooler_handlers.py | 23 |
3 files changed, 71 insertions, 0 deletions
diff --git a/t/python/spooler_decorators/spooler_decorator_test.ini b/t/python/spooler_decorators/spooler_decorator_test.ini new file mode 100644 index 00000000..795286fc --- /dev/null +++ b/t/python/spooler_decorators/spooler_decorator_test.ini @@ -0,0 +1,17 @@ +[uwsgi] +socket = /tmp/temporary-socket + +; Spooler! +spooler-import = %d/spooler_handlers.py +; Specify the spooler +spooler = $(SPOOLER_DIR) +; And the number of processes +spooler-processes = 1 +; Spooler ordered scanning (only works with "numbered" dirs) +spooler-ordered = 1 + +spooler-frequency = 1 + +pyrun = %d/spooler_decorator_tests.py +master = 1 + diff --git a/t/python/spooler_decorators/spooler_decorator_tests.py b/t/python/spooler_decorators/spooler_decorator_tests.py new file mode 100644 index 00000000..ec72e399 --- /dev/null +++ b/t/python/spooler_decorators/spooler_decorator_tests.py @@ -0,0 +1,31 @@ +# run it with: +# export SPOOLER_DIR=t/python/spooler_priority/temporary_spooler; # or your spooler dir +# ./uwsgi t/python/spooler_decorators/spooler_decorator_test.ini + +import unittest +import uwsgi +import spooler_handlers +from os import remove, path + + +class BitmapTest(unittest.TestCase): + + def setUp(self): + try: + remove(spooler_handlers.ghostpath) + except OSError: # file does not exist + pass + + spooler_handlers.controlled_task.spool(arg='alive', ghost='world') + spooler_handlers.controlled_task.spool(arg='barbis') + spooler_handlers.controlled_raw_task.spool(arg='alive', ghost='world') + spooler_handlers.controlled_raw_task.spool(arg='barbis') + + for i in range(4): + uwsgi.signal_wait(20) + print("Signal received!") + + def test_spooler(self): + self.assertFalse(path.exists(spooler_handlers.ghostpath)) + +unittest.main() diff --git a/t/python/spooler_decorators/spooler_handlers.py b/t/python/spooler_decorators/spooler_handlers.py new file mode 100644 index 00000000..5298f91c --- /dev/null +++ b/t/python/spooler_decorators/spooler_handlers.py @@ -0,0 +1,23 @@ +# See spooler_decorator_tests + +from uwsgidecorators import * +import uwsgi + +ghostpath = "/tmp/ghost" + + +@spool +def controlled_task(arguments): + if arguments['arg'] != 'alive' and 'ghost' in arguments: + print("We have a problem!") + open(ghostpath, 'w').close() + uwsgi.signal(20) + + +@spoolraw +def controlled_raw_task(arguments): + if arguments['arg'] != 'alive' and 'ghost' in arguments: + print("We have a problem!") + open(ghostpath, 'w').close() + uwsgi.signal(20) + return uwsgi.SPOOL_OK |