-
Notifications
You must be signed in to change notification settings - Fork 25
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
Close the HTTP pool when service is stopped. Take 2. #156
Conversation
(I would suggest splitting this up into a bunch of smaller PRs, the PR template and contributing docs don't seem to have anything to do with the functional changes here.) |
Codecov Report
@@ Coverage Diff @@
## master #156 +/- ##
==========================================
Coverage 100.00% 100.00%
==========================================
Files 27 27
Lines 2000 2100 +100
Branches 173 182 +9
==========================================
+ Hits 2000 2100 +100
Continue to review full report at Codecov.
|
Thanks for the work on this. I split it into a single other PR ... see here #157 I will look and try to fix the defect |
I'll have to address backwards incompatibility when I update
#150 is merged, I should do a release.
Again, the incompatibilities are not a huge concern here; I'd much rather land this as a separate change if we can, just to make the review churn manageable. (Although perhaps you are correct that we should do a release with #150 and without this, to provide a smoother upgrade path.) Thank you for working on the acme-v2 branch though! Is it already working for you, or just in progress? |
incompatible with itself and also the docs were never updated so they were still wrong :) |
@glyph thanks for the info. I tried to update the docstring for AutoTLSEndpoint. Can you please take a look and let me know if you find any other errors? Thanks! The acme v2 works for me ... and if you are just using the AcmeIssuingService it should be backward compatible with anyone. txacme.client.Client.fromURL API is not changed.... But I have added txacme.client.Client.start() to match the the new stop() method from here...and starts also takes care of registration and getting a first nonce. The SAN is implemented using CSV names. |
@glyph do you have time to check that the changes are ok now? I want to have this merges as it can help with the future tests that I want to add for ACME v2 support. Thanks! |
@adiroiban I'll try to check it out this weekend; it would be great if you could address whatever's wrong on Travis before then, though! |
I have retried the failings jobs... no is green (sort of :) It looks like one failure is due to a flaky test while the other was a
Thanks! |
@adiroiban I know it's a bit of an artificial metric, but it seems a shame to sacrifice 100% code coverage. Would you mind fixing up the coverage around |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Apparently I can't approve this PR because it's "mine" anyway, but I wanted to ask for getting the test coverage back to 100% anyway. :). A couple of other minor issues inline, but if you can address these i'll merge whether I can 'approve' or not.
@@ -84,7 +81,7 @@ class AutoTLSEndpoint(object): | |||
reactor = attr.ib() | |||
directory = attr.ib( | |||
validator=lambda inst, a, value: check_directory_url_type(value)) | |||
client_creator = attr.ib() | |||
client = attr.ib() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would you consider putting a validator in here, to make it easier for folks to find the place where they need to update their code? In the absence of proper type checking, it would be easy for anyone invoking this to pass the wrong thing, and the error wouldn't be reported until later. I know we don't have a strict Twisted-style compat policy here, but it would still be nice.
@@ -0,0 +1,4 @@ | |||
INCOMPATIBLE CHANGE: txacme.service.AcmeIssuingService.stopFactory nows | |||
closes the persisted HTTP client connections. | |||
This is done to bring the in a state similar to the one before calling |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What does "bring the in" mean here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that the last sentence can be removed.
@@ -19,6 +21,24 @@ | |||
from txacme.util import clock_now, generate_private_key | |||
|
|||
|
|||
class TXACMETestCase(TestCase): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you change this from a superclass into a function?
Rather than inheriting a tearDown
, which can be quite challenging and difficult to correctly inherit and compose, you could make it work like this:
def cancelDelayedCallsAtExit(testCase):
def cancelCalls():
...
testCase.addCleanup(cancelCalls)
This avoids having a big ball of random utility functionality accrete around all the tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In fact, I think you can just use AsynchronousDeferredRunTest
; add run_tests_with = AsynchronousDeferredRunTest
to the test cases needing this.
See https://testtools.readthedocs.io/en/latest/twisted-support.html#running-tests-in-the-reactor and https://github.com/testing-cabal/testtools/blob/209c1bf7618541f7b9a9e01798ef0588658d6ab1/testtools/twistedsupport/_runtest.py#L452
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Happy to use a function... but the idea is that we want all tests to be executed with this check..and to make sure you don't forget to enable this check.
I agree that setUp / tearDown inheritance can be complicated, but at the same time I think that we should enforce that this check is called for all tests.
If we make the check optional, people might forget to enable it for the tests
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's equally possible to forget to inherit from the test class though; like it's literally the same number of modified lines of code. (one per class
statement or one per setUp
method).
However, there are other extension mechanisms we could use for this: the test_suite
hook for example?
@@ -19,6 +21,24 @@ | |||
from txacme.util import clock_now, generate_private_key | |||
|
|||
|
|||
class TXACMETestCase(TestCase): | |||
""" | |||
Common code for all tests for the txacme project. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I definitely don't want all the tests in the whole project to have special nonstandard behavior :)
src/txacme/test/test_client.py
Outdated
@@ -344,6 +344,7 @@ def test_unexpected_update(self): | |||
self.assertThat( | |||
client.register(reg2), | |||
failed_with(IsInstance(errors.UnexpectedUpdate))) | |||
succeeded(client.stop()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This constructs a matcher then does nothing with it; I think you want an assertThat
call here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
True. Thanks.
@adiroiban any chance you'll have some time to work on this soon? |
I will not have time to work on this anytime soon. Feel free to continue the work. I am using the code from this branch https://github.com/twisted/txacme/tree/151-acme-v2 and it works for me. |
and hey it looks like stop() didn't actually work right due to the .called check
I am going to just land this because we need to get v2 out for this to be useful at all, now that the LE endpoints have shut down new registrations and are starting brownouts. |
I am sorry that I was not able to create a proper pull request. I had the same issue that v2 should be delivered ASAP, so I went ahead and implemented txacme with v2 without eliot and with stdlib unit tests. |
Scope
This tries to fixes #86
When the service is stopped, it should automatically clean the resource and not left files opened or connections openend.
In Take1 the #154 regression was introduced.
Obviously there was lots of great stuff in code I had to revert out, so we should probably take a second crack at this.
This is the take 2 of #140