Skip to content

[ECO-5338] Liveobject unit/integration test setup#1095

Merged
sacOO7 merged 4 commits intomainfrom
chore/liveobject-tests
Jun 6, 2025
Merged

[ECO-5338] Liveobject unit/integration test setup#1095
sacOO7 merged 4 commits intomainfrom
chore/liveobject-tests

Conversation

@sacOO7
Copy link
Collaborator

@sacOO7 sacOO7 commented Jun 5, 2025

  1. Added test specific dependencies, updated junit, added mockk
  2. Added test utils for mocking private classes, fields etc
  3. Updated CI scripts to run liveobject unit/integration tests

Summary by CodeRabbit

Summary by CodeRabbit

  • New Features

    • Introduced structured error and HTTP status code enums for improved error handling.
    • Added utility functions for creating exceptions with detailed error information.
    • Added test utilities for reflection and coroutine-based testing.
    • Provided helpers for mocking channels and managing test sandbox environments.
    • Implemented custom test tasks for running unit and integration tests on live objects.
    • Enhanced error handling in async operations with improved exception creation.
  • Tests

    • Added unit and integration tests to verify the retrieval of live objects from channels.
    • Introduced a shared integration test setup with protocol parameterization and sandbox management.
  • Chores

    • Updated and expanded testing dependencies, including new versions and libraries.
    • Enhanced CI workflows to run additional unit and integration tests for live objects.
    • Added nullability annotations to key method parameters for improved code safety.

sacOO7 added 2 commits June 5, 2025 14:32
1. Added test specific dependencies, updated junit, added mockk
2. Added test utils for mocking private classes, fields etc
3. Added IntegrationTest parameterized class along with sample test
4. Added sample unit test along with mocked realtime channel
1. Updated separate gradlew task for both unit and integration tests
2. Updated check.yml and integration-test.yml file to run respective tests
@coderabbitai
Copy link

coderabbitai bot commented Jun 5, 2025

Walkthrough

This update introduces a comprehensive test infrastructure for the LiveObjects module. It adds new unit and integration tests, test utilities, and custom Gradle test tasks. CI workflows are updated to run these tests, and dependencies for testing and HTTP clients are expanded. Supporting code for error handling and test setup is also included.

Changes

File(s) Change Summary
.github/workflows/check.yml Appended runLiveObjectUnitTests Gradle task to CI check job.
.github/workflows/integration-test.yml Added check-liveobjects job to run runLiveObjectIntegrationTests task.
gradle/libs.versions.toml Updated JUnit version, added MockK and Ktor libraries, and created a test bundle for Kotlin tests.
live-objects/build.gradle.kts Enhanced test configuration, added custom unit/integration test tasks, and updated dependencies.
live-objects/src/main/kotlin/io/ably/lib/objects/ErrorCodes.kt Introduced internal enums for error and HTTP status codes.
live-objects/src/main/kotlin/io/ably/lib/objects/Utils.kt Added utility functions for structured Ably exception creation.
live-objects/src/main/kotlin/io/ably/lib/objects/Helpers.kt Modified error handling in sendAsync to use new ablyException function.
live-objects/src/test/kotlin/io/ably/lib/objects/TestUtils.kt Added reflection and coroutine utilities for testing private members and async code.
live-objects/src/test/kotlin/io/ably/lib/objects/integration/LiveObjectTest.kt Added integration test verifying channel objects getter.
live-objects/src/test/kotlin/io/ably/lib/objects/integration/setup/IntegrationTest.kt Introduced abstract base class for integration tests with setup/teardown and helpers.
live-objects/src/test/kotlin/io/ably/lib/objects/integration/setup/Sandbox.kt Added sandbox test utility for dynamic app creation and client/channel management.
live-objects/src/test/kotlin/io/ably/lib/objects/unit/LiveObjectTest.kt Added unit test verifying channel objects getter using a mock channel.
live-objects/src/test/kotlin/io/ably/lib/objects/unit/TestHelpers.kt Introduced helper to create a mock and spied Realtime channel for unit tests.
lib/src/main/java/io/ably/lib/objects/Adapter.java Added @NotNull annotations to send method parameters.
lib/src/main/java/io/ably/lib/objects/LiveObjectsAdapter.java Added @NotNull annotations to send method parameters in interface.

Sequence Diagram(s)

sequenceDiagram
    participant CI as GitHub Actions
    participant Gradle as Gradle Build
    participant UnitTests as runLiveObjectUnitTests
    participant IntegrationTests as runLiveObjectIntegrationTests

    CI->>Gradle: Run check job
    Gradle->>UnitTests: Execute LiveObject unit tests

    CI->>Gradle: Run check-liveobjects job
    Gradle->>IntegrationTests: Execute LiveObject integration tests
Loading
sequenceDiagram
    participant Test as Test Class
    participant Sandbox as Sandbox Utility
    participant Ably as AblyRealtime
    participant Channel as Channel

    Test->>Sandbox: createInstance()
    Sandbox->>Ably: createRealtimeClient()
    Ably->>Channel: get channel
    Test->>Ably: ensureConnected()
    Ably->>Channel: ensureAttached()
    Test->>Channel: Access objects property
Loading

Assessment against linked issues

Objective Addressed Explanation
Setup LiveObjects unit and integration tests infrastructure (#1089, ECO-5338)
Provide test utilities/helpers for LiveObjects testing (#1089, ECO-5338)
Add or update CI workflows to run LiveObjects tests (#1089, ECO-5338)
Add error handling and utility code to support testing and LiveObjects core (#1089, ECO-5338)

Possibly related PRs

Suggested reviewers

  • ttypic

Poem

In the warren where the tests now hop,
LiveObjects leap—no sign they’ll stop!
Helpers and sandboxes, enums in tow,
Channels and clients in a testing show.
CI now checks with a keen rabbit’s eye—
All is well in the code, oh my!
🐇✨


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2d7f510 and 1a7fafd.

📒 Files selected for processing (6)
  • lib/src/main/java/io/ably/lib/objects/Adapter.java (1 hunks)
  • lib/src/main/java/io/ably/lib/objects/LiveObjectsAdapter.java (1 hunks)
  • live-objects/build.gradle.kts (2 hunks)
  • live-objects/src/test/kotlin/io/ably/lib/objects/integration/setup/IntegrationTest.kt (1 hunks)
  • live-objects/src/test/kotlin/io/ably/lib/objects/integration/setup/Sandbox.kt (1 hunks)
  • live-objects/src/test/kotlin/io/ably/lib/objects/unit/TestHelpers.kt (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (6)
  • lib/src/main/java/io/ably/lib/objects/LiveObjectsAdapter.java
  • lib/src/main/java/io/ably/lib/objects/Adapter.java
  • live-objects/build.gradle.kts
  • live-objects/src/test/kotlin/io/ably/lib/objects/unit/TestHelpers.kt
  • live-objects/src/test/kotlin/io/ably/lib/objects/integration/setup/IntegrationTest.kt
  • live-objects/src/test/kotlin/io/ably/lib/objects/integration/setup/Sandbox.kt
⏰ Context from checks skipped due to timeout of 90000ms (11)
  • GitHub Check: check
  • GitHub Check: build
  • GitHub Check: check-rest-okhttp
  • GitHub Check: check-liveobjects
  • GitHub Check: check-realtime-okhttp
  • GitHub Check: check (19)
  • GitHub Check: check-realtime
  • GitHub Check: check (24)
  • GitHub Check: check (29)
  • GitHub Check: check-rest
  • GitHub Check: check (21)
✨ Finishing Touches
  • 📝 Generate Docstrings

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@github-actions github-actions bot temporarily deployed to staging/pull/1095/features June 5, 2025 09:06 Inactive
@github-actions github-actions bot temporarily deployed to staging/pull/1095/javadoc June 5, 2025 09:13 Inactive
@sacOO7 sacOO7 marked this pull request as ready for review June 5, 2025 09:28
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🧹 Nitpick comments (9)
live-objects/src/test/kotlin/io/ably/lib/objects/unit/TestHelpers.kt (1)

11-31: Add documentation and consider making the test key more explicit.

The mock channel utility function is well-implemented but would benefit from KDoc documentation explaining its purpose and behavior. Additionally, consider making the dummy API key more obviously a test value.

+/**
+ * Creates a mocked Ably Realtime channel for unit testing.
+ * 
+ * @param channelName The name of the channel to create
+ * @param clientId The client ID to use (defaults to "client1")
+ * @return A spied Channel instance with stubbed attach/detach/subscribe methods
+ */
 internal fun getMockRealtimeChannel(channelName: String, clientId: String = "client1"): Channel {
   val client = AblyRealtime(ClientOptions().apply {
     autoConnect = false
-    key = "keyName:Value"
+    key = "test-key:test-value"
     this.clientId = clientId
   })
live-objects/src/test/kotlin/io/ably/lib/objects/TestUtils.kt (1)

1-9: Consider adding file-level documentation for reflection utilities.

This file contains powerful reflection-based utilities that bypass normal access controls. Consider adding KDoc at the file level to document the purpose and security implications of these utilities.

+/**
+ * Test utilities for accessing private members via reflection.
+ * 
+ * These utilities should only be used in test code and provide access to:
+ * - Private fields (get/set)
+ * - Private methods (regular and suspend)
+ * - Polling utilities for async testing
+ * 
+ * Note: These utilities bypass normal access controls and should be used carefully.
+ */
 package io.ably.lib.objects
live-objects/src/test/kotlin/io/ably/lib/objects/unit/LiveObjectTest.kt (2)

9-9: Improve test method naming.

The method name testChannelObjectGetterTest is redundant and unclear. Consider a more descriptive name that follows testing conventions.

-  fun testChannelObjectGetterTest() = runTest {
+  fun `should return non-null objects when accessing channel objects property`() = runTest {

Or using conventional naming:

-  fun testChannelObjectGetterTest() = runTest {
+  fun testChannelObjectsPropertyIsNotNull() = runTest {

9-13: Consider enhancing test coverage.

While this test verifies that channel.objects returns a non-null value, it could be more comprehensive by testing the actual type or functionality of the returned objects.

Consider adding assertions to verify the type or basic functionality:

   @Test
-  fun testChannelObjectGetterTest() = runTest {
+  fun testChannelObjectsPropertyIsNotNull() = runTest {
     val channel = getMockRealtimeChannel("test-channel")
     val objects = channel.objects
     assertNotNull(objects)
+    // Additional assertions could verify the type or basic functionality
+    // assertTrue(objects is ExpectedType)
   }
live-objects/src/main/kotlin/io/ably/lib/objects/ErrorCodes.kt (2)

3-6: Consider removing redundant public modifier.

The public modifier on enum properties is redundant since it's the default visibility in Kotlin enums.

-internal enum class ErrorCode(public val code: Int) {
+internal enum class ErrorCode(val code: Int) {
   BadRequest(40_000),
   InternalError(50_000),
 }

8-11: Consider removing redundant public modifier.

Same as above - the public modifier is redundant for enum properties.

-internal enum class HttpStatusCode(public val code: Int) {
+internal enum class HttpStatusCode(val code: Int) {
   BadRequest(400),
   InternalServerError(500),
 }
live-objects/src/test/kotlin/io/ably/lib/objects/integration/LiveObjectTest.kt (2)

11-11: Improve test method naming for consistency.

Similar to the unit test, the method name testChannelObjectGetterTest is redundant and unclear. Consider using a more descriptive name that clearly indicates this is an integration test.

-  fun testChannelObjectGetterTest() = runTest {
+  fun `should return non-null objects when accessing real channel objects property`() = runTest {

Or using conventional naming:

-  fun testChannelObjectGetterTest() = runTest {
+  fun testRealChannelObjectsPropertyIsNotNull() = runTest {

11-16: Consider adding integration-specific test scenarios.

While the basic null check is valuable, integration tests could verify more complex scenarios like channel state management, real connectivity, or live object synchronization behaviors.

Consider adding tests that verify integration-specific behaviors:

@Test
fun `should handle channel attachment lifecycle with objects`() = runTest {
  val channelName = generateChannelName()
  val channel = getRealtimeChannel(channelName)
  
  // Verify channel is attached and objects are accessible
  assertTrue(channel.state == ChannelState.attached)
  assertNotNull(channel.objects)
  
  // Test object lifecycle or synchronization scenarios
}
live-objects/src/test/kotlin/io/ably/lib/objects/integration/setup/IntegrationTest.kt (1)

90-91: Remove empty tearDownAfterClass method.

The empty tearDownAfterClass method serves no purpose and can be removed to clean up the code.

-  @JvmStatic
-  @AfterClass
-  @Throws(Exception::class)
-  fun tearDownAfterClass() {
-  }
🧰 Tools
🪛 detekt (1.23.8)

[warning] 90-91: This empty block of code can be removed.

(detekt.empty-blocks.EmptyFunctionBlock)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e00af51 and e0b4dcd.

📒 Files selected for processing (12)
  • .github/workflows/check.yml (1 hunks)
  • .github/workflows/integration-test.yml (1 hunks)
  • gradle/libs.versions.toml (3 hunks)
  • live-objects/build.gradle.kts (2 hunks)
  • live-objects/src/main/kotlin/io/ably/lib/objects/ErrorCodes.kt (1 hunks)
  • live-objects/src/main/kotlin/io/ably/lib/objects/Utils.kt (1 hunks)
  • live-objects/src/test/kotlin/io/ably/lib/objects/TestUtils.kt (1 hunks)
  • live-objects/src/test/kotlin/io/ably/lib/objects/integration/LiveObjectTest.kt (1 hunks)
  • live-objects/src/test/kotlin/io/ably/lib/objects/integration/setup/IntegrationTest.kt (1 hunks)
  • live-objects/src/test/kotlin/io/ably/lib/objects/integration/setup/Sandbox.kt (1 hunks)
  • live-objects/src/test/kotlin/io/ably/lib/objects/unit/LiveObjectTest.kt (1 hunks)
  • live-objects/src/test/kotlin/io/ably/lib/objects/unit/TestHelpers.kt (1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (4)
live-objects/src/test/kotlin/io/ably/lib/objects/unit/LiveObjectTest.kt (1)
live-objects/src/test/kotlin/io/ably/lib/objects/unit/TestHelpers.kt (1)
  • getMockRealtimeChannel (11-31)
live-objects/src/test/kotlin/io/ably/lib/objects/integration/LiveObjectTest.kt (1)
live-objects/src/test/kotlin/io/ably/lib/objects/integration/setup/IntegrationTest.kt (2)
  • generateChannelName (53-55)
  • getRealtimeChannel (36-47)
live-objects/src/test/kotlin/io/ably/lib/objects/integration/setup/IntegrationTest.kt (1)
live-objects/src/test/kotlin/io/ably/lib/objects/integration/setup/Sandbox.kt (2)
  • ensureConnected (74-90)
  • ensureAttached (92-107)
live-objects/src/main/kotlin/io/ably/lib/objects/Utils.kt (1)
lib/src/main/java/io/ably/lib/types/ErrorInfo.java (1)
  • ErrorInfo (17-197)
🪛 detekt (1.23.8)
live-objects/src/test/kotlin/io/ably/lib/objects/integration/setup/IntegrationTest.kt

[warning] 90-91: This empty block of code can be removed.

(detekt.empty-blocks.EmptyFunctionBlock)

⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: check-realtime-okhttp
  • GitHub Check: check-realtime
🔇 Additional comments (22)
live-objects/src/test/kotlin/io/ably/lib/objects/TestUtils.kt (1)

10-19: The assertWaiter implementation looks solid.

Good use of coroutines with proper timeout handling and context switching. The 100ms polling interval is reasonable for test scenarios.

.github/workflows/check.yml (1)

22-22: Good integration of LiveObject unit tests into CI pipeline.

The addition of runLiveObjectUnitTests to the gradle command properly integrates the new tests into the existing CI workflow.

.github/workflows/integration-test.yml (1)

94-110: Well-structured integration test job.

The new check-liveobjects job follows the established patterns in the workflow and properly sets up the environment for running LiveObject integration tests. The configuration is consistent with other jobs in the file.

live-objects/src/main/kotlin/io/ably/lib/objects/ErrorCodes.kt (1)

3-11: Well-structured error code definitions.

The enum design provides a clean, type-safe way to handle error codes and HTTP status codes. The use of underscore separators in large numbers follows Kotlin conventions and improves readability.

live-objects/src/test/kotlin/io/ably/lib/objects/integration/LiveObjectTest.kt (1)

8-17: Good integration test structure.

The test correctly extends IntegrationTest and uses real channels via getRealtimeChannel() instead of mocked ones. This provides valuable integration testing coverage complementing the unit tests.

gradle/libs.versions.toml (3)

3-3: Good security update for JUnit.

Updating JUnit from 4.12 to 4.13.2 addresses multiple security vulnerabilities and bug fixes. This is a recommended upgrade.


52-55: Well-structured dependency additions.

The new MockK and Ktor client dependencies are appropriately defined with consistent naming and versioning patterns.


61-61: Comprehensive testing bundle.

The new kotlin-tests bundle effectively groups modern testing dependencies (MockK, coroutines-test, Turbine, Ktor clients) alongside traditional ones (JUnit, nanohttpd), providing a solid foundation for the LiveObjects testing infrastructure.

live-objects/src/main/kotlin/io/ably/lib/objects/Utils.kt (4)

6-14: Well-structured exception utility function.

The function correctly delegates to helper functions and provides sensible defaults. The parameter order and types align well with the ErrorInfo constructor.


16-19: Clean overload for ErrorInfo-based exception creation.

This overload provides a clean interface when you already have an ErrorInfo object, maintaining consistency with the other overload.


27-31: Proper handling of optional cause parameter.

The use of let with Elvis operator correctly handles both cases - with and without a cause throwable. This follows Kotlin idioms well.


33-35: Convenient error factory functions.

These functions provide good defaults for common error scenarios, making the API more user-friendly.

live-objects/build.gradle.kts (3)

16-18: Good dependency organization.

Replacing individual test dependencies with a bundle and adding kotlin("test") provides better dependency management and consistency.


20-32: Comprehensive test configuration with appropriate JVM settings.

The configuration covers essential aspects:

  • Full exception logging for better debugging
  • JVM module opens for reflection access (needed for mocking frameworks)
  • Test lifecycle logging
  • Forcing test execution to ensure fresh runs
  • Smart exclusion of release builds to avoid duplication

34-45: Well-designed test task separation.

The separation between unit and integration tests with appropriate filtering is excellent practice. The exclusion of the base IntegrationTest class from the integration test task prevents running the abstract base class.

live-objects/src/test/kotlin/io/ably/lib/objects/integration/setup/IntegrationTest.kt (3)

36-47: Robust channel management with proper state handling.

The function correctly:

  • Uses getOrPut for efficient client caching
  • Ensures client connection before channel operations
  • Properly attaches and waits for channel attachment
  • Handles the protocol selection based on test parameters

53-55: Effective collision avoidance strategy.

Using UUID for channel names is an excellent approach to prevent test interference and state collisions across different test runs.


57-67: Thorough resource cleanup.

The cleanup logic properly:

  • Removes event listeners from channels
  • Releases channels from the client
  • Closes realtime connections
  • Clears the client map

This prevents resource leaks and test interference.

live-objects/src/test/kotlin/io/ably/lib/objects/integration/setup/Sandbox.kt (4)

25-38: Robust HTTP client configuration with appropriate retry logic.

The retry configuration handles common network issues:

  • Connection timeouts
  • Request timeouts
  • Socket timeouts
  • Non-success HTTP responses
  • Exponential backoff for intelligent retry spacing

57-58: Clarify API key index discrepancy.

The comment mentions using "index 5" but the code uses [0]. This inconsistency should be resolved - either the comment or the code needs correction.

Please verify which index is correct for the API key selection. The comment suggests index 5 provides sufficient permissions, but the implementation uses index 0.


74-90: Excellent async state management.

Both ensureConnected and ensureAttached functions properly:

  • Check current state before waiting
  • Use CompletableDeferred for async coordination
  • Handle both success and failure scenarios
  • Clean up event listeners appropriately
  • Close connections on failure to prevent resource leaks

Also applies to: 92-107


42-46:

Details

❓ Verification inconclusive

Verify relative file path dependency.

The relative path "../lib/src/test/resources/ably-common/test-resources/test-app-setup.json" could be fragile if the working directory changes during test execution.


🏁 Script executed:

#!/bin/bash
# Verify the test-app-setup.json file exists at the expected location
fd -t f "test-app-setup.json" --exec ls -la {}

Length of output: 48


🏁 Script executed:

#!/usr/bin/env bash
# Search for test-app-setup.json anywhere in the repository
find . -type f -name "test-app-setup.json" -print

Length of output: 49


Verify existence and robustness of the relative test resource path

I wasn’t able to locate test-app-setup.json under ../lib/src/test/resources/ably-common/test-resources/ in this module’s codebase—not finding evidence doesn’t confirm it lives there in your monorepo. Please manually verify:

  • That the file actually exists at that relative location when running tests.
  • That your build/test runner’s working directory will always resolve this path correctly.

If this path spans sibling modules, consider loading the JSON as a classpath resource (e.g., via ClassLoader.getResourceAsStream) or centralizing test fixtures to avoid brittle relative paths.

@github-actions github-actions bot temporarily deployed to staging/pull/1095/features June 5, 2025 10:31 Inactive
@github-actions github-actions bot temporarily deployed to staging/pull/1095/javadoc June 5, 2025 10:37 Inactive
@sacOO7 sacOO7 requested a review from ttypic June 5, 2025 14:57
@github-actions github-actions bot temporarily deployed to staging/pull/1095/features June 6, 2025 09:19 Inactive
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (2)
live-objects/src/test/kotlin/io/ably/lib/objects/integration/setup/IntegrationTest.kt (2)

38-52: Fix formatting and consider error handling improvements.

The method logic is sound, but there are a couple of improvements to consider:

  1. Formatting issue: There's an extra space before the dot on line 43.
  2. Error handling: Consider wrapping the channel operations in try-catch blocks for better error reporting.

Apply this diff to fix the formatting:

-      }. apply { ensureConnected() }
+      }.apply { ensureConnected() }

Consider adding error handling for better diagnostics:

 return client.channels.get(channelName, channelOpts).apply {
-  attach()
-  ensureAttached()
+  try {
+    attach()
+    ensureAttached()
+  } catch (e: Exception) {
+    throw Exception("Failed to attach channel '$channelName' for client '$clientId'", e)
+  }
 }

95-96: Remove empty tearDownAfterClass method.

The static analysis tool correctly identified that this empty method serves no purpose and should be removed.

Apply this diff to remove the empty method:

-  @JvmStatic
-  @AfterClass
-  @Throws(Exception::class)
-  fun tearDownAfterClass() {
-  }
🧰 Tools
🪛 detekt (1.23.8)

[warning] 95-96: This empty block of code can be removed.

(detekt.empty-blocks.EmptyFunctionBlock)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 9cac543 and 26d1cdc.

📒 Files selected for processing (4)
  • lib/src/main/java/io/ably/lib/objects/Adapter.java (1 hunks)
  • lib/src/main/java/io/ably/lib/objects/LiveObjectsAdapter.java (1 hunks)
  • live-objects/src/test/kotlin/io/ably/lib/objects/integration/setup/IntegrationTest.kt (1 hunks)
  • live-objects/src/test/kotlin/io/ably/lib/objects/unit/TestHelpers.kt (1 hunks)
✅ Files skipped from review due to trivial changes (2)
  • lib/src/main/java/io/ably/lib/objects/Adapter.java
  • lib/src/main/java/io/ably/lib/objects/LiveObjectsAdapter.java
🚧 Files skipped from review as they are similar to previous changes (1)
  • live-objects/src/test/kotlin/io/ably/lib/objects/unit/TestHelpers.kt
🧰 Additional context used
🪛 detekt (1.23.8)
live-objects/src/test/kotlin/io/ably/lib/objects/integration/setup/IntegrationTest.kt

[warning] 95-96: This empty block of code can be removed.

(detekt.empty-blocks.EmptyFunctionBlock)

⏰ Context from checks skipped due to timeout of 90000ms (11)
  • GitHub Check: check-realtime-okhttp
  • GitHub Check: check-liveobjects
  • GitHub Check: check-rest
  • GitHub Check: check-realtime
  • GitHub Check: check-rest-okhttp
  • GitHub Check: check (19)
  • GitHub Check: check (24)
  • GitHub Check: check (21)
  • GitHub Check: check (29)
  • GitHub Check: check
  • GitHub Check: build
🔇 Additional comments (4)
live-objects/src/test/kotlin/io/ably/lib/objects/integration/setup/IntegrationTest.kt (4)

1-16: LGTM! Clean package structure and appropriate imports.

The package declaration and imports are well-organized and include all necessary dependencies for the integration testing framework.


17-26: Well-structured parameterized test setup.

The use of JUnit's parameterized runner to test both msgpack and json protocols is excellent. The 10-second timeout is reasonable for integration tests, though you may want to consider if this is sufficient for network operations in slower environments.


58-60: LGTM! Effective collision avoidance strategy.

Using UUID for channel name generation is a solid approach to prevent test interference.


62-72: Thorough cleanup implementation.

The cleanup logic properly handles all resources - channels are detached, released, clients are closed, and the map is cleared. This prevents resource leaks between tests.

@github-actions github-actions bot temporarily deployed to staging/pull/1095/javadoc June 6, 2025 09:25 Inactive
@sacOO7 sacOO7 force-pushed the chore/liveobject-tests branch from 26d1cdc to 2d7f510 Compare June 6, 2025 11:30
@sacOO7 sacOO7 requested a review from ttypic June 6, 2025 11:31
@github-actions github-actions bot temporarily deployed to staging/pull/1095/features June 6, 2025 11:31 Inactive
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (2)
live-objects/build.gradle.kts (2)

20-28: Global test configuration is solid
Using tasks.withType<Test>().configureEach for logging, module-opens, and lifecycle logging is a good way to ensure consistency across all Test tasks.

Consider restricting outputs.upToDateWhen { false } to only the integration test task so that unit tests can still benefit from Gradle’s up-to-date checks and improve overall build performance.


30-34: Add group and description to custom test tasks
Registering runLiveObjectUnitTests without a group or description can make it harder for devs to discover.

Example:

tasks.register<Test>("runLiveObjectUnitTests") {
  group = "verification"
  description = "Executes LiveObject unit tests only"
  filter { includeTestsMatching("io.ably.lib.objects.unit.*") }
}
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 26d1cdc and 2d7f510.

📒 Files selected for processing (6)
  • lib/src/main/java/io/ably/lib/objects/Adapter.java (1 hunks)
  • lib/src/main/java/io/ably/lib/objects/LiveObjectsAdapter.java (1 hunks)
  • live-objects/build.gradle.kts (2 hunks)
  • live-objects/src/test/kotlin/io/ably/lib/objects/integration/setup/IntegrationTest.kt (1 hunks)
  • live-objects/src/test/kotlin/io/ably/lib/objects/integration/setup/Sandbox.kt (1 hunks)
  • live-objects/src/test/kotlin/io/ably/lib/objects/unit/TestHelpers.kt (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (5)
  • lib/src/main/java/io/ably/lib/objects/Adapter.java
  • lib/src/main/java/io/ably/lib/objects/LiveObjectsAdapter.java
  • live-objects/src/test/kotlin/io/ably/lib/objects/unit/TestHelpers.kt
  • live-objects/src/test/kotlin/io/ably/lib/objects/integration/setup/IntegrationTest.kt
  • live-objects/src/test/kotlin/io/ably/lib/objects/integration/setup/Sandbox.kt
⏰ Context from checks skipped due to timeout of 90000ms (11)
  • GitHub Check: check-realtime-okhttp
  • GitHub Check: check-liveobjects
  • GitHub Check: build
  • GitHub Check: check (29)
  • GitHub Check: check-rest-okhttp
  • GitHub Check: check (24)
  • GitHub Check: check (19)
  • GitHub Check: check-rest
  • GitHub Check: check (21)
  • GitHub Check: check
  • GitHub Check: check-realtime
🔇 Additional comments (1)
live-objects/build.gradle.kts (1)

16-18: Verify test dependency redundancy
You’ve added both kotlin("test") and libs.bundles.kotlin.tests. Ensure that the bundle in libs.versions.toml doesn’t already include kotlin("test"). If it does, you can safely remove the standalone declaration to avoid duplication.

@github-actions github-actions bot temporarily deployed to staging/pull/1095/javadoc June 6, 2025 11:37 Inactive
Copy link
Contributor

@ttypic ttypic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

1. Fixed liveobject channel options while initializing test channel
2. Fixed test utils as per review comments
3. Fixed adapter NotNull annotation for send method
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.

LiveObjects : Setup liveobject tests

2 participants