Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[e2e] add new volume negative test case #1510

Merged
merged 1 commit into from
Sep 12, 2024
Merged
Changes from all commits
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
55 changes: 55 additions & 0 deletions harvester_e2e_tests/integrations/test_1_volumes.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,61 @@ def teardown_class(cls):
)


@pytest.mark.p0
@pytest.mark.negative
@pytest.mark.volumes
def test_volume_export(api_client, wait_timeout, unique_name, ubuntu_image):
''' ref: https://github.com/harvester/tests/issues/1057

1. Create image
2. Create volume from the image
3. export the volume to new image
4. delete the new image
'''
image_id, storage_cls = ubuntu_image['id'], f"longhorn-{ubuntu_image['display_name']}"
spec = api_client.volumes.Spec("10Gi", storage_cls)

# Create Volume from image and wait it bounded
code, data = api_client.volumes.create(unique_name, spec, image_id=image_id)
assert 201 == code, (code, data)
endtime = datetime.now() + timedelta(seconds=wait_timeout)
while endtime > datetime.now():
code, data = api_client.volumes.get(unique_name)
if "Bound" == data['status']['phase']:
break
sleep(5)
else:
raise AssertionError(
"Volume not changed to phase: _Bound_ with {wait_timeout} timed out\n"
f"Got error: {code}, {data}"
)

# Export volume to new image
code, data = api_client.volumes.export(unique_name, unique_name, "harvester-longhorn")
assert 204 == code, (code, data)
# check the new image is available and creating
code, data = api_client.images.get()
assert 200 == code, (code, data)
new_img = next(d for d in data['items'] if unique_name == d['spec']['displayName'])
assert new_img, (code, data['items'])
assert 100 > new_img['status'].get('progress', 0), (code, new_img)
# Delete the source volume
code, data = api_client.volumes.delete(unique_name)
assert 422 == code, (code, data)

# teardown
fns = [(api_client.volumes, unique_name), (api_client.images, new_img['metadata']['name'])]
endtime = datetime.now() + timedelta(seconds=wait_timeout)
while endtime > datetime.now():
fn, name = fns[-1]
code, data = fn.delete(name)
if 404 == code:
fns.pop()
if not fns:
break
sleep(3)


@pytest.mark.p0
@pytest.mark.volumes
class TestVolumeWithVM:
Expand Down