Skip to content
This repository was archived by the owner on Aug 7, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions src/sunrise6g_opensdk/edgecloud/adapters/i2edge/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,6 @@ def get_edge_cloud_zones(
# ------------------------------------------------------------------------
# Artefact Management (i2Edge-Specific, Non-CAMARA)
# ------------------------------------------------------------------------
# All artefact methods now return Response objects for API consistency

def create_artefact(
self,
Expand Down Expand Up @@ -380,7 +379,7 @@ def get_all_onboarded_apps(self) -> Response:
name=app_metadata.get("appName", ""),
version=app_metadata.get("version", ""),
appProvider=profile_data.get("appProviderId", ""),
# Hardcoding mandatory fields that don't exist in i2Edge
# Hardcoding mandatory fields that doesn't exist in i2Edge
packageType="CONTAINER",
appRepo={"type": "PUBLICREPO", "imagePath": "not-available"},
requiredResources={
Expand Down Expand Up @@ -462,18 +461,22 @@ def deploy_app(self, app_id: str, app_zones: List[Dict]) -> Response:
appId=camara_schemas.AppId(appId),
appInstanceId=camara_schemas.AppInstanceId(app_instance_id),
appProvider=camara_schemas.AppProvider(appProviderId),
status=camara_schemas.Status.instantiating, # 202 means deployment is in progress
status=camara_schemas.Status.instantiating,
edgeCloudZoneId=camara_schemas.EdgeCloudZoneId(zone_id),
)

# CAMARA spec requires appInstances array wrapper
camara_response = {"appInstances": [app_instance_info.model_dump(mode="json")]}
camara_response = app_instance_info.model_dump(mode="json")

# Add mandatory Location header
location_url = f"/appinstances/{app_instance_id}"
camara_headers = {"Content-Type": "application/json", "Location": location_url}

log.info("App deployment request submitted successfully")
return build_custom_http_response(
status_code=i2edge_response.status_code,
content=camara_response,
headers={"Content-Type": "application/json"},
headers=camara_headers,
encoding="utf-8",
url=i2edge_response.url,
request=i2edge_response.request,
Expand Down Expand Up @@ -541,7 +544,7 @@ def get_all_deployed_apps(
),
status=camara_schemas.Status(
camara_status
), # Map the i2Edge "DEPLOYED" status to the CAMARA "ready" status for consistency with CAMARA specifications.
), # FIX: Map DEPLOYED -> ready
edgeCloudZoneId=camara_schemas.EdgeCloudZoneId(
zone_id
), # FIX: Extract from nodeSelector
Expand Down
22 changes: 8 additions & 14 deletions tests/edgecloud/test_e2e.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,26 +176,20 @@ def app_instance_id(edgecloud_client):
deploy_payload = config["APP_DEPLOY_PAYLOAD"]
app_id = deploy_payload["appId"]
app_zones = deploy_payload["appZones"]

# edgecloud_client.deploy_app maps with CAMARA POST /appinstances
response = edgecloud_client.deploy_app(app_id, app_zones)

assert isinstance(response, Response)

# All CAMARA-compliant adapters should return 202 for async deployment
assert response.status_code == 202
assert (
response.status_code == 202
), f"Expected 202, got {response.status_code}: {response.text}"

response_data = response.json()
instance_info = camara_schemas.AppInstanceInfo(**response_data)

# Use CAMARA schema validation for deployment response
assert "appInstances" in response_data
assert isinstance(response_data["appInstances"], list)
assert len(response_data["appInstances"]) > 0

# Validate each app instance with CAMARA schema
for instance_data in response_data["appInstances"]:
camara_schemas.AppInstanceInfo(**instance_data)

# Extract appInstanceId from first instance
app_instance_id = response_data["appInstances"][0].get("appInstanceId")
# Extract appInstanceId from the validated object
app_instance_id = instance_info.appInstanceId.root

assert app_instance_id is not None
yield app_instance_id
Expand Down