Skip to content

Commit

Permalink
Conform to new rancher behavior with backward compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
albinsun committed Feb 26, 2025
1 parent 1a03bde commit 38d9e8c
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 17 deletions.
9 changes: 7 additions & 2 deletions apiclient/harvester_api/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,13 @@ def get_pods(self, name="", namespace=DEFAULT_NAMESPACE):
resp = self._get(path)
return resp.status_code, resp.json()

def get_apps_catalog(self, name="", namespace=DEFAULT_NAMESPACE):
path = f"v1/catalog.cattle.io.apps/{namespace}/{name}"
def get_apps_deployments(self, name="", namespace=DEFAULT_NAMESPACE):
path = f"v1/apps.deployments/{namespace}/{name}"
resp = self._get(path)
return resp.status_code, resp.json()

def get_apps_controllerrevisions(self, namespace=""):
path = f"v1/apps.controllerrevisions/{namespace}"
resp = self._get(path)
return resp.status_code, resp.json()

Expand Down
33 changes: 18 additions & 15 deletions harvester_e2e_tests/integrations/test_upgrade.py
Original file line number Diff line number Diff line change
Expand Up @@ -1079,23 +1079,26 @@ def test_verify_deployed_components_version(self, api_client):
engine_image_version_existed = False
longhorn_manager_version_existed = False

# Get except version from apps.catalog.cattle.io/harvester
code, apps = api_client.get_apps_catalog(name="harvester",
namespace=DEFAULT_HARVESTER_NAMESPACE)
assert code == 200 and apps['type'] != "error", (
f"Failed to get apps.catalog.cattle.io/harvester: {apps['message']}")

# Get except image of kubevirt and longhorn
kubevirt_operator = (
apps['spec']['chart']['values']['kubevirt-operator']['containers']['operator'])
kubevirt_operator_image = (
f"{kubevirt_operator['image']['repository']}:{kubevirt_operator['image']['tag']}")

longhorn = apps['spec']['chart']['values']['longhorn']['image']['longhorn']
# Get expected image of kubevirt
code, app = api_client.get_apps_deployments(name="virt-operator",
namespace=DEFAULT_HARVESTER_NAMESPACE)
assert code == 200, (code, app)
kubevirt_operator_image = app['spec']['template']['spec']['containers'][0]['image']

# Get except image of longhorn
code, apps = api_client.get_apps_controllerrevisions(namespace=DEFAULT_LONGHORN_NAMESPACE)
assert code == 200, (code, apps)

longhorn_images = {
"engine-image": f"{longhorn['engine']['repository']}:{longhorn['engine']['tag']}",
"longhorn-manager": f"{longhorn['manager']['repository']}:{longhorn['manager']['tag']}"
"engine-image": "",
"longhorn-manager": ""
}
for lh_app in longhorn_images:
for app in apps['data']:
if app["id"].startswith(f"{DEFAULT_LONGHORN_NAMESPACE}/{lh_app}"):
longhorn_images[lh_app] = (
app["data"]["spec"]["template"]["spec"]["containers"][0]["image"])
break

# Verify kubevirt version
code, pods = api_client.get_pods(namespace=DEFAULT_HARVESTER_NAMESPACE)
Expand Down

0 comments on commit 38d9e8c

Please sign in to comment.