Checkpoint marker not working when using plan or date
When listing checkpoints by plan or by date with marker, the result is not correct. It is because that the marker that generated in the process is not right, this patch will fix it. Closes-Bug: #1803409 Change-Id: I3d6c1a93e6408de1ca95552531d9ff2d2395afa2
This commit is contained in:
parent
705040dbe3
commit
0a756778ed
|
@ -326,13 +326,12 @@ class CheckpointCollection(object):
|
|||
prefix = "/by-plan/%s/%s/" % (plan_id, project_id)
|
||||
if marker is not None:
|
||||
date = marker_checkpoint["created_at"]
|
||||
marker = "/by-plan/%s/%s/%s/%s" % (
|
||||
plan_id, project_id, date, marker)
|
||||
marker = "/%s/%s" % (date, marker)
|
||||
else:
|
||||
prefix = "/by-date/"
|
||||
if marker is not None:
|
||||
date = marker_checkpoint["created_at"]
|
||||
marker = "/by-date/%s/%s/%s" % (date, project_id, marker)
|
||||
marker = "/%s/%s/%s" % (date, project_id, marker)
|
||||
|
||||
return self._list_ids(project_id, prefix, limit, marker, start_date,
|
||||
end_date, sort_dir, context=context)
|
||||
|
|
|
@ -95,6 +95,20 @@ class CheckpointCollectionTest(base.TestCase):
|
|||
plan_id="fake_plan_id", start_date=date2)),
|
||||
checkpoints_plan_date2)
|
||||
|
||||
def test_list_checkpoints_by_plan_with_marker(self):
|
||||
collection = self._create_test_collection()
|
||||
plan = fake_protection_plan()
|
||||
plan["id"] = "fake_plan_id"
|
||||
plan['provider_id'] = "fake_provider_id"
|
||||
plan["project_id"] = "fake_project_id"
|
||||
provider_id = plan['provider_id']
|
||||
checkpoints_plan = {collection.create(plan, {
|
||||
'checkpoint_id': i}).id for i in range(10)}
|
||||
checkpoints_sorted = sorted(checkpoints_plan)
|
||||
self.assertEqual(len(collection.list_ids(
|
||||
project_id="fake_project_id", provider_id=provider_id,
|
||||
plan_id="fake_plan_id", marker=checkpoints_sorted[0])) < 10, True)
|
||||
|
||||
def test_list_checkpoints_by_date(self):
|
||||
collection = self._create_test_collection()
|
||||
date1 = datetime.strptime("2016-06-12", "%Y-%m-%d")
|
||||
|
@ -121,6 +135,24 @@ class CheckpointCollectionTest(base.TestCase):
|
|||
end_date=date2)),
|
||||
checkpoints_date_2)
|
||||
|
||||
def test_list_checkpoints_by_date_with_marker(self):
|
||||
collection = self._create_test_collection()
|
||||
date = datetime.strptime("2018-11-12", "%Y-%m-%d")
|
||||
timeutils.utcnow = mock.MagicMock()
|
||||
timeutils.utcnow.return_value = date
|
||||
plan = fake_protection_plan()
|
||||
plan["id"] = "fake_plan_id"
|
||||
plan['provider_id'] = "fake_provider_id"
|
||||
plan["project_id"] = "fake_project_id"
|
||||
provider_id = plan['provider_id']
|
||||
checkpoints_plan = {collection.create(plan, {
|
||||
'checkpoint_id': i}).id for i in range(10)}
|
||||
checkpoints_sorted = sorted(checkpoints_plan)
|
||||
self.assertEqual(len(collection.list_ids(
|
||||
project_id="fake_project_id", provider_id=provider_id,
|
||||
start_date=date,
|
||||
marker=checkpoints_sorted[0])) < 10, True)
|
||||
|
||||
def test_delete_checkpoint(self):
|
||||
collection = self._create_test_collection()
|
||||
plan = fake_protection_plan()
|
||||
|
|
Loading…
Reference in New Issue