Commit 63aa0950 authored by George Papathanail's avatar George Papathanail
Browse files

fix: align ResourceZone with SRM's latest zone model

parent fe9b3d12
Loading
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -110,7 +110,7 @@ class SRMClient:
        if region is not None:
            params["region"] = region
        if status is not None:
            params["status"] = status
            params["state"] = status

        headers = {}
        if x_correlator:
+5 −4
Original line number Diff line number Diff line
@@ -119,16 +119,17 @@ def _parse_storage_mb(value: str) -> int:

def build_edge_cloud_zone(srm_zone: ResourceZone) -> EdgeCloudZone:
    try:
        status = EdgeCloudZoneStatus(srm_zone.status)
        status = EdgeCloudZoneStatus(srm_zone.state)
    except ValueError:
        status = EdgeCloudZoneStatus.UNKNOWN

    location = srm_zone.metadata.location
    return EdgeCloudZone(
        edgeCloudZoneId=UUID(srm_zone.resource_zone_id),
        edgeCloudZoneId=UUID(srm_zone.id),
        edgeCloudZoneName=srm_zone.name,
        edgeCloudZoneStatus=status,
        edgeCloudProvider=srm_zone.provider,
        edgeCloudRegion=srm_zone.location.region if srm_zone.location else None,
        edgeCloudProvider=srm_zone.metadata.provider,
        edgeCloudRegion=location.region if location else None,
    )


+9 −5
Original line number Diff line number Diff line
@@ -96,17 +96,21 @@ class AppDeploymentTranslation(BaseModel):

class ResourceZoneLocation(BaseModel):
    region: str | None = None
    country: str | None = None
    geo: Any | None = None


class ResourceZone(BaseModel):
    resource_zone_id: str
    name: str
    status: str
class ResourceZoneMetadata(BaseModel):
    provider: str
    location: ResourceZoneLocation | None = None


class ResourceZone(BaseModel):
    id: str
    name: str
    state: str
    metadata: ResourceZoneMetadata


class SRMAccelerator(BaseModel):
    type: str
    units: int
+7 −4
Original line number Diff line number Diff line
@@ -22,7 +22,10 @@ from open_exposure_gateway.dependencies import (
    get_publisher,
    get_qod_service,
)
from open_exposure_gateway.domain.edge_application_management import ResourceZone
from open_exposure_gateway.domain.edge_application_management import (
    ResourceZone,
    ResourceZoneMetadata,
)
from tests.conformance.harness import app
from tests.unit.fakes import (
    FakeAppInstanceRepository,
@@ -45,10 +48,10 @@ def service_overrides() -> Generator[None, None, None]:
    # otherwise, which no real provider would ever be.
    srm.zones.append(
        ResourceZone(
            resource_zone_id=str(uuid4()),
            id=str(uuid4()),
            name="conformance-zone",
            status="active",
            provider="conformance-provider",
            state="active",
            metadata=ResourceZoneMetadata(provider="conformance-provider"),
        )
    )
    operation_repo = FakeOperationRepository()
+25 −0
Original line number Diff line number Diff line
@@ -282,6 +282,31 @@ class TestInternalHttpPaths:

        assert calls == [("GET", "/internal/zones")]

    async def test_zone_status_filter_uses_state_query_param(self) -> None:
        """The zone column is `state`, not `status` (srm/persistence-model.md);
        the CAMARA-facing `status` filter must be forwarded as `state` or SRM
        silently ignores it and returns unfiltered results."""
        client = SRMClient.__new__(SRMClient)
        client.base_url = "http://srm:8081"
        client.timeout = 1.0
        recorded_params: dict[str, Any] | None = None

        async def record(
            method: str,
            path: str,
            json: dict[str, Any] | None = None,
            params: dict[str, Any] | None = None,
            headers: dict[str, str] | None = None,
        ) -> Any:
            nonlocal recorded_params
            recorded_params = params
            return []

        client._request = record  # type: ignore[method-assign]
        await client.get_resource_zones(region="athens", status="active")

        assert recorded_params == {"region": "athens", "state": "active"}

    async def test_get_app_parses_srm_catalog_read_shape(self) -> None:
        """SRM's GET /internal/catalog/service-specifications/{id} response
        (ServiceCapabilityRequirementResponseSchema) never carries
Loading