Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tests: Don't assert connection key equality #675

Merged
merged 2 commits into from
Dec 2, 2024
Merged

Conversation

lmars
Copy link
Member

@lmars lmars commented Nov 27, 2024

The format of the connection key is not public, and we reserve the right to change it server-side as we please, the only functionality the client expects is that providing the connection key of a previous connection results in the new connection having the same id, so that's all we need to test.

Summary by CodeRabbit

  • New Features

    • Introduced several new integration tests for enhanced validation of the Ably Realtime connection, covering connection state changes, error handling, and reauthorization scenarios.
  • Bug Fixes

    • Improved error handling and assertion checks to ensure correct connection state transitions and management of connection details.
  • Documentation

    • Enhanced clarity in test assertions to better reflect expected outcomes and connection behaviors.

The format of the connection key is not public, and we reserve the right
to change it server-side as we please, the only functionality the client
expects is that providing the connection key of a previous connection
results in the new connection having the same id, so that's all we need
to test.

Signed-off-by: Lewis Marshall <[email protected]>
@lmars lmars requested a review from sacOO7 November 27, 2024 16:01
Copy link
Contributor

coderabbitai bot commented Nov 27, 2024

Walkthrough

The pull request introduces extensive modifications to the integration tests in the ably/realtime_conn_spec_integration_test.go file. Key changes include the addition of new test cases for connection state transitions and error handling, updates to assertions for improved validation accuracy, and enhancements in error handling and connection details management. The modifications ensure that the connection logic adheres to the Ably protocol by accurately reflecting connection behaviors and processing protocol messages.

Changes

File Change Summary
ably/realtime_conn_spec_integration_test.go - Added new test cases for connection state transitions, error handling, and reauthorization scenarios.
- Updated assertions for existing tests to enhance validation accuracy.
- Improved error handling logic for token renewal and connection failures.
- Updated connection details management to ensure correct overwriting of parameters.
- Adjusted protocol message handling to validate correct processing of incoming messages.
- Refactored existing test functions for clarity and maintainability.
- Minor changes in method signatures for existing tests.

Poem

🐇 In the realm of tests, we hop and play,
New cases added, brightening the day.
With errors caught and states in line,
Our connections flourish, robust and fine.
So here's to the changes, a joyful cheer,
For seamless connections, we hold dear! 🎉


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between d5321df and 1159986.

📒 Files selected for processing (1)
  • ably/realtime_conn_spec_integration_test.go (1 hunks)
🔇 Additional comments (1)
ably/realtime_conn_spec_integration_test.go (1)

1950-1950: ⚠️ Potential issue

Fix incorrect assertion comparing connection IDs

The assertion on line 1950 compares prevConnId with c.Connection.ID(), which refers to the original client's connection ID. To verify that the recovered connection has the same ID, you should compare prevConnId with client.Connection.ID().

Apply this diff to fix the assertion:

-    		assert.Equal(t, prevConnId, c.Connection.ID(),
+    		assert.Equal(t, prevConnId, client.Connection.ID(),
     			"expected the same connection")

Likely invalid or redundant comment.


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ 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.
    • Generate unit testing code for this file.
    • 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 generate unit testing code for this file.
    • @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 generate unit testing code.
    • @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.

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 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.

Copy link
Contributor

@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

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between a81632d and d5321df.

📒 Files selected for processing (1)
  • ably/realtime_conn_spec_integration_test.go (1 hunks)

ably/realtime_conn_spec_integration_test.go Outdated Show resolved Hide resolved
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
@lmars
Copy link
Member Author

lmars commented Dec 2, 2024

@sacOO7 please can you review this?

@sacOO7
Copy link
Collaborator

sacOO7 commented Dec 2, 2024

Yes, will take a look soon 👍

@sacOO7
Copy link
Collaborator

sacOO7 commented Dec 2, 2024

It seems, there's one more test consistently failing

TestRealtimePresence_Sync250_RTP4

This test is causing job to run for ~2 hrs
Most of the time, error is

[ErrorInfo :Rate limit exceeded; request rejected (nonfatal); metric = channel.maxRate; interval = 2024-11-27:17:02:8; permitted rate = 250; current rate = 266 code=42910 rate limit exceeded (nonfatal): request rejected (unspecified) statusCode=429] See https://help.ably.io/error/42910

Sometimes
=== RUN TestRealtimePresence_Sync250_RTP4 realtime_presence_integration_test.go:91: Error Trace: realtime_presence_integration_test.go:91 Error: Received unexpected error: [ErrorInfo :Unable to enter member to presence channel; maximum number of 250 members exceeded code=91003 unable to enter presence channel (maximum member limit exceeded) statusCode=400] See https://help.ably.io/error/91003 Test: TestRealtimePresence_Sync250_RTP4 Messages: rg.Wait()=[ErrorInfo :Unable to enter member to presence channel; maximum number of 250 members exceeded code=91003 unable to enter presence channel (maximum member limit exceeded) statusCode=400] See https://help.ably.io/error/91003
For first place, error is
=== RUN TestRealtimePresence_Sync250_RTP4 realtime_presence_integration_test.go:114: Error Trace: realtime_presence_integration_test.go:114 Error: Received unexpected error: clientID="client0" not found in presence map Test: TestRealtimePresence_Sync250_RTP4 Messages: members3: clientID="client0" not found in presence map

@sacOO7
Copy link
Collaborator

sacOO7 commented Dec 2, 2024

We never faced an issue like this before. TestRealtimePresence_Sync250_RTP4 always used to pass.

@lmars
Copy link
Member Author

lmars commented Dec 2, 2024

@sacOO7 ok, but I think that's unrelated to this change, I think we should tackle the issues one at a time, the change here definitely fixes TestRealtimeConn_RTN16 which is failing consistently in main.

@sacOO7
Copy link
Collaborator

sacOO7 commented Dec 2, 2024

Sure, I will approve this PR.
Just that I was worried main will be red once we merge this PR.

Copy link
Collaborator

@sacOO7 sacOO7 left a comment

Choose a reason for hiding this comment

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

LGTM.
Considering we will fix other failing tests soon 👍

@lmars lmars merged commit 70acf92 into main Dec 2, 2024
10 of 15 checks passed
@lmars lmars deleted the fix-connection-id-test branch December 2, 2024 19:32
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.

2 participants