Commit 1eadb8f3 authored by Cédric Le Ninivin's avatar Cédric Le Ninivin

wip: test passing with slapgrid-sr

parent 5b0a1273
......@@ -837,7 +837,6 @@ exit 1
self.assertEqual(computer.sequence,
['/getFullComputerInformation',
'/startedComputerPartition', '/getHateoasUrl',
'/getJIOAPIUrl',
'/getFullComputerInformation', '/softwareInstanceError'])
self.assertEqual(instance.state, 'started')
......@@ -889,7 +888,7 @@ chmod 755 etc/run/wrapper
'etc', 'software_release', 'worked', '.slapos-retention-lock-delay'])
self.assertLogContent(wrapper_log, 'Signal handler called with signal 15')
self.assertEqual(computer.sequence,
['/getHateoasUrl', '/getJIOAPIUrl',
['/getHateoasUrl',
'/getFullComputerInformation',
'/stoppedComputerPartition'])
self.assertEqual(instance.state, 'stopped')
......@@ -952,7 +951,7 @@ exit 1
'.slapos-retention-lock-delay', '.slapgrid-0-error.log'])
self.assertLogContent(wrapper_log, 'Signal handler called with signal 15')
self.assertEqual(computer.sequence,
['/getHateoasUrl', '/getJIOAPIUrl',
['/getHateoasUrl',
'/getFullComputerInformation',
'/softwareInstanceError'])
self.assertEqual(instance.state, 'started')
......@@ -989,7 +988,7 @@ exit 1
wrapper_log = os.path.join(instance.partition_path, '.0_wrapper.log')
self.assertLogContent(wrapper_log, 'Working')
self.assertEqual(computer.sequence,
['/getHateoasUrl', '/getJIOAPIUrl',
['/getHateoasUrl',
'/getFullComputerInformation',
'/startedComputerPartition'])
self.assertEqual('started', instance.state)
......@@ -1467,13 +1466,13 @@ class TestSlapgridCPPartitionProcessing(MasterMixin, unittest.TestCase):
self.assertEqual(self.launchSlapgrid(), slapgrid.SLAPGRID_SUCCESS)
self.assertEqual(self.launchSlapgrid(), slapgrid.SLAPGRID_SUCCESS)
self.assertEqual(computer.sequence,
['/getHateoasUrl', '/getJIOAPIUrl',
['/getHateoasUrl',
'/getFullComputerInformation',
'/stoppedComputerPartition',
'/getHateoasUrl', '/getJIOAPIUrl',
'/getHateoasUrl',
'/getFullComputerInformation',
'/stoppedComputerPartition',
'/getHateoasUrl', '/getJIOAPIUrl',
'/getHateoasUrl',
'/getFullComputerInformation'])
def test_partition_timestamp_no_timestamp(self):
......@@ -1493,10 +1492,10 @@ class TestSlapgridCPPartitionProcessing(MasterMixin, unittest.TestCase):
instance.timestamp = None
self.launchSlapgrid()
self.assertEqual(computer.sequence,
['/getHateoasUrl', '/getJIOAPIUrl',
['/getHateoasUrl',
'/getFullComputerInformation',
'/stoppedComputerPartition',
'/getHateoasUrl', '/getJIOAPIUrl',
'/getHateoasUrl',
'/getFullComputerInformation',
'/stoppedComputerPartition'])
......@@ -3123,6 +3122,73 @@ fdleak() {
: >&5 && fdleak 5
: >&6 && fdleak 6
echo "file descriptors: ok"
exit 1 # do not proceed trying to use this software
""")
self.launchSlapgridSoftware()
self.assertEqual(
software.sequence,
[
(
'/api/put/',
{
'compute_node_id': self.computer_id,
'portal_type': 'Software Installation',
'reported_state': 'building',
'software_release_uri': software.name,
}
),
(
'/api/put/',
{
'compute_node_id': self.computer_id,
'portal_type': 'Software Installation',
'error_status': software.error_log,
'software_release_uri': software.name,
}
)
]
)
self.assertNotIn("file descriptors: leaked", software.error_log)
self.assertIn("file descriptors: ok", software.error_log)
class TestSlapgridNoFDLeakSlapTool(SlapToolMasterMixin, unittest.TestCase):
def test_no_fd_leak(self):
filev = []
try:
# open some file descriptors
for i in range(4):
f = open(os.devnull)
filev.append(f)
self.assertGreater(f.fileno(), 2)
# 'node software' with check that buildout does not see opened files
self._test_no_fd_leak()
finally:
for f in filev:
f.close()
def _test_no_fd_leak(self):
computer = ComputerForTest(self.software_root, self.instance_root, 1, 1)
with httmock.HTTMock(computer.request_handler):
software = computer.software_list[0]
software.setBuildout("""#!/bin/bash
fdleak() {
echo "file descriptors: leaked:" "$@"
exit 1
}
# https://unix.stackexchange.com/a/206848
: >&3 && fdleak 3
: >&4 && fdleak 4
: >&5 && fdleak 5
: >&6 && fdleak 6
echo "file descriptors: ok"
exit 1 # do not proceed trying to use this software
""")
......
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