Commit b0447adf authored by Jérome Perrin's avatar Jérome Perrin Committed by Alain Takoudjou

test_slapgrid: tests for software deletion

including the edge case where software permissions have been changed
parent d97d01f8
Pipeline #9843 failed with stage
in 0 seconds
...@@ -397,6 +397,8 @@ class ComputerForTest(object): ...@@ -397,6 +397,8 @@ class ComputerForTest(object):
return {'status_code': 200} return {'status_code': 200}
if url.path == '/buildingSoftwareRelease': if url.path == '/buildingSoftwareRelease':
return {'status_code': 200} return {'status_code': 200}
if url.path == '/destroyedSoftwareRelease':
return {'status_code': 200}
if url.path == '/softwareReleaseError': if url.path == '/softwareReleaseError':
software.error_log = '\n'.join( software.error_log = '\n'.join(
[ [
...@@ -1921,6 +1923,41 @@ echo %s; echo %s; exit 42""" % (line1, line2)) ...@@ -1921,6 +1923,41 @@ echo %s; echo %s; exit 42""" % (line1, line2))
self.launchSlapgridSoftware() self.launchSlapgridSoftware()
self.assertIn('shared-part-list = %s' % self.shared_parts_root, software.error_log) self.assertIn('shared-part-list = %s' % self.shared_parts_root, software.error_log)
def test_remove_software(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/sh
mkdir directory
touch directory/file
""")
self.launchSlapgridSoftware()
self.assertIn('directory', os.listdir(os.path.join(self.software_root, software.software_hash)))
software.requested_state = 'destroyed'
self.launchSlapgridSoftware()
self.assertEqual(os.listdir(self.software_root), [])
def test_remove_software_chmod(self):
# This software is "hard" to remove, as permissions have been changed
computer = ComputerForTest(self.software_root, self.instance_root, 1, 1)
with httmock.HTTMock(computer.request_handler):
software = computer.software_list[0]
software.setBuildout("""#!/bin/sh
mkdir directory
touch directory/file
chmod a-rxw directory/file
chmod a-rxw directory
""")
self.launchSlapgridSoftware()
self.assertIn('directory', os.listdir(os.path.join(self.software_root, software.software_hash)))
software.requested_state = 'destroyed'
self.launchSlapgridSoftware()
self.assertEqual(os.listdir(self.software_root), [])
class SlapgridInitialization(unittest.TestCase): class SlapgridInitialization(unittest.TestCase):
""" """
......
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