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

fix(connection-model): adjust connection for driver v4 COMPASS-4892 #2289

Merged
merged 15 commits into from
Jun 24, 2021

Conversation

mcasimir
Copy link
Contributor

@mcasimir mcasimir commented Jun 23, 2021

NOTE: please review also packages/connection-model/lib/connect.js which is collapsed.

  • remove gssapiServiceName from the connection string, was already affected by https://jira.mongodb.org/browse/COMPASS-4529 that will have to be fixed in future.
  • do not try to read SSL certs from files and just pass it to the driver instead
  • don't set useNewUrlParser and useUnifiedTopology anymore as those options got removed.
  • remove the adaptation of connection properties from 3.6 to 4.0 in compass shell
  • refactor connection-model connect to use nowadays js instead of async and clean up dead code
  • add a debug of the connection string (redacted) and options used by the driver

Copy link
Contributor

@gribnoysup gribnoysup left a comment

Choose a reason for hiding this comment

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

LGTM, sweet connect method refactor!

Seems like windows is consistently fails to start mongodb server now in one of the tests, could you try starting a patch in Evergreen on Windows to check if that's a GitHub CI issue only? (mongodb-runner was flaky there before, maybe it's just shuffling the test order by removing some of them that increased the flakiness somehow)

Comment on lines +117 to +118
(res) => process.nextTick(() => done(null, ...res)),
(err) => process.nextTick(() => done(err))
Copy link
Contributor

Choose a reason for hiding this comment

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

connect is an async function, wrapping done in nextTick feels a bit redundant here, right?

Copy link
Contributor Author

@mcasimir mcasimir Jun 24, 2021

Choose a reason for hiding this comment

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

Yeah is probably unnecessary, that is to replicate the behaviour of util.callbackify and keep the interface outside 100% as it was. Basically if the handler fails the promise won't catch it and try to call another handler. At the end it doesn't really matter that much, but we would get an unhandled promise rejection instead of an uncaught exception.

@@ -15,7 +15,8 @@
],
"scripts": {
"test-check-ci": "npm run check && npm test",
"pretest": "mongodb-runner install",
"prepretest": "mongodb-runner install",
"pretest": "node ../../scripts/rebuild.js keytar",
Copy link
Contributor

Choose a reason for hiding this comment

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

FWIW I was adding rebuild scripts only in post step for test suites that are running tests with electron runtime. Doesn't hurt to have it here, but might be a bit redundant

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We really need to do the dynamic package that supports both electron and node when we have some time. The problem is that when you "develop" you'd end up mixing npm run start with CMD+R reloads (that does not rebuild) with npm run test, and you'd get basically skewed rebuilds that breaks the execution all the times. Since NAPI won't help till 2024 i guess the only option left is the double build trick that gets selected dinamically.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'd say it really depends on ones workflow then, I don't often jump between running tests and running an app so haven't noticed this an an issue. But to make it clear I am not dismissing this as an issue, let's open a ticket? We can also circumvent this in other ways, it's just if we will start adding rebuild before npm run test in more packages, it might slow down the tests (and CI flows) quite a bit

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh, also will add this to the docs

Copy link
Contributor Author

@mcasimir mcasimir Jun 24, 2021

Choose a reason for hiding this comment

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

yeah i can create a ticket, the rebuild before tests should be a good idea at least for now, i bet there is a way to "detect" if a rebuild is required.

Another thing we could do is "flip" the logic. Right now we build for node and we keep it built for electron only while electron is running. We could do the other way around (build for electron by default) and only rebuild for node while running the tests.

After a while you get used to it but that issue is a bit of a deep thing to circumvent if you get it and don't have enough experience, i'm thinking about external or casual contributors / newbies too, and in general a random source of time wasted.

That's why I feel quite good about that "dynamic" require trick if we could timebox it to 1-2 days and would solve the issue forever. If it takes more or is problematic otherwise we could give up and fallback to rebuilds.

Copy link
Contributor

Choose a reason for hiding this comment

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

Another thing we could do is "flip" the logic. Right now we build for node and we keep it built for electron only while electron is running. We could do the other way around (build for electron by default) and only rebuild for node while running the tests.

We can switch all tests to use electron-mocha as a test runner (a lot of packages are using it already) and then you don't need to rebuild anything back to node env at all I guess

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We can switch all tests to use electron-mocha as a test runner (a lot of packages are using it already) and then you don't need to rebuild anything back to node env at all I guess

Ohh that i would like!! :)

@mcasimir mcasimir merged commit 38ad4e5 into main Jun 24, 2021
@mcasimir mcasimir deleted the COMPASS-4892 branch June 24, 2021 12:43
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.

None yet

2 participants