Commit 49dfeca0 authored by Christos Tranoris's avatar Christos Tranoris
Browse files

adding TMF 685 support

parent 2a401479
Loading
Loading
Loading
Loading
+112
Changes for .changelog/20261031_0023_tmf685-facade.md: 112 added lines, 0 removed lines.
Original line number Diff line number Diff line
# TMF685 v5 Resource Pool Management facade

**Date:** 2026-10-31
**Branch:** `tmf685-support`
**Plan:** Epic 30 in `chronos-implementation-plan.md`

## Summary

Chronos now serves a best-effort **TMF685 v5** API next to its native `/api/v1`, over the same
pool, membership and availability services. Classes are generated by Maven from
`src/main/resources/tmfapi/TMF685-Resource_Pool_Management-v5.0.0.oas.yaml`; hand-written mappers
translate them to the Chronos model. The goal is to be as close to the native API as possible,
not full TMF conformance.

- Base path: `/tmf-api/resourcePoolManagement/v5` (behind the Helm prefix: `/chronos-api/tmf-api/...`)
- Swagger UI: `/swagger-ui.html`, group **tmf685** (JSON at `/v3/api-docs/tmf685`); the native API is group **chronos** (`/v3/api-docs/chronos`)
- Security: unchanged. Same JWT roles, enforced by the services through `OperationGate`

## Code generation (`pom.xml`)

`openapi-generator-maven-plugin` 7.14.0, `spring` generator, `interfaceOnly`, `useTags`,
`skipDefaultInterface`, `openApiNullable=false`, Jakarta and Spring Boot 3. Output goes to
`target/generated-sources/tmf685`, in packages `org.etsi.osl.chronos.tmf685.v5.api` and `.model`.
The spec's `Error` model is renamed to `TmfError` so it does not clash with `java.lang.Error`.

## Endpoints

| TMF operation | Chronos call | Notes |
|---|---|---|
| `GET /resourcePool` | `PoolService.list` + memberships | Paged in memory (`offset`/`limit`, `X-Total-Count`/`X-Result-Count`); `fields` ignored |
| `POST /resourcePool` | `PoolService.create` | 201. A non-empty `pooledResource` → 400 (use push) |
| `GET /resourcePool/{id}` | `PoolService.get` + `listByPool` | `pooledResource` = memberships |
| `PATCH /resourcePool/{id}` | `get` → merge → `PoolService.update` | Merge-patch only |
| `DELETE /resourcePool/{id}` | `PoolService.delete` | 204 |
| `POST /resourcePool/{id}/push` | `PoolMembershipService.push` per resource | 201, `done` or `terminatedWithError` with one `errorMessage` per failed resource |
| `POST /resourcePool/{id}/extract` | `listByResource` → `PoolMembershipService.extract` | Same; capacityDemand-only → 501 |
| `POST /resourcePool/{id}/availabilityCheck` | `AvailabilityService.searchAvailability` | One `planned` `capacityOption` per free window |
| task list / retrieve | — | 501 (tasks are not stored) |
| `GET /resourcePoolSpecification[/{id}]` | derived, one per `PoolCategory` | writes → 501 |
| `GET /capacitySpecification[/{id}]` | derived, one per `CapacityUnit.Family` | writes → 501 |
| `/hub`, `/listener/*` | not implemented | not mapped → 404 |

### Field mapping (ResourcePool ↔ PoolEntity)

| TMF | Chronos |
|---|---|
| `id`, `href`, `@type=ResourcePool`, `@baseType=LogicalResource` | `id` (href from the current request, so it honours forwarded headers) |
| `name`, `description` | same |
| `category` + `resourceSpecification` ref | `PoolCategory` name (unknown → 400) |
| `capacity[0].capacityAmount {amount, units}`, `capacityStatus=actual` | `capacityTotal`, `capacityUnit` |
| `relatedParty[{role: owner}]` | `owner` |
| `resourceCharacteristic[]` (`StringCharacteristic`) | `setupDuration`, `teardownDuration`, `maxReservationDuration` (ISO-8601), `tags` (JSON) |
| `pooledResource[]` | memberships (`tmf639Id/Href/Name`), read-only |
| `resourceStatus` | always `available` |
| `startOperatingDate` | `createdAt` |

AvailabilityCheck demand: `applicableTimePeriod[0].fromToDateTime` → horizon; `capacityAmount` →
`CapacityAmount` (only when units are given); characteristic `requestedDuration` (ISO-8601,
defaults to the whole period) and `coverageMode` (default `STRICT`).

### Errors

`edge.rest.Tmf685ExceptionHandler` (scoped to `edge.tmf685`) asks the native
`ProblemDetailExceptionHandler` how it would classify the exception. It then renders TMF
`Error {code, reason, message, status}` as `application/json`, with `code` = Chronos error code,
`reason` = title, `message` = detail, and `status` as a string. The same translation fills
per-resource `errorMessage` entries in Push/Extract.

## Inconsistencies found between TMF685 v5 and Chronos

1. **No reservations in TMF685 v5.** Holds, firm reservations and assessments stay native only. v4 had `Reservation`; v5 does not.
2. **Extract semantics differ.** In TMF, Extract allocates resources or capacity out of the pool. In Chronos it means the resource is no longer managed (membership extract). We map it to the membership extract and reject a capacityDemand-only Extract with 501.
3. **Tasks.** TMF tasks are async and persistent; Chronos runs them synchronously without storing them. POST returns the final state, and list/retrieve return 501.
4. **Multi-resource Push/Extract is not atomic.** Resources processed before a failure stay changed. The task reports them alongside the errors.
5. **Capacity precision and units.** `Quantity.amount` is a `float` while Chronos uses `BigDecimal(20,6)`, so precision is lost. TMF units are free text; Chronos only accepts `CapacityUnit` names.
6. **Per-membership data** (`contributedCapacity`, `setupOverride`, `teardownOverride`) has no slot on `ResourceRef`. Pushed members use the pool defaults.
7. **Buffers, max duration and tags** can only be expressed as `resourceCharacteristic`. Only `StringCharacteristic` is accepted.
8. **Category.** `category` is free text in TMF and the `PoolCategory` enum in Chronos. A Chronos pool has no status of its own, so `resourceStatus` is always `available`.
9. **Update.** TMF uses merge-patch while Chronos does a full PUT; the facade merges onto the stored pool before calling it. A JSON-Patch body cannot bind to `ResourcePool_MVO` and gets 400.
10. **Paging.** The Chronos pool list is not paged, so the facade pages in memory. The `fields` projection is ignored.
11. **Error envelope.** Chronos returns RFC 7807 and TMF returns `Error`. The facade translates; the codes are the Chronos codes plus `NOT_IMPLEMENTED`.
12. **Spec typo.** The listener path `/listener/resourcePoolStateChangeEvent` does not match the schema name `ResourcePoolStatusChangeEvent`. This does not matter here because listeners are not implemented.
13. **`@type` is required.** The generated models are polymorphic on `@type` and mark it as required, so clients must send `"@type"` (e.g. `"ResourcePool"`, `"ResourceRef"`, `"StringCharacteristic"`).

## OpenAPI

`OpenApiConfig` adds two `GroupedOpenApi` beans. The native `globalErrorResponseCustomizer` skips
TMF handlers, so their error responses keep the spec's `Error` schema. The TMF group drops
`ChronosProblemDetail` and the unused native tags. The ungrouped `/v3/api-docs` still lists
both APIs: a global `springdoc.paths-to-match` would override the groups' own filters and empty
the TMF group. `OpenApiGroupsTest` therefore checks that native schemas in the ungrouped document
match the chronos group, which would catch a schema-name collision.

## Architecture

New ArchUnit rule `generatedTmf685ModelStaysInTheFacade`: only `edge.tmf685` and the
`edge.rest` error adapter may depend on `..chronos.tmf685.v5..`.

## Tests

- `edge/tmf685/ResourcePoolMapperTest` (7): every field, absent optionals, FVO → `PoolRequest`, rejections (pooledResource, unknown category or characteristic, non-string characteristic, bad ISO duration), merge-patch keep and override, blank value clears
- `edge/tmf685/ResourcePoolTmfControllerTest` (14, MVC slice, no Docker): retrieve, list paging headers, TMF 404 shape, create, create with pooledResource → 400, patch merge, delete, push with partial failure, push to an unknown pool, extract with partial failure, capacity-only extract → 501, availability check, task retrieve → 501, specifications
- `edge/tmf685/OpenApiGroupsTest` (3, no Docker): the group contents, and native schemas intact in the ungrouped document
- `e2e/Tmf685ResourcePoolRestIT` (3, Docker-gated): create → push → retrieve → availabilityCheck → extract → delete against MySQL, the TMF 404 shape, and 501

`mvn test`: 992 tests, 0 failures, 256 skipped (Docker was not running, so all Testcontainers ITs
were skipped, including the new e2e IT and the existing `OpenApiContractTest`; neither has been run yet).

## Follow-ups

- Run the Docker-gated suite (`Tmf685ResourcePoolRestIT`, `OpenApiContractTest`) on a machine with Docker.
- Helm (`org.etsi.osl.chronos.deploy`): the API is served under `/chronos-api`, so TMF clients use `{rootUrl}/chronos-api/tmf-api/resourcePoolManagement/v5`. No chart change is needed unless a bare `/tmf-api` route is wanted.
+24
Changes for .changelog/20261031_1200_tmf685-api-guide.md: 24 added lines, 0 removed lines.
Original line number Diff line number Diff line
# TMF685 API Guide

**Date:** 2026-10-31
**Branch:** `tmf685-support`

## Summary

Added [tmf685-api-guide.md](tmf685-api-guide.md), a user guide for the TMF685 v5 facade, in the same
style as the REST, JMS and events guides:

1. **Alignment.** Roles; TMF operation ↔ native `/api/v1` endpoint table; field mapping for
   `ResourcePool` ↔ pool and for `AvailabilityCheck` ↔ availability search; TMF `Error` ↔ RFC 7807.
2. **Differences.** The 13 TMF↔Chronos inconsistencies from the
   [facade entry](20261031_0023_tmf685-facade.md), written for API users.
3. **Examples.** curl requests for create, list/retrieve, merge-patch, push (partial failure),
   availabilityCheck, extract, delete, specifications, plus the 404 and 501 errors.

The example responses are built from the mapper code and shortened. They have not yet been
captured from a running instance.

README: new row "Managing pools through TMF685 v5" in the documentation map; the Quick start
TMF685 bullet now links to the guide.

Docs only, no code change.
+14
Changes for .changelog/chronos-implementation-plan.md: 14 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -509,6 +509,20 @@ _Depends on: 7.1, 8.1, 8.2, 11.1_

---

## Epic 30 — TMF685 v5 Resource Pool Management facade

_Depends on: 3.x (pools), 4.x (memberships), 11.x (availability search)_

- [x] 30. Expose a best-effort TMF685 v5 API next to `/api/v1`, generated from `src/main/resources/tmfapi/TMF685-Resource_Pool_Management-v5.0.0.oas.yaml`
  - `openapi-generator-maven-plugin` 7.14.0 (`spring`, interface-only) generates `org.etsi.osl.chronos.tmf685.v5.{api,model}` into `target/generated-sources/tmf685`; `Error` → `TmfError`
  - Hand-written controllers and static mappers in `edge.tmf685` under `/tmf-api/resourcePoolManagement/v5`: `ResourcePool` CRUD (merge-patch), `Push` / `Extract` / `AvailabilityCheck` run synchronously and are not stored (task list/retrieve → 501), read-only derived `ResourcePoolSpecification` (one per `PoolCategory`) and `CapacitySpecification` (one per `CapacityUnit.Family`)
  - `edge.rest.Tmf685ExceptionHandler` reuses the native `ProblemDetailExceptionHandler` classification and renders the TMF `Error` envelope
  - springdoc groups `chronos` (`/api/v1/**`) and `tmf685`; ArchUnit rule keeps the generated model inside the facade
  - New tests: `ResourcePoolMapperTest`, `ResourcePoolTmfControllerTest` (MVC slice), `OpenApiGroupsTest`, `e2e/Tmf685ResourcePoolRestIT` (Docker-gated)
  - _Done when: `/v3/api-docs/tmf685` lists the TMF paths only, and a pool can be created, pushed into, availability-checked, extracted from and deleted through the TMF paths_

---

## Coverage check against the traceability matrix

| Req | Covered by tasks |
+2
Changes for .changelog/index.md: 2 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -89,3 +89,5 @@
| 2026-09-03 | [`/api/v1/modifications` — enforce availability calendar, blackouts & capacity (R16.2)](20260903_2035_modification-calendar-blackout-capacity.md) | Schedule-modification feasibility checked only reservation-vs-reservation overlap + the horizon, so `EXTEND` / `START_MOVE` could push a reservation outside its availability calendar, across a blackout, past the pool's `maxReservationDuration`, or over the capacity ceiling within the new window — all of which the booking and assessment paths already reject (R16.2 specified, unimplemented on the modification path). Added `checkTargetShape(...)` to `ScheduleModificationServiceImpl`: after the existing engine gate passes, the post-modification interval is re-checked against calendar coverage (`AvailabilityService.bookingCoverage`), blackouts (`blockingBlackouts`), `maxReservationDuration`, and `engine.checkConflict` for capacity/overlap — the same primitives the booking path trusts. `EXTEND`/`START_MOVE` only (SHORTEN can only relax all four); calendar+blackout gated by `chronos.calendar.enforce-on-booking`. Rejections carry `CALENDAR` / `BLACKOUT` / `MAX_DURATION_EXCEEDED` / `CAPACITY` / `OVERLAP` in `violatedConstraints`, `suggestedAlternative` null (request property, not a race). No REST/JMS/DTO/schema change; `AvailabilityService` injected in-layer. +7 unit tests (10 existing unchanged via lenient `ALWAYS_OPEN` defaults). 978 tests, 1 pre-existing unrelated failure (`ReleasePathTest.onExternalEnd_overdue_emitsReleaseOverdueEvent`) |
| 2026-10-12 | [Restore the release-overdue alert in `onExternalEnd`](20261012_2328_restore-onexternalend-overdue-alert.md) | Fixes the long-standing `ReleasePathTest.onExternalEnd_overdue_emitsReleaseOverdueEvent` failure. Commit `8c6be7f` had removed the `ReservationReleaseOverdue` emission from `onExternalEnd` without recording it. `ReconciliationJob` does not cover a late release that is confirmed before its next 5-minute scan, so the check (R20.15, R8.4) is restored. 990 tests, 0 failures |
| 2026-10-13 | [Helm deployment pointer + CI comment fix](20261013_0030_helm-deploy-pointer-ci-comment.md) | New sibling repo `org.etsi.osl.chronos.deploy` has a Helm chart for backend + UI next to OpenSlice: shared Artemis and Keycloak, its own MySQL 8.4, `/chronos` and `/chronos-api` subpaths, single replica. Here: README/CLAUDE.md pointers, and the `.gitlab-ci.yml` comment now says the Dockerfile builds from source. Docs only |
| 2026-10-31 | [TMF685 v5 Resource Pool Management facade](20261031_0023_tmf685-facade.md) | Parallel TMF685 v5 API at `/tmf-api/resourcePoolManagement/v5`, generated by `openapi-generator-maven-plugin` from `src/main/resources/tmfapi/` into `target/generated-sources/tmf685`, with hand-written mappers over pools, memberships and availability search. ResourcePool CRUD (merge-patch). Push/Extract/AvailabilityCheck run synchronously and are not stored (task retrieve → 501). Read-only derived Resource/Capacity specifications. TMF `Error` envelope from the native classification. Swagger groups `chronos` / `tmf685`. ArchUnit keeps generated classes in `edge.tmf685`. Lists 13 TMF↔Chronos inconsistencies. +27 tests (24 without Docker). 992 tests, 0 failures, 256 Docker-gated skipped |
| 2026-10-31 | [TMF685 API Guide](20261031_1200_tmf685-api-guide.md) | New user guide [tmf685-api-guide.md](tmf685-api-guide.md): how TMF685 v5 maps to the native API (operations, fields, errors, roles), the 13 differences, and curl examples for every supported operation. Linked from the README documentation map. Docs only |
+386

File added.

Preview size limit exceeded, changes collapsed.

Loading