Skip to content

feat: support record and replay websocket requests#13

Merged
hkt74 merged 6 commits intomainfrom
kaituo/ws
Jun 27, 2025
Merged

feat: support record and replay websocket requests#13
hkt74 merged 6 commits intomainfrom
kaituo/ws

Conversation

@hkt74
Copy link
Copy Markdown
Collaborator

@hkt74 hkt74 commented Jun 25, 2025

  1. Update the record file name to prefer read the test name from header, and fallback to the sha256 name
  2. The whole websocket session request and response chunks will be stored in one replay file

hkt74 added 3 commits June 25, 2025 09:48
1. Add a new GetRecordFileName method, prefers the test name from header if present
2. Add magic words used to split websocket client and server message chunks

See example replay file: https://gist.github.com/hkt74/2430f265644dc5d5b62a7fd7ad97f1a6
1. Add a new GetRecordFileName method, prefers the test name from header if present
2. Add magic words used to split websocket client and server message chunks

See example replay file: https://gist.github.com/hkt74/2430f265644dc5d5b62a7fd7ad97f1a6
@hkt74 hkt74 requested a review from amirh June 25, 2025 17:25
@hkt74 hkt74 requested a review from amirh June 25, 2025 21:37
recChunk := string(runes[1:])
if reqChunk != recChunk {
fmt.Printf("input chunk mismatch\n Input chunk: %s\n Recorded chunk: %s\n", reqChunk, recChunk)
return
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Do we need to return an error in this case? how would we know to fail the test?

Copy link
Copy Markdown
Collaborator Author

@hkt74 hkt74 Jun 26, 2025

Choose a reason for hiding this comment

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

Good call, the current behavior test will fail after timeout (5 seconds), the test is awaiting message from the server, while the request mismatch would skip the subsequent message write

To make it fail fast, we probably could write an error message in the session, but it require the test setup to listen to the error message and fail the test.

what do you think I track this as a follow up action? need more time to explore the possible jasmine setup.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Is it possible to close the connection with an error?

@hkt74 hkt74 requested a review from amirh June 26, 2025 03:34
@hkt74 hkt74 changed the title Kaituo/ws feat: support record and replay websocket requests Jun 27, 2025
@hkt74 hkt74 merged commit bee7f68 into main Jun 27, 2025
2 checks passed
@hkt74 hkt74 deleted the kaituo/ws branch June 27, 2025 19:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants