-
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
ba5a86a
commit 21d5f33
Showing
19 changed files
with
466 additions
and
2 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
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
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,14 @@ | ||
from longhorn_deploy import LonghornDeploy | ||
class longhorn_deploy_keywords: | ||
|
||
def __init__(self): | ||
self.longhorn = LonghornDeploy() | ||
|
||
def uninstall_longhorn(self, longhorn_branch): | ||
self.longhorn.uninstall(longhorn_branch) | ||
|
||
def check_longhorn_crd_removed(self): | ||
self.longhorn.check_longhorn_crd_removed() | ||
|
||
def install_longhorn(self, longhorn_branch): | ||
self.longhorn.install(longhorn_branch) |
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,3 @@ | ||
from longhorn_deploy.longhorn_deploy import LonghornDeploy | ||
from longhorn_deploy.longhorn_kubectl import LonghornKubectl | ||
from longhorn_deploy.longhorn_helm_chart import LonghornHelmChart |
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,68 @@ | ||
from abc import ABC, abstractmethod | ||
from k8s import k8s | ||
from kubernetes.client.rest import ApiException | ||
from utility.constant import LONGHORN_NAMESPACE | ||
from utility.constant import LONGHORN_UNINSTALL_JOB_LABEL | ||
import time | ||
from utility.utility import logging | ||
from node_exec import NodeExec | ||
from node import Node | ||
|
||
class Base(ABC): | ||
|
||
@abstractmethod | ||
def install(self): | ||
return NotImplemented | ||
|
||
@abstractmethod | ||
def uninstall(self, longhorn_branch=None): | ||
return NotImplemented | ||
|
||
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 check_longhorn_uninstall_pod_log(self): | ||
logs = k8s.get_pod_logs(LONGHORN_NAMESPACE, LONGHORN_UNINSTALL_JOB_LABEL) | ||
assert "error" not in logs | ||
assert "level=fatal" not in logs | ||
|
||
def wait_longhorn_status_running(self): | ||
RETRY_COUNTS = 10 | ||
RETRY_INTERVAL = 60 | ||
retries = 0 | ||
|
||
while True: | ||
try: | ||
pods = k8s.list_namespace_pods(LONGHORN_NAMESPACE) | ||
|
||
csi_pods = [pod for pod in pods.items if 'csi-' in pod.metadata.name] | ||
engine_image_pods = [pod for pod in pods.items if 'engine-image-' in pod.metadata.name] | ||
non_running_pods = [pod for pod in pods.items if pod.status.phase != 'Running'] | ||
|
||
if csi_pods and engine_image_pods and not non_running_pods: | ||
logging(f"Longhorn is fully running.") | ||
break | ||
else: | ||
logging("Longhorn is still installing ... re-checking in 1m") | ||
except ApiException as e: | ||
logging("Exception when calling CoreV1Api->list_namespaced_pod: %s\n" % e) | ||
|
||
time.sleep(RETRY_INTERVAL) | ||
retries += 1 | ||
|
||
if retries == RETRY_COUNTS: | ||
logging("Error: longhorn installation timeout") | ||
return 1 | ||
|
||
def expose_longhorn_ui(self): | ||
control_plane_nodes = Node.list_node_names_by_role(self, role="control-plane") | ||
control_plane_node = control_plane_nodes[0] | ||
|
||
cmd = "kubectl expose --type=NodePort deployment longhorn-ui -n longhorn-system "\ | ||
"--port 8000 --name longhorn-ui-nodeport "\ | ||
"--overrides '{\"apiVersion\": \"v1\",\"spec\":{\"ports\": [{\"port\":8000,\"protocol\":\"TCP\",\"targetPort\":8000,\"nodePort\":30000}]}}'" | ||
|
||
res = NodeExec.get_instance().issue_cmd(control_plane_node, cmd) | ||
assert res, "expose longhorn-ui failed" |
Oops, something went wrong.