Skip to content

Commit

Permalink
Updated arguments and test
Browse files Browse the repository at this point in the history
  • Loading branch information
Thoughtseize1 committed Dec 13, 2024
1 parent c4de2b1 commit 644fe50
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@


# <INGREDIENT consistency_group_clone_disks>
def clone_disks_to_consistency_group(project_id, group_name, group_region):
def clone_disks_to_consistency_group(project_id, group_region, group_name):
"""
Clones disks to a consistency group in the specified region.
Args:
project_id (str): The ID of the Google Cloud project.
group_name (str): The name of the consistency group.
group_region (str): The region where the consistency group is located.
group_name (str): The name of the consistency group.
Returns:
bool: True if the disks were successfully cloned to the consistency group.
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,13 @@ def wait_for_extended_operation(
return result


def clone_disks_to_consistency_group(project_id, group_name, group_region):
def clone_disks_to_consistency_group(project_id, group_region, group_name):
"""
Clones disks to a consistency group in the specified region.
Args:
project_id (str): The ID of the Google Cloud project.
group_name (str): The name of the consistency group.
group_region (str): The region where the consistency group is located.
group_name (str): The name of the consistency group.
Returns:
bool: True if the disks were successfully cloned to the consistency group.
"""
Expand Down
27 changes: 15 additions & 12 deletions compute/client_library/snippets/tests/test_disks.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@
)
from ..disks.сonsistency_groups.create_consistency_group import create_consistency_group
from ..disks.сonsistency_groups.delete_consistency_group import delete_consistency_group
from ..disks.сonsistency_groups.remove_disk_consistency_group import remove_disk_consistency_group
from ..disks.сonsistency_groups.remove_disk_consistency_group import (
remove_disk_consistency_group,
)
from ..images.get import get_image_from_family
from ..instances.create import create_instance, disk_from_image
from ..instances.delete import delete_instance
Expand Down Expand Up @@ -514,14 +516,16 @@ def test_clone_disks_in_consistency_group(
autodelete_regional_disk_name,
autodelete_regional_blank_disk,
):
first = "first-group" + uuid.uuid4().hex[:5]
create_consistency_group(PROJECT, REGION, first, "description")
group_name1 = "first-group" + uuid.uuid4().hex[:5]
group_name2 = "second-group" + uuid.uuid4().hex[:5]
create_consistency_group(PROJECT, REGION, group_name1, "description")
create_consistency_group(PROJECT, REGION_SECONDARY, group_name2, "description")

add_disk_consistency_group(
project_id=PROJECT,
disk_name=autodelete_regional_blank_disk.name,
disk_location=REGION,
consistency_group_name=first,
consistency_group_name=group_name1,
consistency_group_region=REGION,
)

Expand All @@ -535,14 +539,11 @@ def test_clone_disks_in_consistency_group(
DISK_SIZE,
)

second = "second-group" + uuid.uuid4().hex[:5]
create_consistency_group(PROJECT, REGION_SECONDARY, second, "description")

add_disk_consistency_group(
project_id=PROJECT,
disk_name=second_disk.name,
disk_location=REGION_SECONDARY,
consistency_group_name=second,
consistency_group_name=group_name2,
consistency_group_region=REGION_SECONDARY,
)

Expand All @@ -555,7 +556,7 @@ def test_clone_disks_in_consistency_group(
)
time.sleep(60)
try:
assert clone_disks_to_consistency_group(PROJECT, second, REGION_SECONDARY)
assert clone_disks_to_consistency_group(PROJECT, REGION_SECONDARY, group_name2)
finally:
stop_disk_replication(
project_id=PROJECT,
Expand All @@ -571,6 +572,8 @@ def test_clone_disks_in_consistency_group(
for disk in disks:
delete_regional_disk(PROJECT, REGION_SECONDARY, disk.name)
time.sleep(25)
remove_disk_consistency_group(PROJECT, autodelete_regional_blank_disk.name, REGION, first, REGION)
delete_consistency_group(PROJECT, REGION, first)
delete_consistency_group(PROJECT, REGION_SECONDARY, second)
remove_disk_consistency_group(
PROJECT, autodelete_regional_blank_disk.name, REGION, group_name1, REGION
)
delete_consistency_group(PROJECT, REGION, group_name1)
delete_consistency_group(PROJECT, REGION_SECONDARY, group_name2)

0 comments on commit 644fe50

Please sign in to comment.