Skip to content

refactor(uts): share test infra via testFixtures, move objects unit suite into :liveobjects - #1229

Draft
sacOO7 wants to merge 1 commit into
fix/liveobjects-objects-audit-op-handlingfrom
refactor/uts-objects-unit-into-liveobjects
Draft

refactor(uts): share test infra via testFixtures, move objects unit suite into :liveobjects#1229
sacOO7 wants to merge 1 commit into
fix/liveobjects-objects-audit-op-handlingfrom
refactor/uts-objects-unit-into-liveobjects

Conversation

@sacOO7

@sacOO7 sacOO7 commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Summary

Follow-up to the cross-SDK objects audit. Three related changes, bundled because the test move and the production conformance work touch the same suites:

  1. Share the UTS test infra — moved from :uts's src/test into its src/testFixtures variant, so other modules can consume it via testFixtures(project(":uts")).
  2. Relocate the objects UTS unit suite into the :liveobjects module's own test source set, so the internal-graph specs can reach internal members directly (and expand coverage).
  3. Production spec-conformance — op-path returns ObjectUpdate, plus two root-object safeguards.

Based on fix/liveobjects-objects-audit-op-handling (not main).

Related spec

Mirrors the spec changes in ably/specification#512 into the ably-java derived tests and source:

  • RTO27 — objects-data lifecycle on channel state transitions (DETACHED/FAILED clear pooled data without emitting; SUSPENDED retains); new white-box unit test.
  • RTLC9g / RTLM7f — op-path returns the LiveObjectUpdate; the internal-counter/map UTS tests assert the returned update directly.
  • RTO10c1b1 / RTLO4e10 — root object excluded from GC and non-tombstoneable.
  • RTO18d — duplicate-listener handling kept, with the optional note allowing SDKs that de-duplicate to assert call_count == 1.
  • Nested pooled-map coverage in the RTO27 assertions (CodeRabbit follow-up on the JS side, kept in sync).

Changes

1. Test infra → testFixtures

  • 16 infra files (mock WebSocket/HTTP transport, FakeClock, SandboxApp, proxy control) move to uts/src/testFixtures/kotlin/io/ably/lib/uts/infra/ — pure moves, no content change.
  • :uts gains the java-test-fixtures plugin; fixture deps scoped testFixturesApi/testFixturesImplementation.
  • Acyclicity invariant (documented in uts/build.gradle.kts): :liveobjects test → :uts testFixtures → :java, with :uts test → :liveobjects kept testRuntimeOnly. testFixtures must never depend on :liveobjects.

2. Objects UTS unit suite → :liveobjects

  • Suite moves :utsliveobjects/src/test/.../uts/unit/ (package io.ably.lib.liveobjects.uts.unit).
  • Coverage expands with new suites: InternalLiveCounter, InternalLiveMap, ObjectId, ObjectsPool, ParentReferences.
  • runLiveObjectsUnitTests now filters both io.ably.lib.liveobjects.unit.* and io.ably.lib.liveobjects.uts.unit.* — CI coverage preserved, no integration tiers pulled in.
  • Deviations recorded in liveobjects/.../uts/deviations.md (manual's format; S/T shape/typed vocabulary).

3. Production spec-conformance (liveobjects/src/main)

  • Op-path returns ObjectUpdate instead of Boolean (RTLC9g/RTLM7f). The RTO9a2a4 on-ack serial gate now uses !update.noOp, matching the UTS model where result == true ⟺ !update.noop.
  • Root object excluded from GC (RTO10c1b1).
  • Root object rejects tombstone attempts (RTLO4e10).
  • Both safeguards covered by new tests (LiveObjectTombstoneTest).

Verification

  • :liveobjects:runLiveObjectsUnitTests + :uts:runUtsUnitTests — green, unit-only (0 integration tests).
  • checkWithCodenarc checkstyleMain checkstyleTest — green.

Follow-up TODOs (draft — from FUTURE_WORK_UTS_INFRA.md)

Deferred intentionally; do not do speculatively. Trigger = a second infra consumer beyond :liveobjects.

  • Extract shared infra into a dedicated :test-support module (rename pkg io.ably.lib.uts.infraio.ably.lib.testsupport); drop java-test-fixtures from :uts.
  • Add a Kotlin test source set to :java for its UTS-derived tests — guardrail: keep kotlin-stdlib out of :java's main artifact.
  • Decide Chat SDK consumption: in-repo module vs. separate-repo publish/version.
  • Simplify uts-package-mapping.json to one full path per tier (drop testRoot + {root,path} form; simplify resolve_uts.py).

Notes for reviewers

Read as three changes, not move noise — the op-path return and the root-object safeguards are behavioural. FUTURE_WORK_UTS_INFRA.md captures the deferred extraction and its rationale.

…uite into :liveobjects

Three related changes from the cross-SDK objects audit follow-up:

1. Shared UTS test infra (mock transport, FakeClock, SandboxApp, proxy control)
   moves from :uts's src/test to its src/testFixtures variant, so other modules
   can consume it via testFixtures(project(":uts")). Acyclicity invariant
   documented: :liveobjects test -> :uts testFixtures -> :java, with :uts test ->
   :liveobjects kept runtime-only.

2. The objects UTS unit suite moves out of :uts into the :liveobjects module's own
   test source set (package io.ably.lib.liveobjects.uts.unit) so the internal-graph
   specs can reach `internal` members directly. Coverage expands: adds
   InternalLiveCounter/Map, ObjectId, ObjectsPool and ParentReferences suites.
   runLiveObjectsUnitTests now covers both .unit.* and .uts.unit.*.

3. Spec-conformance in production source:
   - op-path applyObject/applyOperation now returns the ObjectUpdate instead of a
     Boolean (RTLC9g/RTLM7f); the RTO9a2a4 on-ack gate uses !update.noOp.
   - root object is excluded from GC (RTO10c1b1) and rejects tombstone attempts
     (RTLO4e10); both covered by new tests.

Deviations recorded in liveobjects/.../uts/deviations.md. Unit suites and the CI
static-analysis gate are green.
@coderabbitai

coderabbitai Bot commented Jul 30, 2026

Copy link
Copy Markdown

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 4854d776-6781-49f8-a8e6-751b07dfe109

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant