-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(robot): add replica rebuilding after engine image upgrade test
Signed-off-by: Yang Chiu <[email protected]>
- Loading branch information
Showing
11 changed files
with
220 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
*** Settings *** | ||
Documentation Longhorn engine image related keywords | ||
Library ../libs/keywords/engine_image_keywords.py | ||
|
||
*** Keywords *** | ||
Create compatible engine image | ||
${compatible_engine_image_name} = deploy_compatible_engine_image | ||
Set Test Variable ${compatible_engine_image_name} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from engine_image.engine_image import EngineImage |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
import time | ||
from utility.utility import logging | ||
from utility.utility import get_longhorn_client | ||
from utility.utility import get_retry_count_and_interval | ||
|
||
|
||
class EngineImage(): | ||
|
||
UPGRADE_TEST_IMAGE_PREFIX = "longhornio/longhorn-test:upgrade-test" | ||
|
||
def __init__(self): | ||
self.retry_count, self.retry_interval = get_retry_count_and_interval() | ||
|
||
def get_default_engine_image(self): | ||
images = get_longhorn_client().list_engine_image() | ||
for img in images: | ||
if img.default: | ||
return img | ||
assert False, f"Failed to get default engine image: {images}" | ||
|
||
def get_default_engine_image_versions(self): | ||
default_img = self.get_default_engine_image() | ||
cli_v = default_img.cliAPIVersion | ||
cli_minv = default_img.cliAPIMinVersion | ||
ctl_v = default_img.controllerAPIVersion | ||
ctl_minv = default_img.controllerAPIMinVersion | ||
data_v = default_img.dataFormatVersion | ||
data_minv = default_img.dataFormatMinVersion | ||
return cli_v, cli_minv, ctl_v, ctl_minv, data_v, data_minv | ||
|
||
def deploy_compatible_engine_image(self): | ||
cli_v, cli_minv, ctl_v, ctl_minv, data_v, data_minv = self.get_default_engine_image_versions() | ||
compatible_engine_image_name = \ | ||
f"{self.UPGRADE_TEST_IMAGE_PREFIX}.{cli_v}-{cli_minv}.{ctl_v}-{ctl_minv}.{data_v}-{data_minv}" | ||
image = self.create_engine_image(compatible_engine_image_name) | ||
return image.image | ||
|
||
def create_engine_image(self, image_name): | ||
image = get_longhorn_client().create_engine_image(image=image_name) | ||
image = self.wait_for_engine_image_deployed(image.name) | ||
assert image.refCount == 0, f"Expected new engine image {image_name} refCount == 0, but it's {image.refCount}" | ||
assert image.noRefSince != "", f"Expected new engine image {image_name} noRefSince not empty, but it's {image.noRefSince}" | ||
return image | ||
|
||
def wait_for_engine_image_deployed(self, image_name): | ||
self.wait_for_engine_image_created(image_name) | ||
for i in range(self.retry_count): | ||
image = get_longhorn_client().by_id_engine_image(image_name) | ||
if image.state == "deployed": | ||
break | ||
time.sleep(self.retry_interval) | ||
assert image.state == "deployed", f"Failed to deploy engine image {image_name}: {image}" | ||
return image | ||
|
||
def wait_for_engine_image_ref_count(self, image_name, count): | ||
self.wait_for_engine_image_created(image_name) | ||
for i in range(self.retry_count): | ||
image = get_longhorn_client().by_id_engine_image(image_name) | ||
if image.refCount == count: | ||
break | ||
time.sleep(self.retry_interval) | ||
assert image.refCount == count, f"Failed to wait engine image {image_name} reference count {count}: {image}" | ||
if count == 0: | ||
assert image.noRefSince != "", f"Expected engine image {image_name} noRefSince non-empty: {image}" | ||
return image | ||
|
||
def wait_for_engine_image_created(self, image_name): | ||
for i in range(self.retry_count): | ||
images = get_longhorn_client().list_engine_image() | ||
found = False | ||
for img in images: | ||
if img.name == image_name: | ||
found = True | ||
break | ||
if found: | ||
break | ||
time.sleep(self.retry_interval) | ||
assert found, f"Failed to create engine image {image_name}: {images}" | ||
|
||
def cleanup_engine_images(self): | ||
images = get_longhorn_client().list_engine_image().data | ||
for image in images: | ||
if not image.default: | ||
self.wait_for_engine_image_ref_count(image.name, 0) | ||
get_longhorn_client().delete(image) | ||
self.wait_for_engine_image_deleted(image.name) | ||
|
||
def wait_for_engine_image_deleted(self, image_name): | ||
|
||
deleted = False | ||
|
||
for i in range(self.retry_count): | ||
|
||
time.sleep(self.retry_interval) | ||
deleted = True | ||
|
||
images = get_longhorn_client().list_engine_image().data | ||
for image in images: | ||
if image.name == image_name: | ||
deleted = False | ||
break | ||
if deleted: | ||
break | ||
|
||
assert deleted, f"Failed to delete engine image {image_name}: {images}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
from engine_image import EngineImage | ||
from utility.utility import logging | ||
|
||
class engine_image_keywords: | ||
|
||
def __init__(self): | ||
self.engine_image = EngineImage() | ||
|
||
def deploy_compatible_engine_image(self): | ||
return self.engine_image.deploy_compatible_engine_image() | ||
|
||
def cleanup_engine_images(self): | ||
return self.engine_image.cleanup_engine_images() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
*** Settings *** | ||
Documentation Engine Image Test Cases | ||
Test Tags regression engine_image | ||
|
||
Resource ../keywords/common.resource | ||
Resource ../keywords/volume.resource | ||
Resource ../keywords/engine_image.resource | ||
|
||
Test Setup Set test environment | ||
Test Teardown Cleanup test resources | ||
|
||
*** Variables *** | ||
${LOOP_COUNT} 1 | ||
${RETRY_COUNT} 300 | ||
${RETRY_INTERVAL} 1 | ||
${DATA_ENGINE} v1 | ||
|
||
*** Test Cases *** | ||
Test Replica Rebuilding After Engine Upgrade | ||
[Tags] coretest | ||
Given Create compatible engine image | ||
And Create volume 0 | ||
And Attach volume 0 | ||
And Wait for volume 0 healthy | ||
And Write data to volume 0 | ||
When Upgrade volume 0 engine to compatible engine image | ||
Then Delete volume 0 replica on node 1 | ||
And Wait until volume 0 replica rebuilding started on node 1 | ||
And Wait until volume 0 replica rebuilding completed on node 1 | ||
And Wait for volume 0 healthy | ||
And Check volume 0 data is intact |