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

Collect FaaS info during handshake #1156

Merged
merged 9 commits into from
Jul 10, 2023
Merged

Conversation

katcharov
Copy link
Contributor

@katcharov katcharov requested a review from rozza July 3, 2023 22:53
createClientMetadataDocument(applicationName, driverInfo) == createExpectedClientMetadataDocument(applicationName, driverInfo)
}

def 'should create client metadata document and exclude the extra driver info if its too verbose'() {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

These tests have been moved (altered where needed) to the java prose test.

Copy link
Member

Choose a reason for hiding this comment

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

I would recommend converting these tests to Junit tests. Also keeping all the unit / non functional tests here instead of moving to the prose tests.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Does this imply converting the groovy file to java?

I'm unsure about unit vs prose. Perhaps all of these tests should try to send hello at the end? The existing tests seemed to me very similar - like tests that should have been prose tests, but weren't specified whenever this was originally created.

Copy link
Member

Choose a reason for hiding this comment

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

Yes, I would ditch any / all groovy spec tests.

I suppose sending hello isn't required to test the what this class generates which in my mind makes it more of a unit test. However, I have no issue with having them mixed in with prose tests and all being consistent.

Copy link
Member

@rozza rozza Jul 6, 2023

Choose a reason for hiding this comment

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

The issue with sending hello is it should be done sync and async - if the output is tested against.

If we can get this in driver-core that would be ideal.

Copy link
Member

@rozza rozza left a comment

Choose a reason for hiding this comment

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

Looking good some questions, suggestions and nits. :)

String original = System.getProperty(name);
System.setProperty(name, value);
runnable.run();
System.setProperty(name, original);
Copy link
Member

Choose a reason for hiding this comment

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

For safety should this step be done in a try / finally block.


import static java.lang.System.getenv;

public final class TestHelper {
Copy link
Member

Choose a reason for hiding this comment

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

Naming not great / very descriptive

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Does a better name come to mind? It's meant to be fairly generic, containing methods similar to what might be found in a test superclass.

Copy link
Member

Choose a reason for hiding this comment

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

If they are all relating to one thing then I'd use that in the name - eg. EnvironmentTestHelper

Copy link
Contributor Author

@katcharov katcharov Jul 7, 2023

Choose a reason for hiding this comment

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

Turned this into a "WithWrapper" (removed repeat, which was unrelated). I considered creating some sort of junit annotation to remove the indentation, but that seemed more complicated.

createClientMetadataDocument(applicationName, driverInfo) == createExpectedClientMetadataDocument(applicationName, driverInfo)
}

def 'should create client metadata document and exclude the extra driver info if its too verbose'() {
Copy link
Member

Choose a reason for hiding this comment

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

I would recommend converting these tests to Junit tests. Also keeping all the unit / non functional tests here instead of moving to the prose tests.

* See <a href="https://github.com/mongodb/specifications/blob/master/source/mongodb-handshake/handshake.rst#test-plan">spec</a>
* @see ClientMetadataHelperSpecification
*/
public class ClientMetadataHelperProseTest {
Copy link
Member

Choose a reason for hiding this comment

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

Should these tests be in driver-core and not in driver-sync?

As they are not driver specific I think probably not.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah, right - before I settled on CollectionHelper (which I now see is in driver-core), I tried using a MongoClient, but one was only available in driver-sync.

Copy link
Member

@rozza rozza Jul 6, 2023

Choose a reason for hiding this comment

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

If they can all stay in driver-core that would be the ideal.

Copy link
Contributor Author

@katcharov katcharov Jul 7, 2023

Choose a reason for hiding this comment

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

I moved the prose test back to core - do let me know if you think anything else can be in a better place.

@katcharov
Copy link
Contributor Author

@rozza I updated this PR with spec updates (see DRIVERS-2209) that should have been included in the original implementation. I confirmed that 935954b implies that "platform" is moved above env, when adding info in order (as this PR does).

Copy link
Member

@rozza rozza left a comment

Choose a reason for hiding this comment

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

LGTM!

@katcharov katcharov merged commit d65def4 into mongodb:master Jul 10, 2023
@katcharov katcharov deleted the JAVA-4761 branch July 10, 2023 14:35
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