Factor wrapper, add sleep in it

parent 62875167
...@@ -13,6 +13,14 @@ import unittest ...@@ -13,6 +13,14 @@ import unittest
import urlparse import urlparse
import xml_marshaller import xml_marshaller
WRAPPER_CONTENT = """#!/bin/sh
touch worked &&
mkdir -p etc/run &&
echo "#!/bin/sh" > etc/run/wrapper &&
echo "while :; do echo "Working\\nWorking\\n" ; sleep 0.1; done" >> etc/run/wrapper &&
chmod 755 etc/run/wrapper
"""
class BasicMixin: class BasicMixin:
def assertSortedListEqual(self, list1, list2, msg=None): def assertSortedListEqual(self, list1, list2, msg=None):
self.assertListEqual(sorted(list1), sorted(list2), msg) self.assertListEqual(sorted(list1), sorted(list2), msg)
...@@ -274,13 +282,7 @@ touch worked""") ...@@ -274,13 +282,7 @@ touch worked""")
"""[buildout]""") """[buildout]""")
srbindir = os.path.join(srdir, 'bin') srbindir = os.path.join(srdir, 'bin')
os.mkdir(srbindir) os.mkdir(srbindir)
open(os.path.join(srbindir, 'buildout'), 'w').write("""#!/bin/sh open(os.path.join(srbindir, 'buildout'), 'w').write(WRAPPER_CONTENT)
touch worked &&
mkdir -p etc/run &&
echo "#!/bin/sh" > etc/run/wrapper &&
echo "while :; do echo "Working\\nWorking\\n" ; done" >> etc/run/wrapper &&
chmod 755 etc/run/wrapper
""")
os.chmod(os.path.join(srbindir, 'buildout'), 0755) os.chmod(os.path.join(srbindir, 'buildout'), 0755)
self.assertTrue(self.grid.processComputerPartitionList()) self.assertTrue(self.grid.processComputerPartitionList())
self.assertSortedListEqual(os.listdir(self.instance_root), ['0', 'etc', self.assertSortedListEqual(os.listdir(self.instance_root), ['0', 'etc',
...@@ -400,13 +402,7 @@ chmod 755 etc/run/wrapper ...@@ -400,13 +402,7 @@ chmod 755 etc/run/wrapper
"""[buildout]""") """[buildout]""")
srbindir = os.path.join(srdir, 'bin') srbindir = os.path.join(srdir, 'bin')
os.mkdir(srbindir) os.mkdir(srbindir)
open(os.path.join(srbindir, 'buildout'), 'w').write("""#!/bin/sh open(os.path.join(srbindir, 'buildout'), 'w').write(WRAPPER_CONTENT)
touch worked &&
mkdir -p etc/run &&
echo "#!/bin/sh" > etc/run/wrapper &&
echo "while :; do echo "Working\\nWorking\\n" ; done" >> etc/run/wrapper &&
chmod 755 etc/run/wrapper
""")
os.chmod(os.path.join(srbindir, 'buildout'), 0755) os.chmod(os.path.join(srbindir, 'buildout'), 0755)
self.assertTrue(self.grid.processComputerPartitionList()) self.assertTrue(self.grid.processComputerPartitionList())
self.assertSortedListEqual(os.listdir(self.instance_root), ['0', 'etc', self.assertSortedListEqual(os.listdir(self.instance_root), ['0', 'etc',
...@@ -682,13 +678,7 @@ class TestSlapgridUsageReport(MasterMixin, unittest.TestCase): ...@@ -682,13 +678,7 @@ class TestSlapgridUsageReport(MasterMixin, unittest.TestCase):
self.sequence = [] self.sequence = []
self.started = False self.started = False
httplib.HTTPConnection._callback = _server_response(self, 'started') httplib.HTTPConnection._callback = _server_response(self, 'started')
open(os.path.join(srbindir, 'buildout'), 'w').write("""#!/bin/sh open(os.path.join(srbindir, 'buildout'), 'w').write(WRAPPER_CONTENT)
touch worked &&
mkdir -p etc/run &&
echo "#!/bin/sh" > etc/run/wrapper &&
echo "while :; do echo "Working\\nWorking\\n" ; done" >> etc/run/wrapper &&
chmod 755 etc/run/wrapper
""")
os.chmod(os.path.join(srbindir, 'buildout'), 0755) os.chmod(os.path.join(srbindir, 'buildout'), 0755)
self.assertTrue(self.grid.processComputerPartitionList()) self.assertTrue(self.grid.processComputerPartitionList())
self.assertSortedListEqual(os.listdir(self.instance_root), ['0', 'etc', self.assertSortedListEqual(os.listdir(self.instance_root), ['0', 'etc',
...@@ -759,13 +749,7 @@ chmod 755 etc/run/wrapper ...@@ -759,13 +749,7 @@ chmod 755 etc/run/wrapper
self.sequence = [] self.sequence = []
self.started = False self.started = False
httplib.HTTPConnection._callback = _server_response(self, 'started') httplib.HTTPConnection._callback = _server_response(self, 'started')
open(os.path.join(srbindir, 'buildout'), 'w').write("""#!/bin/sh open(os.path.join(srbindir, 'buildout'), 'w').write(WRAPPER_CONTENT)
touch worked &&
mkdir -p etc/run &&
echo "#!/bin/sh" > etc/run/wrapper &&
echo "while :; do echo "Working\\nWorking\\n" ; sleep 0.1; done" >> etc/run/wrapper &&
chmod 755 etc/run/wrapper
""")
os.chmod(os.path.join(srbindir, 'buildout'), 0755) os.chmod(os.path.join(srbindir, 'buildout'), 0755)
self.assertTrue(self.grid.processComputerPartitionList()) self.assertTrue(self.grid.processComputerPartitionList())
self.assertSortedListEqual(os.listdir(self.instance_root), ['0', 'etc', self.assertSortedListEqual(os.listdir(self.instance_root), ['0', 'etc',
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment