-
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 uninstallation check test case
ref: longhorn/longhorn#9222 Signed-off-by: Chris <chris.chien@suse.com>
- Loading branch information
1 parent
67e68c8
commit a92eacc
Showing
8 changed files
with
217 additions
and
0 deletions.
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
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,12 @@ | ||
from uninstallation import Uninstallation | ||
|
||
class uninstallation_keywords: | ||
|
||
def __init__(self): | ||
self.uninstallation = Uninstallation() | ||
|
||
def uninstall_longhorn(self, longhor_branch, install_method): | ||
self.uninstallation.uninstall_longhorn(longhor_branch, install_method) | ||
|
||
def check_longhorn_crd_removed(self): | ||
self.uninstallation.check_longhorn_crd_removed() |
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 uninstallation.uninstallation import Uninstallation |
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,57 @@ | ||
from utility.utility import logging | ||
from node import Node | ||
from node_exec import NodeExec | ||
from k8s import k8s | ||
from utility.constant import LONGHORN_NAMESPACE | ||
from utility.constant import LONGHORN_UNINSTALL_JOB_LABEL | ||
from kubernetes import client | ||
|
||
import os | ||
|
||
class Uninstallation: | ||
|
||
def uninstall_longhorn(self, longhorn_branch, install_method): | ||
control_plane_nodes = Node.list_node_names_by_role(self, role="control-plane") | ||
control_plane_node = control_plane_nodes[0] | ||
|
||
if install_method == "kubectl": | ||
self.uninstall_longhorn_by_kubectl(control_plane_node, longhorn_branch) | ||
|
||
elif install_method == "helm": | ||
self.uninstall_longhorn_by_helm(control_plane_node) | ||
|
||
def check_longhorn_crd_removed(self): | ||
all_crd = k8s.get_all_custom_resources() | ||
for crd in all_crd.items: | ||
assert "longhorn.io" not in crd.metadata.name | ||
|
||
def uninstall_longhorn_by_kubectl(self, control_plane_node, longhorn_branch): | ||
cmd = f"kubectl create -f https://raw.githubusercontent.com/longhorn/longhorn/{longhorn_branch}/uninstall/uninstall.yaml" | ||
res = NodeExec.get_instance().issue_cmd(control_plane_node, cmd) | ||
assert res, "apply uninstall yaml failed" | ||
k8s.wait_namespaced_job_complete(job_label=LONGHORN_UNINSTALL_JOB_LABEL, namespace=LONGHORN_NAMESPACE) | ||
self.check_longhorn_uninstall_pod_log() | ||
|
||
cmd =f"kubectl delete -f https://raw.githubusercontent.com/longhorn/longhorn/{longhorn_branch}/deploy/longhorn.yaml" | ||
res = NodeExec.get_instance().issue_cmd(control_plane_node, cmd) | ||
assert res, "delete remaining components failed" | ||
|
||
cmd= f"kubectl delete -f https://raw.githubusercontent.com/longhorn/longhorn/{longhorn_branch}/uninstall/uninstall.yaml" | ||
res = NodeExec.get_instance().issue_cmd(control_plane_node, cmd) | ||
assert res, "delete uninstallation components failed" | ||
k8s.wait_namespace_terminated(namespace=LONGHORN_NAMESPACE) | ||
|
||
def uninstall_longhorn_by_helm(self, control_plane_node): | ||
kubeconfig_path = os.getenv('KUBECONFIG') | ||
|
||
cmd = f"export KUBECONFIG={kubeconfig_path} && helm uninstall longhorn -n {LONGHORN_NAMESPACE}" | ||
res = NodeExec.get_instance().issue_cmd(control_plane_node, cmd) | ||
assert res, "helm uninstallation longhorn failed" | ||
|
||
k8s.delete_namespace(LONGHORN_NAMESPACE) | ||
k8s.wait_namespace_terminated(namespace=LONGHORN_NAMESPACE) | ||
|
||
def check_longhorn_uninstall_pod_log(self): | ||
logs = k8s.get_pod_logs(LONGHORN_NAMESPACE, LONGHORN_UNINSTALL_JOB_LABEL) | ||
assert "level=error" not in logs | ||
assert "level=fatal" not in logs |
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,65 @@ | ||
*** Settings *** | ||
Documentation Uninstallation Checks | ||
Test Tags manual_test_case | ||
|
||
Resource ../keywords/common.resource | ||
Resource ../keywords/setting.resource | ||
Resource ../keywords/volume.resource | ||
Resource ../keywords/persistentvolume.resource | ||
Resource ../keywords/persistentvolumeclaim.resource | ||
Resource ../keywords/workload.resource | ||
Resource ../keywords/backup.resource | ||
Resource ../keywords/snapshot.resource | ||
Resource ../keywords/backupstore.resource | ||
Resource ../keywords/longhorn.resource | ||
|
||
Test Setup Set test environment | ||
Test Teardown Cleanup test resources after uninstall | ||
|
||
*** Variables *** | ||
${LOOP_COUNT} 1 | ||
${RETRY_COUNT} 300 | ||
${RETRY_INTERVAL} 1 | ||
${DATA_ENGINE} v1 | ||
${LONGHORN_BRANCH} masater | ||
${INSTALL_METHOD} kubectl | ||
|
||
*** Test Cases *** | ||
Uninstallation Checks | ||
[Documentation] Uninstallation Checks | ||
... Prerequisites | ||
... - Have a setup of Longhorn installed on a kubernetes cluster. | ||
... - Have few volumes backups stored on S3/NFS backup store. | ||
... - Have one DR volume created (not activated) in another cluster with a volume in current cluster. | ||
... | ||
... Test steps | ||
... 1. Uninstall Longhorn. | ||
... 2. Check the logs of the job longhorn-uninstall, make sure there is no error(skip this step if using helm). | ||
... 3. Check all the components of Longhorn from the namespace longhorn-system are uninstalled. E.g. Longhorn manager, Longhorn driver, Longhorn UI, instance manager, engine image, CSI driver etc. | ||
... 4. Check all the CRDs are removed kubectl get crds | grep longhorn. | ||
... | ||
... Not implemented Steps | ||
... 5. Check the backup stores, the backups taken should NOT be removed. | ||
... 6. Activate the DR volume in the other cluster and check the data. | ||
Given Set setting deleting-confirmation-flag to true | ||
And Create volume 0 with dataEngine=v1 | ||
And Attach volume 0 | ||
And Wait for volume 0 healthy | ||
And Create volume 1 with dataEngine=v2 | ||
And Attach volume 1 | ||
And Wait for volume 1 healthy | ||
|
||
When Create backup 0 for volume 0 | ||
And Create backup 1 for volume 1 | ||
Then Verify backup list contains no error for volume 0 | ||
And Verify backup list contains no error for volume 1 | ||
And Verify backup list contains backup 0 of volume 0 | ||
And Verify backup list contains backup 1 of volume 1 | ||
|
||
When Create DR volume 2 from backup 0 | ||
And Wait for volume 2 restoration from backup 0 completed | ||
|
||
Then Uninstall Longhorn ${LONGHORN_BRANCH} by ${INSTALL_METHOD} | ||
And Check Longhorn CRD removed |