Clone snapshot to a share of larger size

Changing this scenario test will help us establish
yet another requirement from our share backend driver
expectations:

- Users should be able to create a share of size X
- They can snapshot the share
- They can then create a new share from snapshot of
  size Y (> X)
- Backend share drivers are expected to ensure that
  the resulting share is extended past the size of the
  parent share.

Also re-enable scenario tests on the LVM driver job
so we can run this test case.

Depends-On: Ie6599bc3533a002fa118ebe8b9243d677bdb410e
Change-Id: I5bdcfc1c975f6e2cbaf0601d344495b697176961
Related-Bug: #2020816
Signed-off-by: Goutham Pacha Ravi <gouthampravi@gmail.com>
This commit is contained in:
Goutham Pacha Ravi 2023-10-13 16:34:32 -07:00
parent dae4d135da
commit 618e61713c
1 changed files with 35 additions and 14 deletions

View File

@ -251,10 +251,12 @@ class ShareBasicOpsBase(manager.ShareScenarioTest):
def test_write_data_to_share_created_from_snapshot(self):
# 1 - Create UVM, ok, created
instance = self.boot_instance(wait_until="BUILD")
parent_share_size = CONF.share.share_size
# 2 - Create share S1, ok, created
extra_specs = {'snapshot_support': True}
parent_share = self.create_share(extra_specs=extra_specs)
parent_share = self.create_share(extra_specs=extra_specs,
size=parent_share_size)
parent_share_export_location = self.get_user_export_locations(
parent_share)[0]
@ -272,7 +274,6 @@ class ShareBasicOpsBase(manager.ShareScenarioTest):
locations=parent_share_export_location)
# 5 - Try mount S1 to UVM, ok, mounted
parent_share_dir = "/mnt/parent"
remote_client.exec_command("sudo mkdir -p %s" % parent_share_dir)
@ -281,20 +282,30 @@ class ShareBasicOpsBase(manager.ShareScenarioTest):
parent_share_dir)
self.addCleanup(self.unmount_share, remote_client, parent_share_dir)
# 6 - Create "file1", ok, created
# 6 - Get the size of S1
fs_size = remote_client.exec_command(
f"sudo df -h --output=size {parent_share_dir} | awk ' NR == 2 '"
).strip()
LOG.debug("Mounted parent share's size is %s", fs_size)
# 7 - Create "file1", ok, created
remote_client.exec_command("sudo touch %s/file1" % parent_share_dir)
# 7 - Create snapshot SS1 from S1, ok, created
# 8 - Create snapshot SS1 from S1, ok, created
snapshot = self._create_snapshot(parent_share['id'])
# 8 - Create "file2" in share S1 - ok, created. We expect that
# 9 - Create "file2" in share S1 - ok, created. We expect that
# snapshot will not contain any data created after snapshot creation.
remote_client.exec_command("sudo touch %s/file2" % parent_share_dir)
# 9 - Create share S2 from SS1, ok, created
child_share = self.create_share(snapshot_id=snapshot["id"])
# 10 - Create share S2 from SS1, ok, created
# The share is intentionally created with a larger size than the
# snapshot
child_share_size = parent_share_size + 1
child_share = self.create_share(snapshot_id=snapshot["id"],
size=child_share_size)
# 10 - Try mount S2 - fail, access denied. We test that child share
# 11 - Try mount S2 - fail, access denied. We test that child share
# did not get access rules from parent share.
child_share_export_location = self.get_user_export_locations(
child_share)[0]
@ -307,35 +318,45 @@ class ShareBasicOpsBase(manager.ShareScenarioTest):
child_share_export_location, remote_client, child_share_dir,
)
# 11 - Provide RW access to S2, ok, provided
# 12 - Provide RW access to S2, ok, provided
self.allow_access(share=child_share,
instance=instance,
remote_client=remote_client,
locations=child_share_export_location)
# 12 - Try mount S2, ok, mounted
# 13 - Try mount S2, ok, mounted
self.mount_share(child_share_export_location,
remote_client,
child_share_dir)
self.addCleanup(self.unmount_share, remote_client, child_share_dir)
# 13 - List files on S2, only "file1" exists
# 14 - Verify the size of S2, it has to be size(S1) + 1 GiB
fs_size_2 = remote_client.exec_command(
f"sudo df -h --output=size {child_share_dir} | awk ' NR == 2 '"
).strip()
LOG.debug("Mounted child share's size is %s", fs_size_2)
# the size may be a decimal, and lesser than the actual size we expect
fs_size_2 = float(fs_size_2[:-1])
self.assertTrue(parent_share_size < fs_size_2 <= child_share_size)
# 15 - List files on S2, only "file1" exists
output = remote_client.exec_command(
"sudo ls -lRA %s" % child_share_dir)
self.assertIn('file1', output)
self.assertNotIn('file2', output)
# 14 - Create file3 on S2, ok, file created
# 16 - Create file3 on S2, ok, file created
remote_client.exec_command("sudo touch %s/file3" % child_share_dir)
# 15 - List files on S1, two files exist - "file1" and "file2"
# 17 - List files on S1, two files exist - "file1" and "file2"
output = remote_client.exec_command(
"sudo ls -lRA %s" % parent_share_dir)
self.assertIn('file1', output)
self.assertIn('file2', output)
self.assertNotIn('file3', output)
# 16 - List files on S2, two files exist - "file1" and "file3"
# 18 - List files on S2, two files exist - "file1" and "file3"
output = remote_client.exec_command(
"sudo ls -lRA %s" % child_share_dir)
self.assertIn('file1', output)