Skip to content

Refactor ExtensionsRunner test code out of production source tree#172

Merged
dbwiddis merged 2 commits intoopensearch-project:mainfrom
roulpriya:Issue-171
Oct 10, 2022
Merged

Refactor ExtensionsRunner test code out of production source tree#172
dbwiddis merged 2 commits intoopensearch-project:mainfrom
roulpriya:Issue-171

Conversation

@roulpriya
Copy link
Copy Markdown
Contributor

Description

Remove ExtensionsRunner constructor which was used only in tests

Issues Resolved

Closes #171

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

Copy link
Copy Markdown
Member

@dbwiddis dbwiddis 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 so far!

@dbwiddis dbwiddis added the hacktoberfest Global event that encourages people to contribute to open-source. label Oct 9, 2022
@roulpriya roulpriya force-pushed the Issue-171 branch 2 times, most recently from 03c9cac to d75df92 Compare October 10, 2022 08:01
super.setUp();
this.extensionsRunner = new ExtensionsRunner();
this.extensionsRunner = new ExtensionsRunnerForTest();
this.initialTransportService = extensionsRunner.extensionTransportService;
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The constructor of ExtensionRunner creates an instance of TransportService which listens a port in the background.

Tests further use setExtensionTransportService to replace the created instance with a mock to use in testing. The original instance becomes unreachable and our tearDown cannot stop it, which causes the rest of the tests to fail due to the port being already in use. Hence, this hack.

IMO, we should pass TransportService as a constructor parameter and not instantiate inside.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

At this point, let's "hack" as needed to get this merged.

I agree with you and have questioned how we've tracked the transport service from some of the initial PRs. I'm not sure putting it in the constructor is the best solution but we do need something better than what we have.

We do have a future requirement to gracefully handle disconnections/reconnections (hot plugin, etc.) and I think handling these will definitely need to be part of that functionality as well.

@roulpriya roulpriya changed the title [WIP] Refactor ExtensionsRunner test code out of production source tree Refactor ExtensionsRunner test code out of production source tree Oct 10, 2022
@roulpriya roulpriya marked this pull request as ready for review October 10, 2022 08:21
@roulpriya roulpriya requested a review from a team October 10, 2022 08:21
Copy link
Copy Markdown
Member

@dbwiddis dbwiddis left a comment

Choose a reason for hiding this comment

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

Code changes look good! Thank you for your contribution and your patience in dealing with our early-stage code!

Please undo the whitespace changes in build.gradle and add the DCO signoff and I'll approve this.

* @throws IOException if the runner failed to read settings or API.
*/
private ExtensionsRunner(Extension extension) throws IOException {
protected ExtensionsRunner(Extension extension) throws IOException {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Note to self/other reviewers: package private would be sufficient for tests if we only want to make ExtensionsRunner extendable for testing. However I think it's reasonable to think any user might wish to create a simple anonymous extension (possibly for their own testing!) so I like using protected here.

Signed-off-by: Priyambada Roul <roulpriyambada@gmail.com>
dbwiddis
dbwiddis previously approved these changes Oct 10, 2022
joshpalis
joshpalis previously approved these changes Oct 10, 2022
Signed-off-by: Daniel Widdis <widdis@gmail.com>
@dbwiddis dbwiddis dismissed stale reviews from joshpalis and themself via 1cb21b5 October 10, 2022 16:54
@Override
@AfterEach
public void tearDown() throws Exception {
super.tearDown();
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for adding the tearDown. This will definitely avoid the bind connection error.

@dbwiddis dbwiddis requested a review from joshpalis October 10, 2022 17:02
@@ -0,0 +1,32 @@
package org.opensearch.sdk;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This is great!
It sets up our initial framework for tests going forward.

Copy link
Copy Markdown
Member

@saratvemulapalli saratvemulapalli left a comment

Choose a reason for hiding this comment

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

Thanks @roulpriya for the changes!

@dbwiddis dbwiddis merged commit 279e674 into opensearch-project:main Oct 10, 2022
kokibas pushed a commit to kokibas/opensearch-sdk-java that referenced this pull request Mar 17, 2023
…t#172)

Signed-off-by: Priyambada Roul <roulpriyambada@gmail.com>
caokyhieu pushed a commit to caokyhieu/opensearch-sdk-java that referenced this pull request Aug 15, 2025
…t#172)

Signed-off-by: Priyambada Roul <roulpriyambada@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

hacktoberfest Global event that encourages people to contribute to open-source.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE] Refactor ExtensionsRunner test code out of production source tree

5 participants