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

rpcsrv: enforce WS connection close on test cleanup #3398

Merged
merged 1 commit into from
Apr 4, 2024

Conversation

AnnaShaleva
Copy link
Member

Do not wait until wsReader routine gracefully finishes its work before WS connection close. Instead, firstly close the connection, and after that wait for proper wsReader exit.

It's a harsh way, but I don't have any other options to try, because wsReader routine hangs on ws.ReadMessage() operation for more than ReadDeadline (more than 5 seconds) during test cleanup which results in the test timeout.

Close #3378.

@AnnaShaleva AnnaShaleva force-pushed the enforce-testws-close branch from fc3e9dc to a1ca8ab Compare April 4, 2024 09:02
Do not wait until wsReader routine gracefully finishes its work before
WS connection close. Instead, firstly close the connection, and after
that wait for proper wsReader exit.

It's a harsh way, but I don't have any other options to try, because
wsReader routine hangs on `ws.ReadMessage()` operation for more than
ReadDeadline (more than 5 seconds) during test cleanup which results in
the test timeout.

Close #3378.

Signed-off-by: Anna Shaleva <[email protected]>
@AnnaShaleva AnnaShaleva force-pushed the enforce-testws-close branch from a1ca8ab to e5c919f Compare April 4, 2024 09:03
@AnnaShaleva AnnaShaleva changed the title rpcsrv: enforce WS connection close on cleanup rpcsrv: enforce WS connection close on test cleanup Apr 4, 2024
@AnnaShaleva
Copy link
Member Author

Let's firstly see if it helps. If not, then I'm likely wrong about the reason of timeout.

Copy link

codecov bot commented Apr 4, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 84.78%. Comparing base (22af33a) to head (e5c919f).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3398      +/-   ##
==========================================
- Coverage   84.78%   84.78%   -0.01%     
==========================================
  Files         331      331              
  Lines       44972    44972              
==========================================
- Hits        38131    38128       -3     
- Misses       5328     5330       +2     
- Partials     1513     1514       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@AnnaShaleva
Copy link
Member Author

Nice, Coverage tests are PASSed, but the Codecove uploading step itself fails:

2024-04-04T09:13:35.8112716Z [2024-04-04T09:13:35.810Z] ['info'] Processing ./coverage.txt...
2024-04-04T09:13:37.9218112Z [2024-04-04T09:13:37.921Z] ['info'] Detected GitHub Actions as the CI provider.
2024-04-04T09:13:37.9218793Z [2024-04-04T09:13:37.921Z] ['verbose'] -> Using the following env variables:
2024-04-04T09:13:37.9219448Z [2024-04-04T09:13:37.921Z] ['verbose']      GITHUB_ACTION: __codecov_codecov-action
2024-04-04T09:13:37.9220105Z [2024-04-04T09:13:37.921Z] ['verbose']      GITHUB_HEAD_REF: enforce-testws-close
2024-04-04T09:13:37.9220708Z [2024-04-04T09:13:37.921Z] ['verbose']      GITHUB_REF: refs/pull/3398/merge
2024-04-04T09:13:37.9221267Z [2024-04-04T09:13:37.921Z] ['verbose']      GITHUB_REPOSITORY: nspcc-dev/neo-go
2024-04-04T09:13:37.9221771Z [2024-04-04T09:13:37.921Z] ['verbose']      GITHUB_RUN_ID: 8552042055
2024-04-04T09:13:37.9222374Z [2024-04-04T09:13:37.921Z] ['verbose']      GITHUB_SERVER_URL: https://github.com
2024-04-04T09:13:37.9223050Z [2024-04-04T09:13:37.922Z] ['verbose']      GITHUB_SHA: b37a86ee3c5b9942e1cd2684ee22051873089a7f
2024-04-04T09:13:37.9223918Z [2024-04-04T09:13:37.922Z] ['verbose']      GITHUB_WORKFLOW: Tests
2024-04-04T09:13:47.9631635Z [2024-04-04T09:13:47.962Z] ['error'] There was an error running the uploader: 
2024-04-04T09:13:47.9632218Z Unable to detect SHA and slug, please specify them manually.
2024-04-04T09:13:47.9632509Z See the help for more details.
2024-04-04T09:13:47.9633208Z [2024-04-04T09:13:47.962Z] ['verbose'] The error stack is: Error: 
2024-04-04T09:13:47.9633721Z Unable to detect SHA and slug, please specify them manually.
2024-04-04T09:13:47.9634396Z See the help for more details.
2024-04-04T09:13:47.9635093Z     at detectProvider (/snapshot/repo/dist/src/helpers/provider.js)
2024-04-04T09:13:47.9636023Z     at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
2024-04-04T09:13:47.9636381Z     at async main (/snapshot/repo/dist/src/index.js)
2024-04-04T09:13:47.9636892Z [2024-04-04T09:13:47.962Z] ['verbose'] End of uploader: 12223 milliseconds
2024-04-04T09:13:47.9788218Z ##[error]Codecov: Failed to properly upload: The process '/home/runner/work/_actions/codecov/codecov-action/v3/dist/codecov' failed with exit code 255

@AnnaShaleva
Copy link
Member Author

OK, it may happen due to the fact that this PR is based on a very fresh master, and Codecov results are not yet properly uploaded for the base. Not critical for us, may happen from time to time.

ws.Close()
<-readerToExitCh
Copy link
Member Author

Choose a reason for hiding this comment

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

The only thing I'm worried about is the fact that we have a similar usage pattern in our WS client. It's not exactly similar, because it's wsWriter goroutine who is responsible for connection closing, but still, I don't quite understand the reason of WS read process hanging given the fact that we have timeout set. But we have tests for WS client closing process, and it passes on Windows, so likely there's no problem in real code.

@roman-khimov roman-khimov merged commit 927dbb6 into master Apr 4, 2024
18 of 20 checks passed
@roman-khimov roman-khimov deleted the enforce-testws-close branch April 4, 2024 10:12
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.

WS-based RPC server tests fail on Windows
3 participants