Skip to content

Commit

Permalink
Merge pull request #1575 from c3y1huang/refactor-consolidate-engine-v…
Browse files Browse the repository at this point in the history
…alidation

refactor(negative): consolidate engine validation
  • Loading branch information
khushboo-rancher authored Nov 2, 2023
2 parents a6ca2e1 + a3e95c9 commit 075920e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 20 deletions.
20 changes: 10 additions & 10 deletions e2e/libs/engine/crd.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,15 @@ def get_engine(self, volume_name, node_name):
plural="engines",
label_selector=",".join(label_selector)
)
return api_response

if api_response == "" or api_response is None:
raise Exception(f"failed to get the volume {volume_name} engine")

engines = api_response["items"]
if len(engines) == 0:
logging.warning(f"cannot get the volume {volume_name} engines")

return engines

def delete_engine(self, volume_name, node_name):
if volume_name == "" or node_name == "":
Expand All @@ -38,15 +46,7 @@ def delete_engine(self, volume_name, node_name):
logging.info(
f"delete the volume {volume_name} on node {node_name} engine")

resp = self.get_engine(volume_name, node_name)
assert resp != "", "failed to get engines"

engines = resp['items']
if len(engines) == 0:
logging.warning("cannot find engines")
return

for engine in engines:
for engine in self.get_engine(volume_name, node_name):
engine_name = engine['metadata']['name']
self.obj_api.delete_namespaced_custom_object(
group="longhorn.io",
Expand Down
11 changes: 1 addition & 10 deletions e2e/libs/engine/engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,8 @@ def delete_engine(self, volume_name="", node_name=""):
def get_engine_state(self, volume_name, node_name):
logging(f"Getting the volume {volume_name} engine on the node {node_name} state")

resp = self.get_engine(volume_name, node_name)
if resp == "" or resp is None:
raise Exception(f"failed to get the volume {volume_name} engine")

engines = resp["items"]
if len(engines) == 0:
logging.warning(f"cannot get the volume {volume_name} engines")
return

engines_states = {}
for engine in engines:
for engine in self.engine.get_engine(volume_name, node_name):
engine_name = engine["metadata"]["name"]
engine_state = engine['status']['currentState']
engines_states[engine_name] = engine_state
Expand Down

0 comments on commit 075920e

Please sign in to comment.