-
-
Notifications
You must be signed in to change notification settings - Fork 55
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
Container inspect and start + unit tests #56
Conversation
Job #56 is now in scope, role is |
Pull Request Test Coverage Report for Build 84
💛 - Coveralls |
@0crat assign @llorllale |
@amihaiemil This pull request #56 is assigned to @llorllale/z, here is why. The budget is 15 minutes, see §4. Please, read §27 and when you decide to accept the changes, inform @amihaiemil/z (the architect) right in this ticket. If you decide that this PR should not be accepted ever, also inform the architect. |
Manual assignment of issues is discouraged, see §19: -5 points just awarded to @amihaiemil/z |
@llorllale I gave you the REV role. I think this will catch some mistakes I make and also help you learn the architecture better :D |
final HttpResponse response = this.client.execute(start); | ||
final int status = response.getStatusLine().getStatusCode(); | ||
if(status!= HttpStatus.SC_NO_CONTENT) { | ||
throw new IllegalStateException( |
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.
@amihaiemil why not throw IOException
?
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.
@llorllale Because, as I understand it, IOException
should be used only when there are real issues on the network. We have a puzzle for that, we would need an UnexpectedResponseException
, which would provide the status and reason phrase to the user.
So, once that puzzle is fixed, this throw will be changed as well, it won't be IllegalStateException
.
If we simply throw IOException
the user won't know whether there was a real networking issue (e.g. timeout connection) or something else.
What do you think?
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.
@amihaiemil It's a design decision. We are currently not declaring any other checked exception, so I assume this new UnexpectedResponseException
would be runtime? I'd throw an IOException
(or a subclass) because it's already in the API's contract.
I think this is a design call and that you have final say.
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.
@amihaiemil see above
} else { | ||
info = null; | ||
} | ||
inspect.releaseConnection(); |
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.
@amihaiemil see this. I think we should leave a puzzle for abstracting away all the low-level apache http handling stuff into a single point. Something like "Encapsulate HTTP connection/request/response handling" I guess. We'd gain:
- Reduced risk per PR since we won't have to keep implementing/reviewing correct handling of HTTP resources
- Reduce procedural code throughout the code base
@@ -25,12 +25,17 @@ | |||
*/ |
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.
@amihaiemil you're leaving a puzzle for finishing implementation of the rest of the Container
API, but I feel we need another one specifically for adding more test cases for start
and inspect
final HttpResponse response = this.client.execute(start); | ||
final int status = response.getStatusLine().getStatusCode(); | ||
if(status!= HttpStatus.SC_NO_CONTENT) { | ||
throw new IllegalStateException( |
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.
@amihaiemil It's a design decision. We are currently not declaring any other checked exception, so I assume this new UnexpectedResponseException
would be runtime? I'd throw an IOException
(or a subclass) because it's already in the API's contract.
I think this is a design call and that you have final say.
@llorllale I wrote more unit tests and left a puzzle for integration tests. About refactoring of HTTP calls, yes, should be done eventually (I also noticed we already have a little duplication, especially with reading the Json payload). But I am not sure what you have in mind about it, could you open an Issue and explain in more detail? And yes, |
But |
@llorllale Yes, but IOException is another story; as I said above, that is for networking problems. Receiving a They |
info = Json | ||
.createReader(response.getEntity().getContent()).readObject(); | ||
} else { | ||
info = null; |
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.
@amihaiemil why are we returning null
? Why not throw an error? Or why not have the return type be Optional<JsonObject>
?
I really think we should throw an error. At the very least, not return null
in any case.
* RtContainer throws ISE if it cannot start. | ||
* @throws Exception If something goes wrong. | ||
*/ | ||
@Test(expected = IllegalStateException.class) |
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.
@amihaiemil RtContainer.start()
missing tests on receiving 404
and 304
from the docker API
@amihaiemil left a couple more comments
I understood you from the start, we just happen to disagree, but that's OK. |
@llorllale fixed the null; throws ISE same as |
* @throws Exception If something goes wrong. | ||
*/ | ||
@Test(expected = IllegalStateException.class) | ||
public void startsWithServerError() throws Exception { |
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.
@amihaiemil can you remove the Condition
s on the startsWith*Error
tests in order to remove some noise? Those conditions are already tested for in the startsOk
test.
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.
@llorllale haha, you're good at this. Sure :)
@amihaiemil just one more minor comment and we're golden |
@rultor merge it |
@amihaiemil OK, I'll try to merge now. You can check the progress of the merge here |
@amihaiemil Done! FYI, the full log is here (took me 2min) |
Order was finished: +15 points just awarded to @llorllale/z |
The job #56 is now out of scope |
Payment to |
PR for #46 implemented and unit tested Container.inspect and Container.start. Left puzzle for continuing implementation.