mirror of
https://github.com/ansible/awx.git
synced 2026-03-21 10:57:36 -02:30
Merge pull request #2628 from AlanCoding/all_projects
Apply lock file to all project updates
This commit is contained in:
@@ -1710,12 +1710,10 @@ class RunProjectUpdate(BaseTask):
|
|||||||
# re-create root project folder if a natural disaster has destroyed it
|
# re-create root project folder if a natural disaster has destroyed it
|
||||||
if not os.path.exists(settings.PROJECTS_ROOT):
|
if not os.path.exists(settings.PROJECTS_ROOT):
|
||||||
os.mkdir(settings.PROJECTS_ROOT)
|
os.mkdir(settings.PROJECTS_ROOT)
|
||||||
if instance.launch_type == 'sync':
|
self.acquire_lock(instance)
|
||||||
self.acquire_lock(instance)
|
|
||||||
|
|
||||||
def post_run_hook(self, instance, status, **kwargs):
|
def post_run_hook(self, instance, status, **kwargs):
|
||||||
if instance.launch_type == 'sync':
|
self.release_lock(instance)
|
||||||
self.release_lock(instance)
|
|
||||||
p = instance.project
|
p = instance.project
|
||||||
if instance.job_type == 'check' and status not in ('failed', 'canceled',):
|
if instance.job_type == 'check' and status not in ('failed', 'canceled',):
|
||||||
fd = open(self.revision_path, 'r')
|
fd = open(self.revision_path, 'r')
|
||||||
|
|||||||
@@ -32,16 +32,18 @@ class TestDependentInventoryUpdate:
|
|||||||
task.revision_path = scm_revision_file
|
task.revision_path = scm_revision_file
|
||||||
proj_update = ProjectUpdate.objects.create(project=scm_inventory_source.source_project)
|
proj_update = ProjectUpdate.objects.create(project=scm_inventory_source.source_project)
|
||||||
with mock.patch.object(RunProjectUpdate, '_update_dependent_inventories') as inv_update_mck:
|
with mock.patch.object(RunProjectUpdate, '_update_dependent_inventories') as inv_update_mck:
|
||||||
task.post_run_hook(proj_update, 'successful')
|
with mock.patch.object(RunProjectUpdate, 'release_lock'):
|
||||||
inv_update_mck.assert_called_once_with(proj_update, mock.ANY)
|
task.post_run_hook(proj_update, 'successful')
|
||||||
|
inv_update_mck.assert_called_once_with(proj_update, mock.ANY)
|
||||||
|
|
||||||
def test_no_unwanted_dependent_inventory_updates(self, project, scm_revision_file):
|
def test_no_unwanted_dependent_inventory_updates(self, project, scm_revision_file):
|
||||||
task = RunProjectUpdate()
|
task = RunProjectUpdate()
|
||||||
task.revision_path = scm_revision_file
|
task.revision_path = scm_revision_file
|
||||||
proj_update = ProjectUpdate.objects.create(project=project)
|
proj_update = ProjectUpdate.objects.create(project=project)
|
||||||
with mock.patch.object(RunProjectUpdate, '_update_dependent_inventories') as inv_update_mck:
|
with mock.patch.object(RunProjectUpdate, '_update_dependent_inventories') as inv_update_mck:
|
||||||
task.post_run_hook(proj_update, 'successful')
|
with mock.patch.object(RunProjectUpdate, 'release_lock'):
|
||||||
assert not inv_update_mck.called
|
task.post_run_hook(proj_update, 'successful')
|
||||||
|
assert not inv_update_mck.called
|
||||||
|
|
||||||
def test_dependent_inventory_updates(self, scm_inventory_source):
|
def test_dependent_inventory_updates(self, scm_inventory_source):
|
||||||
task = RunProjectUpdate()
|
task = RunProjectUpdate()
|
||||||
|
|||||||
Reference in New Issue
Block a user