Be more friendly with supervisor

parent 3801d868
...@@ -494,13 +494,13 @@ class TestSlapgridCPWithMaster(MasterMixin, unittest.TestCase): ...@@ -494,13 +494,13 @@ class TestSlapgridCPWithMaster(MasterMixin, unittest.TestCase):
'var']) 'var'])
self.assertSortedListEqual(os.listdir(partition.partition_path), self.assertSortedListEqual(os.listdir(partition.partition_path),
['.0_wrapper.log','worked', 'buildout.cfg', 'etc']) ['.0_wrapper.log','worked', 'buildout.cfg', 'etc'])
tries = 10 tries = 50
wrapper_log = os.path.join(partition.partition_path, '.0_wrapper.log') wrapper_log = os.path.join(partition.partition_path, '.0_wrapper.log')
while tries > 0: while tries > 0:
tries -= 1 tries -= 1
if os.path.getsize(wrapper_log) > 0: if os.path.getsize(wrapper_log) > 0:
break break
time.sleep(0.2) time.sleep(0.1)
self.assertTrue('Working' in open(wrapper_log, 'r').read()) self.assertTrue('Working' in open(wrapper_log, 'r').read())
self.assertSortedListEqual(os.listdir(self.software_root), self.assertSortedListEqual(os.listdir(self.software_root),
[partition.software.software_hash]) [partition.software.software_hash])
...@@ -539,12 +539,12 @@ chmod 755 etc/run/wrapper ...@@ -539,12 +539,12 @@ chmod 755 etc/run/wrapper
self.assertSortedListEqual(os.listdir(instance.partition_path), ['.0_wrapper.log', self.assertSortedListEqual(os.listdir(instance.partition_path), ['.0_wrapper.log',
'worked', 'buildout.cfg', 'etc']) 'worked', 'buildout.cfg', 'etc'])
wrapper_log = os.path.join(instance.partition_path, '.0_wrapper.log') wrapper_log = os.path.join(instance.partition_path, '.0_wrapper.log')
tries = 10 tries = 50
while tries > 0: while tries > 0:
tries -= 1 tries -= 1
if os.path.getsize(wrapper_log) > 0: if os.path.getsize(wrapper_log) > 0:
break break
time.sleep(0.2) time.sleep(0.1)
os.path.getsize(wrapper_log) os.path.getsize(wrapper_log)
self.assertTrue('Working' in open(wrapper_log, 'r').read()) self.assertTrue('Working' in open(wrapper_log, 'r').read())
self.assertSortedListEqual(os.listdir(self.software_root), self.assertSortedListEqual(os.listdir(self.software_root),
...@@ -562,14 +562,14 @@ chmod 755 etc/run/wrapper ...@@ -562,14 +562,14 @@ chmod 755 etc/run/wrapper
self.assertSortedListEqual( self.assertSortedListEqual(
os.listdir(instance.partition_path), os.listdir(instance.partition_path),
['.0_wrapper.log', '.0_wrapper.log.1', 'worked', 'buildout.cfg', 'etc']) ['.0_wrapper.log', '.0_wrapper.log.1', 'worked', 'buildout.cfg', 'etc'])
tries = 10 tries = 50
expected_text = 'Signal handler called with signal 15' expected_text = 'Signal handler called with signal 15'
while tries > 0: while tries > 0:
tries -= 1 tries -= 1
found = expected_text in open(wrapper_log, 'r').read() found = expected_text in open(wrapper_log, 'r').read()
if found: if found:
break break
time.sleep(0.2) time.sleep(0.1)
self.assertTrue(found) self.assertTrue(found)
self.assertEqual(computer.sequence, self.assertEqual(computer.sequence,
['getFullComputerInformation', 'availableComputerPartition', ['getFullComputerInformation', 'availableComputerPartition',
...@@ -606,13 +606,13 @@ chmod 755 etc/run/wrapper ...@@ -606,13 +606,13 @@ chmod 755 etc/run/wrapper
'worked', 'etc', 'buildout.cfg']) 'worked', 'etc', 'buildout.cfg'])
self.assertSortedListEqual(os.listdir(self.software_root), self.assertSortedListEqual(os.listdir(self.software_root),
[instance.software.software_hash]) [instance.software.software_hash])
tries = 10 tries = 50
wrapper_log = os.path.join(instance.partition_path, '.0_wrapper.log') wrapper_log = os.path.join(instance.partition_path, '.0_wrapper.log')
while tries > 0: while tries > 0:
tries -= 1 tries -= 1
if os.path.getsize(wrapper_log) > 0: if os.path.getsize(wrapper_log) > 0:
break break
time.sleep(0.2) time.sleep(0.1)
self.assertTrue('Working' in open(wrapper_log, 'r').read()) self.assertTrue('Working' in open(wrapper_log, 'r').read())
self.assertEqual(computer.sequence, self.assertEqual(computer.sequence,
['getFullComputerInformation', 'availableComputerPartition', ['getFullComputerInformation', 'availableComputerPartition',
...@@ -680,20 +680,20 @@ class TestSlapgridCPWithMasterWatchdog(MasterMixin, unittest.TestCase): ...@@ -680,20 +680,20 @@ class TestSlapgridCPWithMasterWatchdog(MasterMixin, unittest.TestCase):
'var']) 'var'])
self.assertSortedListEqual(os.listdir(partition.partition_path), self.assertSortedListEqual(os.listdir(partition.partition_path),
['.0_daemon.log','worked', 'buildout.cfg', 'etc']) ['.0_daemon.log','worked', 'buildout.cfg', 'etc'])
tries = 10 tries = 50
daemon_log = os.path.join(partition.partition_path, '.0_daemon.log') daemon_log = os.path.join(partition.partition_path, '.0_daemon.log')
while tries > 0: while tries > 0:
tries -= 1 tries -= 1
if os.path.getsize(daemon_log) > 0: if os.path.getsize(daemon_log) > 0:
break break
time.sleep(0.2) time.sleep(0.1)
self.assertTrue('Failing' in open(daemon_log, 'r').read()) self.assertTrue('Failing' in open(daemon_log, 'r').read())
tries = 25 tries = 25
while tries > 0: while tries > 0:
tries -= 1 tries -= 1
if os.path.exists(watchdog_banged): if os.path.exists(watchdog_banged):
break break
time.sleep(0.2) time.sleep(0.1)
self.assertTrue(os.path.exists(watchdog_banged)) self.assertTrue(os.path.exists(watchdog_banged))
self.assertTrue('daemon' in open(watchdog_banged,'r').read()) self.assertTrue('daemon' in open(watchdog_banged,'r').read())
...@@ -737,20 +737,20 @@ touch worked ...@@ -737,20 +737,20 @@ touch worked
'var']) 'var'])
self.assertSortedListEqual(os.listdir(partition.partition_path), self.assertSortedListEqual(os.listdir(partition.partition_path),
['.0_daemon.log','worked', 'buildout.cfg', 'etc']) ['.0_daemon.log','worked', 'buildout.cfg', 'etc'])
tries = 10 tries = 50
daemon_log = os.path.join(partition.partition_path, '.0_daemon.log') daemon_log = os.path.join(partition.partition_path, '.0_daemon.log')
while tries > 0: while tries > 0:
tries -= 1 tries -= 1
if os.path.getsize(daemon_log) > 0: if os.path.getsize(daemon_log) > 0:
break break
time.sleep(0.2) time.sleep(0.1)
self.assertTrue('Failing' in open(daemon_log, 'r').read()) self.assertTrue('Failing' in open(daemon_log, 'r').read())
tries = 25 tries = 25
while tries > 0: while tries > 0:
tries -= 1 tries -= 1
if os.path.exists(watchdog_banged): if os.path.exists(watchdog_banged):
break break
time.sleep(0.2) time.sleep(0.1)
self.assertFalse(os.path.exists(watchdog_banged)) self.assertFalse(os.path.exists(watchdog_banged))
...@@ -1111,13 +1111,13 @@ class TestSlapgridUsageReport(MasterMixin, unittest.TestCase): ...@@ -1111,13 +1111,13 @@ class TestSlapgridUsageReport(MasterMixin, unittest.TestCase):
'var']) 'var'])
self.assertSortedListEqual(os.listdir(instance.partition_path), ['.0_wrapper.log', self.assertSortedListEqual(os.listdir(instance.partition_path), ['.0_wrapper.log',
'worked', 'buildout.cfg', 'etc']) 'worked', 'buildout.cfg', 'etc'])
tries = 10 tries = 50
wrapper_log = os.path.join(instance.partition_path, '.0_wrapper.log') wrapper_log = os.path.join(instance.partition_path, '.0_wrapper.log')
while tries > 0: while tries > 0:
tries -= 1 tries -= 1
if os.path.getsize(wrapper_log) > 0: if os.path.getsize(wrapper_log) > 0:
break break
time.sleep(0.2) time.sleep(0.1)
self.assertTrue('Working' in open(wrapper_log, 'r').read()) self.assertTrue('Working' in open(wrapper_log, 'r').read())
self.assertSortedListEqual(os.listdir(self.software_root), self.assertSortedListEqual(os.listdir(self.software_root),
[instance.software.software_hash]) [instance.software.software_hash])
...@@ -1138,7 +1138,7 @@ class TestSlapgridUsageReport(MasterMixin, unittest.TestCase): ...@@ -1138,7 +1138,7 @@ class TestSlapgridUsageReport(MasterMixin, unittest.TestCase):
self.assertSortedListEqual(os.listdir(self.software_root), self.assertSortedListEqual(os.listdir(self.software_root),
[instance.software.software_hash]) [instance.software.software_hash])
# Assert supervisor stopped process # Assert supervisor stopped process
tries = 10 tries = 50
wrapper_log = os.path.join(instance.partition_path, '.0_wrapper.log') wrapper_log = os.path.join(instance.partition_path, '.0_wrapper.log')
exists = False exists = False
while tries > 0: while tries > 0:
...@@ -1146,7 +1146,7 @@ class TestSlapgridUsageReport(MasterMixin, unittest.TestCase): ...@@ -1146,7 +1146,7 @@ class TestSlapgridUsageReport(MasterMixin, unittest.TestCase):
if os.path.exists(wrapper_log): if os.path.exists(wrapper_log):
exists = True exists = True
break break
time.sleep(0.2) time.sleep(0.1)
self.assertFalse(exists) self.assertFalse(exists)
self.assertEqual(computer.sequence, self.assertEqual(computer.sequence,
...@@ -1174,7 +1174,7 @@ class TestSlapgridUsageReport(MasterMixin, unittest.TestCase): ...@@ -1174,7 +1174,7 @@ class TestSlapgridUsageReport(MasterMixin, unittest.TestCase):
tries -= 1 tries -= 1
if os.path.getsize(wrapper_log) > 0: if os.path.getsize(wrapper_log) > 0:
break break
time.sleep(0.2) time.sleep(0.1)
self.assertTrue('Working' in open(wrapper_log, 'r').read()) self.assertTrue('Working' in open(wrapper_log, 'r').read())
self.assertSortedListEqual(os.listdir(self.software_root), self.assertSortedListEqual(os.listdir(self.software_root),
[instance.software.software_hash]) [instance.software.software_hash])
...@@ -1192,13 +1192,13 @@ class TestSlapgridUsageReport(MasterMixin, unittest.TestCase): ...@@ -1192,13 +1192,13 @@ class TestSlapgridUsageReport(MasterMixin, unittest.TestCase):
self.assertSortedListEqual( self.assertSortedListEqual(
os.listdir(instance.partition_path), os.listdir(instance.partition_path),
['.0_wrapper.log', 'worked', 'buildout.cfg', 'etc']) ['.0_wrapper.log', 'worked', 'buildout.cfg', 'etc'])
tries = 10 tries = 50
wrapper_log = os.path.join(instance.partition_path, '.0_wrapper.log') wrapper_log = os.path.join(instance.partition_path, '.0_wrapper.log')
while tries > 0: while tries > 0:
tries -= 1 tries -= 1
if os.path.getsize(wrapper_log) > 0: if os.path.getsize(wrapper_log) > 0:
break break
time.sleep(0.2) time.sleep(0.1)
self.assertTrue('Working' in open(wrapper_log, 'r').read()) self.assertTrue('Working' in open(wrapper_log, 'r').read())
self.assertSortedListEqual(os.listdir(self.instance_root), ['0', 'etc', self.assertSortedListEqual(os.listdir(self.instance_root), ['0', 'etc',
'var']) 'var'])
...@@ -1210,7 +1210,7 @@ class TestSlapgridUsageReport(MasterMixin, unittest.TestCase): ...@@ -1210,7 +1210,7 @@ class TestSlapgridUsageReport(MasterMixin, unittest.TestCase):
tries -= 1 tries -= 1
if os.path.getsize(wrapper_log) > 0: if os.path.getsize(wrapper_log) > 0:
break break
time.sleep(0.2) time.sleep(0.1)
self.assertEqual(computer.sequence, self.assertEqual(computer.sequence,
['getFullComputerInformation']) ['getFullComputerInformation'])
self.assertEqual('started',instance.state) self.assertEqual('started',instance.state)
...@@ -1522,7 +1522,7 @@ exit 127""" % {'worked_file': worked_file}) ...@@ -1522,7 +1522,7 @@ exit 127""" % {'worked_file': worked_file})
computer = ComputerForTest(self.software_root,self.instance_root) computer = ComputerForTest(self.software_root,self.instance_root)
instance = computer.instance_list[0] instance = computer.instance_list[0]
instance.requested_state = 'started' instance.requested_state = 'started'
self.fake_waiting_time = 0.2 self.fake_waiting_time = 0.1
worked_file = os.path.join(instance.partition_path, 'succeed_worked') worked_file = os.path.join(instance.partition_path, 'succeed_worked')
succeed = ("""#!/usr/bin/env sh succeed = ("""#!/usr/bin/env sh
touch "%(worked_file)s" touch "%(worked_file)s"
...@@ -1565,7 +1565,7 @@ exit 127""" % {'worked_file': worked_file}) ...@@ -1565,7 +1565,7 @@ exit 127""" % {'worked_file': worked_file})
instance = computer.instance_list[0] instance = computer.instance_list[0]
instance.requested_state = 'started' instance.requested_state = 'started'
self.fake_waiting_time = 0.2 self.fake_waiting_time = 0.1
promise_path = os.path.join(instance.partition_path, 'etc', 'promise') promise_path = os.path.join(instance.partition_path, 'etc', 'promise')
os.makedirs(promise_path) os.makedirs(promise_path)
...@@ -1588,7 +1588,7 @@ exit 0""" % {'worked_file': worked_file}) ...@@ -1588,7 +1588,7 @@ exit 0""" % {'worked_file': worked_file})
instance = computer.instance_list[0] instance = computer.instance_list[0]
instance.requested_state = 'started' instance.requested_state = 'started'
self.fake_waiting_time = 0.2 self.fake_waiting_time = 0.1
for i in range (0,2): for i in range (0,2):
worked_file = os.path.join(instance.partition_path, 'succeed_%s_worked' % i) worked_file = os.path.join(instance.partition_path, 'succeed_%s_worked' % i)
...@@ -1608,7 +1608,7 @@ exit 0""" % {'worked_file': worked_file}) ...@@ -1608,7 +1608,7 @@ exit 0""" % {'worked_file': worked_file})
computer = ComputerForTest(self.software_root,self.instance_root) computer = ComputerForTest(self.software_root,self.instance_root)
instance = computer.instance_list[0] instance = computer.instance_list[0]
instance.requested_state = 'started' instance.requested_state = 'started'
self.fake_waiting_time = 0.2 self.fake_waiting_time = 0.1
for i in range(2): for i in range(2):
worked_file = os.path.join(instance.partition_path, 'promise_worked_%d' % i) worked_file = os.path.join(instance.partition_path, 'promise_worked_%d' % i)
...@@ -1631,7 +1631,7 @@ fi""" % {'worked_file': worked_file, 'lockfile': lockfile}) ...@@ -1631,7 +1631,7 @@ fi""" % {'worked_file': worked_file, 'lockfile': lockfile})
computer = ComputerForTest(self.software_root,self.instance_root) computer = ComputerForTest(self.software_root,self.instance_root)
instance = computer.instance_list[0] instance = computer.instance_list[0]
instance.requested_state = 'started' instance.requested_state = 'started'
self.fake_waiting_time = 0.2 self.fake_waiting_time = 0.1
for i in range(2): for i in range(2):
worked_file = os.path.join(instance.partition_path, 'promise_worked_%d' % i) worked_file = os.path.join(instance.partition_path, 'promise_worked_%d' % i)
lockfile = os.path.join(instance.partition_path, 'lock') lockfile = os.path.join(instance.partition_path, 'lock')
......
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