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

test(NODE-6626): implement integration tests for improved client.close() - server-side #4367

Open
wants to merge 1 commit into
base: NODE-6620/sockets
Choose a base branch
from

Conversation

aditi-khare-mongoDB
Copy link
Contributor

@aditi-khare-mongoDB aditi-khare-mongoDB commented Jan 10, 2025

Description

Add server-side resource integration tests for client.close(). These tests will remain skipped until improved client.close() is implemented.

What is changing?

  • Assert server-side resource creation and clean-up upon client.close()
Is there new documentation needed for these changes?

No

What is the motivation for this change?

Improved client.close()

Release Highlight

Double check the following

  • Ran npm run check:lint script
  • Self-review completed using the steps outlined here
  • PR title follows the correct format: type(NODE-xxxx)[!]: description
    • Example: feat(NODE-1234)!: rewriting everything in coffeescript
  • Changes are covered by tests
  • New TODOs have a related JIRA ticket

@aditi-khare-mongoDB aditi-khare-mongoDB changed the base branch from main to NODE-6620/sockets January 10, 2025 22:21
@aditi-khare-mongoDB aditi-khare-mongoDB changed the title test(NODE-6626): Server Resource Integration Tests test(NODE-6626): Implement integration tests for improved client.close() - server-side Jan 10, 2025
@aditi-khare-mongoDB aditi-khare-mongoDB changed the title test(NODE-6626): Implement integration tests for improved client.close() - server-side test(NODE-6626): implement integration tests for improved client.close() - server-side Jan 10, 2025
@aditi-khare-mongoDB aditi-khare-mongoDB force-pushed the NODE-6626/server-side branch 2 times, most recently from ab9c495 to 34ccf67 Compare January 10, 2025 22:59
@aditi-khare-mongoDB aditi-khare-mongoDB marked this pull request as ready for review January 13, 2025 20:01
await client.close();
await client.connect();

// assert clean-up
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Note: We pass all cases already except cursors already.

Copy link
Contributor

Choose a reason for hiding this comment

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

Should the other test cases be unskipped then?

@baileympearson baileympearson self-assigned this Jan 13, 2025
@baileympearson baileympearson added the Primary Review In Review with primary reviewer, not yet ready for team's eyes label Jan 13, 2025
Copy link
Contributor

@baileympearson baileympearson left a comment

Choose a reason for hiding this comment

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

One comment about unskipping tests that pass, and some optional comments. Otherwise LGTM


it('all active server-side cursors are closed by client.close()', async function () {
const getCursors = async () => {
const res = await client
Copy link
Contributor

Choose a reason for hiding this comment

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

optional: this is the sort of thing for which we'd usually use a utilClient. If we use a separate client, we keep the client used for testing separate from the client we use to collect cluster data. It also avoids reopening the client after closing it in the test (line 729).

await client.close();
await client.connect();

// assert clean-up
Copy link
Contributor

Choose a reason for hiding this comment

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

Should the other test cases be unskipped then?

const res = await client
.db()
.admin()
.command({
Copy link
Contributor

Choose a reason for hiding this comment

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

(optional): Neal added runCursorCommand last year to simplify running cursor commands manually:

const result = await client.db('admin').runCursorCommand({ aggregate: .... }).toArray();
return result.filter(
  r => r.type === 'idleCursor' || (r.type === 'op' && r.desc === 'getMore')
);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Primary Review In Review with primary reviewer, not yet ready for team's eyes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants