Merge "tests: Don't (always) auto-create snapshot instances"
This commit is contained in:
commit
28bb87ff77
|
@ -691,9 +691,10 @@ def share_snapshot_instance_delete(context, snapshot_instance_id):
|
||||||
####################
|
####################
|
||||||
|
|
||||||
|
|
||||||
def share_snapshot_create(context, values):
|
def share_snapshot_create(context, values, create_snapshot_instance=True):
|
||||||
"""Create a snapshot from the values dictionary."""
|
"""Create a snapshot from the values dictionary."""
|
||||||
return IMPL.share_snapshot_create(context, values)
|
return IMPL.share_snapshot_create(
|
||||||
|
context, values, create_snapshot_instance=create_snapshot_instance)
|
||||||
|
|
||||||
|
|
||||||
def share_snapshot_get(context, snapshot_id, project_only=True):
|
def share_snapshot_get(context, snapshot_id, project_only=True):
|
||||||
|
|
|
@ -1829,8 +1829,9 @@ class ShareSnapshotDatabaseAPITestCase(test.TestCase):
|
||||||
'status': expected_status,
|
'status': expected_status,
|
||||||
'metadata': {'foo': 'bar'}
|
'metadata': {'foo': 'bar'}
|
||||||
}
|
}
|
||||||
snapshots = db_api.share_snapshot_get_all(
|
snapshots = db_api.share_snapshot_get_all(self.ctxt, filters=filters)
|
||||||
self.ctxt, filters=filters)
|
|
||||||
|
self.assertEqual(1, len(snapshots))
|
||||||
|
|
||||||
for snapshot in snapshots:
|
for snapshot in snapshots:
|
||||||
s = snapshot.get('share_snapshot_metadata')
|
s = snapshot.get('share_snapshot_metadata')
|
||||||
|
@ -1842,8 +1843,6 @@ class ShareSnapshotDatabaseAPITestCase(test.TestCase):
|
||||||
self.assertEqual(s[0]['key'], filter_meta_key)
|
self.assertEqual(s[0]['key'], filter_meta_key)
|
||||||
self.assertEqual(s[0]['value'], filter_meta_val)
|
self.assertEqual(s[0]['value'], filter_meta_val)
|
||||||
|
|
||||||
self.assertEqual(1, len(snapshots))
|
|
||||||
|
|
||||||
def test_share_snapshot_get_latest_for_share(self):
|
def test_share_snapshot_get_latest_for_share(self):
|
||||||
|
|
||||||
share = db_utils.create_share(size=1)
|
share = db_utils.create_share(size=1)
|
||||||
|
@ -1890,7 +1889,7 @@ class ShareSnapshotDatabaseAPITestCase(test.TestCase):
|
||||||
def test_share_snapshot_instance_get_all_with_filters_some(self, status):
|
def test_share_snapshot_instance_get_all_with_filters_some(self, status):
|
||||||
expected_status = status or (constants.STATUS_CREATING,
|
expected_status = status or (constants.STATUS_CREATING,
|
||||||
constants.STATUS_DELETING)
|
constants.STATUS_DELETING)
|
||||||
expected_number = 1 if status else 3
|
expected_number = 1 if status else 2
|
||||||
filters = {
|
filters = {
|
||||||
'snapshot_ids': 'fake_snapshot_id_1',
|
'snapshot_ids': 'fake_snapshot_id_1',
|
||||||
'statuses': expected_status
|
'statuses': expected_status
|
||||||
|
@ -1925,7 +1924,7 @@ class ShareSnapshotDatabaseAPITestCase(test.TestCase):
|
||||||
}
|
}
|
||||||
instances = db_api.share_snapshot_instance_get_all_with_filters(
|
instances = db_api.share_snapshot_instance_get_all_with_filters(
|
||||||
self.ctxt, filters)
|
self.ctxt, filters)
|
||||||
self.assertEqual(6, len(instances))
|
self.assertEqual(4, len(instances))
|
||||||
|
|
||||||
def test_share_snapshot_instance_create(self):
|
def test_share_snapshot_instance_create(self):
|
||||||
snapshot = db_utils.create_snapshot(with_share=True)
|
snapshot = db_utils.create_snapshot(with_share=True)
|
||||||
|
|
|
@ -156,7 +156,12 @@ def create_snapshot(**kwargs):
|
||||||
'provider_location': 'fake',
|
'provider_location': 'fake',
|
||||||
}
|
}
|
||||||
snapshot.update(kwargs)
|
snapshot.update(kwargs)
|
||||||
return db.share_snapshot_create(context.get_admin_context(), snapshot)
|
|
||||||
|
return db.share_snapshot_create(
|
||||||
|
context.get_admin_context(),
|
||||||
|
snapshot,
|
||||||
|
create_snapshot_instance='instances' not in snapshot,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def create_snapshot_instance(snapshot_id, **kwargs):
|
def create_snapshot_instance(snapshot_id, **kwargs):
|
||||||
|
|
Loading…
Reference in New Issue