diff --git a/app/tests/test_api.py b/app/tests/test_api.py index 0828de2f..ffddc3c9 100644 --- a/app/tests/test_api.py +++ b/app/tests/test_api.py @@ -124,8 +124,8 @@ class TestApi(BootTestCase): # images_count field exists self.assertTrue(res.data["images_count"] == 0) - # TODO: test can_rerun_from - + # can_rerun_from field exists, should be an empty list at this point + self.assertTrue(len(res.data["can_rerun_from"]) == 0) # Get console output res = client.get('/api/projects/{}/tasks/{}/output/'.format(project.id, task.id)) @@ -260,7 +260,8 @@ class TestApi(BootTestCase): 'status': -99, 'last_error': 'yo!', 'created_at': 0, - 'pending_action': 0 + 'pending_action': 0, + 'can_rerun_from': ['abc'] }, format='json') # Operation should fail without errors, but nothing has changed in the DB @@ -271,6 +272,7 @@ class TestApi(BootTestCase): self.assertTrue(task.last_error != 'yo!') self.assertTrue(task.created_at != 0) self.assertTrue(task.pending_action != 0) + self.assertTrue(len(res.data['can_rerun_from']) == 0) def test_processingnodes(self): client = APIClient() diff --git a/app/tests/test_api_task.py b/app/tests/test_api_task.py index 04184554..4e7d6ef7 100644 --- a/app/tests/test_api_task.py +++ b/app/tests/test_api_task.py @@ -153,6 +153,9 @@ class TestApiTask(BootTransactionTestCase): # Two images should have been uploaded self.assertTrue(ImageUpload.objects.filter(task=task).count() == 2) + # Can_rerun_from should be an empty list + self.assertTrue(len(res.data['can_rerun_from']) == 0) + # No processing node is set self.assertTrue(task.processing_node is None) @@ -209,6 +212,17 @@ class TestApiTask(BootTransactionTestCase): self.assertTrue(task.status in [status_codes.RUNNING, status_codes.COMPLETED]) # Sometimes the task finishes and we can't test for RUNNING state self.assertTrue(len(task.uuid) > 0) + # Processing node should have a "rerun_from" option + pnode_rerun_from_opts = list(filter(lambda d: 'name' in d and d['name'] == 'rerun-from', pnode.available_options))[0] + self.assertTrue(len(pnode_rerun_from_opts['domain']) > 0) + + # The can_rerun_from field of a task should now be populated + # with the same values as the "rerun_from" domain values of + # the processing node + res = client.get("/api/projects/{}/tasks/{}/".format(project.id, task.id)) + self.assertTrue(res.status_code == status.HTTP_200_OK) + self.assertTrue(pnode_rerun_from_opts['domain'] == res.data['can_rerun_from']) + time.sleep(DELAY) # Calling process pending tasks should finish the process @@ -361,8 +375,31 @@ class TestApiTask(BootTransactionTestCase): self.assertTrue(task.status == status_codes.COMPLETED) - # Test connection, timeout errors + # Test rerun-from clearing mechanism: + + # 1 .Set some task options, including rerun_from + task.options = [{'name': 'mesh-size', 'value':1000}, + {'name': 'rerun-from', 'value': 'odm_meshing'}] + task.save() + + # 2. Remove the task directly from node-odm (simulate a task purge) + self.assertTrue(task.processing_node.remove_task(task.uuid)) + + # 3. Restart the task res = client.post("/api/projects/{}/tasks/{}/restart/".format(project.id, task.id)) + self.assertTrue(res.status_code == status.HTTP_200_OK) + task.refresh_from_db() + self.assertTrue(task.pending_action == pending_actions.RESTART) + + # 4. Check that the rerun_from parameter has been cleared + # but the other parameters are still set + scheduler.process_pending_tasks() + task.refresh_from_db() + self.assertTrue(len(task.uuid) == 0) + self.assertTrue(len(list(filter(lambda d: d['name'] == 'rerun-from', task.options))) == 0) + self.assertTrue(len(list(filter(lambda d: d['name'] == 'mesh-size', task.options))) == 1) + + # Test connection, timeout errors def connTimeout(*args, **kwargs): raise requests.exceptions.ConnectTimeout("Simulated timeout") diff --git a/nodeodm/external/node-OpenDroneMap b/nodeodm/external/node-OpenDroneMap index 7869f04d..432dc044 160000 --- a/nodeodm/external/node-OpenDroneMap +++ b/nodeodm/external/node-OpenDroneMap @@ -1 +1 @@ -Subproject commit 7869f04d81f85259a10651edf3d1b0ce3b3de0da +Subproject commit 432dc04405566ee494befc70eef61bd2c2fcabc5