Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
[LIB-757] - make backup restore synchronous
  • Loading branch information
ilu2112 committed Jun 29, 2016
commit 4a62a9a45b366e85bc47b44ee7d3e4e90710e2ef
9 changes: 8 additions & 1 deletion syncano/models/backups.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# -*- coding: utf-8 -*-
import time

from . import fields
from .base import Model
from .instances import Instance
Expand Down Expand Up @@ -61,4 +63,9 @@ def restore(self):
}
}
connection = self._get_connection()
connection.request('POST', endpoint, **kwargs)
response = connection.request('POST', endpoint, **kwargs)
restore_endpoint = response['links']['self']
restore_response = connection.request('GET', restore_endpoint)
while restore_response['status'] == 'running':
Copy link
Copy Markdown
Contributor

@opalczynski opalczynski Jun 30, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is also problematic - when you rework this - just return the Restore object and leave reload (for the status update) to the user - or provide method is_success - which will ask for the status by API (in other words: will do reload of the status field -> object).

time.sleep(1)
restore_response = connection.request('GET', restore_endpoint)
4 changes: 2 additions & 2 deletions tests/integration_test_backups.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,12 @@ def _test_backup_restore(self, backup_id):
'There should be only 1 more instance class after new class creation.'
)

# wait for backup to be truly saved and restored
# wait for backup to be saved
while backup.status != 'success':
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If something will fail - we will never end the tests :)

So the check here - is that restore is created and running - the whole logic is checked on CORE test no need to repeat that.

time.sleep(1)
backup.reload()

backup.restore()
time.sleep(15)

instance.reload()
classes_count_after_restore = len(list(instance.classes))
Expand Down