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

Add ability to immediately start ZK testing server in Curator extension #242

Merged
merged 1 commit into from
Aug 21, 2021

Conversation

sleberknight
Copy link
Member

  • Add two factory methods to CuratorTestingServerExtension that will
    start the Curator testing server immediately (at construction) instead
    of during the JUnit lifecycle (i.e. in beforeAll). These are named
    newStartingImmediately and one will start the testing server on a
    random port and the other takes a specific port to use.
  • Before attempting to start the testing server, check that the port
    is available. Otherwise, when Curator's TestingServer attempts to
    start, it will never complete. The reason is that TestingServer starts
    the server in a new Thread and then blocks (without a timeout) until
    connected. We don't want this behavior in a test extension and instead
    should fail fast.
  • Restructure existing test to verify nested test class behavior
    separate from tests having only top-level tests
  • Add new test specifically to test the immediate start (necessary since
    we have to register the CuratorTestingServerExtension with immediate
    start explicitly)

Test restructuring:

Split the original CuratorTestingServerExtensionTest test into two
separate tests.

The first, CuratorTestingServerExtensionTest, contains only top-level
tests while the second, CuratorTestingServerExtensionNestedTest,
contains both top-level and nested test classes. These two contain
essentially the exact same tests, to ensure we are agnostic of how a
test is structured. Though as noted in extension's Javadoc, nested test
classes will cause us to use multiple testing servers (due to the way
the JUnit lifecycle works when using nested test classes).

Add CuratorTestingServerExtensionImmediateStartTest to explicitly test
the immediate start feature added in this commit.

Closes #239

* Add two factory methods to CuratorTestingServerExtension that will
  start the Curator testing server immediately (at construction) instead
  of during the JUnit lifecycle (i.e. in beforeAll). These are named
  newStartingImmediately and one will start the testing server on a
  random port and the other takes a specific port to use.
* Before attempting to start the testing server, check that the port
  is available. Otherwise, when Curator's TestingServer attempts to
  start, it will never complete. The reason is that TestingServer starts
  the server in a new Thread and then blocks (without a timeout) until
  connected. We don't want this behavior in a test extension and instead
  should fail fast.
* Restructure existing test to verify nested test class behavior
  separate from tests having only top-level tests
* Add new test specifically to test the immediate start (necessary since
  we have to register the CuratorTestingServerExtension with immediate
  start explicitly)

Test restructuring:

Split the original CuratorTestingServerExtensionTest test into two
separate tests.

The first, CuratorTestingServerExtensionTest, contains only top-level
tests while the second, CuratorTestingServerExtensionNestedTest,
contains both top-level and nested test classes. These two contain
essentially the exact same tests, to ensure we are agnostic of how a
test is structured. Though as noted in extension's Javadoc, nested test
classes will cause us to use multiple testing servers (due to the way
the JUnit lifecycle works when using nested test classes).

Add CuratorTestingServerExtensionImmediateStartTest to explicitly test
the immediate start feature added in this commit.

Closes #239
@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

100.0% 100.0% Coverage
0.0% 0.0% Duplication

@chrisrohr chrisrohr merged commit 6c1373a into master Aug 21, 2021
@chrisrohr chrisrohr deleted the 239-immediate-start-CuratorTestingServerExtension branch August 21, 2021 03:50
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.

Allow creating a CuratorTestingServerExtension that starts the testing server in the constructor?
2 participants