Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
Issue-1325: Let OS assign random ports to servers during testing, and… #1336
… let tests get the port of the running server once the OS has assigned a port. Delete PortUtil and similar utilities.
As discussed in #1325, I've updated the tests to let the OS assign ports to test servers, rather than using the PortUtil and various other utilities that were similar.
The method for assigning ports outlined in the issue works everywhere, except for the following two places:
I've not updated the following modules, as they aren't attached to the build. I'm not sure why they aren't deleted to be honest:
I'll be happy to open a PR to delete these modules if they aren't needed.
Other changes here:
I think it would be good to write e.g. a JUnit rule to wrap server creation/destruction, so test writers won't have to remember to call the right test utility methods, and to properly clean up the server. I haven't done it here, since it's a lot of code to update, but it could be a good idea for new test code.
I've run the build a couple of times on a Linux VM, and I'm pretty much only seeing test failures in the JPA server module, and those failures don't seem related to which port the server is running on. I'll raise separate issue to track fixing the failures I saw.
Super cool. Definitely want to review this with a bit more detail a bit later, but one comment:
That clearAllStaticFieldsForUnitTest method may well not be needed any more truthfully. It was added a long time ago, when the FhirContext consumed quite a bit of memory and the tests were running out. It probably makes sense to just remove it at this point...
I wonder how much removing that method would speed up the build...…
On Mon, Jun 10, 2019 at 4:37 PM James Agnew ***@***.***> wrote: Super cool. Definitely want to review this with a bit more detail a bit later, but one comment: Some tests were closing servers in @afterclass <https://github.com/afterclass> methods, while also clearing all static fields in a different @afterclass <https://github.com/afterclass>, using the TestUtil.clearAllStaticFieldsForUnitTest() method That clearAllStaticFieldsForUnitTest method may well not be needed any more truthfully. It was added a long time ago, when the FhirContext consumed quite a bit of memory and the tests were running out. It probably makes sense to just remove it at this point... — You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub <#1336?email_source=notifications&email_token=AANBORVXZKE3LNGQ4EK5LMLPZ23O3A5CNFSM4HWHTI6KYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODXLFATQ#issuecomment-500584526>, or mute the thread <https://github.com/notifications/unsubscribe-auth/AANBORXIZYNCJTGHTCGG2NTPZ23O3ANCNFSM4HWHTI6A> .
jamesagnew left a comment
This is just awesome. I made one comment, regarding adding a test module so that we can avoid adding any new non-test deps to the hapi-fhir-base module. I'm happy to help with that if needed.
Thanks, this seems like a huge improvement!