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

Include image name in RemoteDockerImage#toString #2558

Merged
merged 14 commits into from Apr 12, 2020

Conversation

bsideup
Copy link
Member

@bsideup bsideup commented Apr 12, 2020

This PR superseeds #2450 with some minor fixes

@bsideup bsideup added this to the next milestone Apr 12, 2020
@bsideup bsideup requested a review from a team April 12, 2020 17:33
@bsideup bsideup changed the title Locationlabs image name in remote docker image to string Include image name in RemoteDockerImage#toString Apr 12, 2020
}

try {
return getImageName().toString();
Copy link
Member

Choose a reason for hiding this comment

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

Why is try necessary after the future is done?

Copy link
Member Author

Choose a reason for hiding this comment

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

you need to get the value from the future. Unless I miss something 😅


@Test
public void toStringContainsOnlyImageName() {
String imageName = Base58.randomString(8).toLowerCase();
Copy link
Member

Choose a reason for hiding this comment

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

Why random string?

Copy link
Member Author

Choose a reason for hiding this comment

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

why not? :)

Copy link
Member

Choose a reason for hiding this comment

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

Because constant example string seems more controlled to me.

@kiview
Copy link
Member

kiview commented Apr 12, 2020

LGTM, just general questions for better understanding.

try {
return getImageName().toString();
} catch (InterruptedException | ExecutionException e) {
return e.getMessage();
Copy link
Member

Choose a reason for hiding this comment

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

This caught me by surprise - in case of a failure, why would we not rethrow? At first sight it seems odd that an exception message could become the 'name' of the image...

Copy link
Member Author

Choose a reason for hiding this comment

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

this is for toString() - it would be weird to rethrow from toString IMO. Instead, we return the message, so that RemoveDockerImage#toString shows that there was an exception

Copy link
Member

Choose a reason for hiding this comment

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

Fair enough - I guess we can't do too much more than this.

Copy link
Member

Choose a reason for hiding this comment

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

Yes, might create some nasty bugs if rethrowing.

@kiview kiview closed this Apr 12, 2020
@kiview kiview reopened this Apr 12, 2020
@kiview
Copy link
Member

kiview commented Apr 12, 2020

Woah sorry, closed by accident from Intellij 😱

@bsideup bsideup merged commit 95c828d into master Apr 12, 2020
@delete-merged-branch delete-merged-branch bot deleted the locationlabs-image_name_in_RemoteDockerImage_toString branch April 12, 2020 18:41
}

@Test
public void toStringWithExceptionContainsOnlyImageNameFuture() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks like this method name doesn't really match the contents anymore

public class RemoteDockerImageTest {

@Test
public void toStringContainsOnlyImageName() {
Copy link
Contributor

Choose a reason for hiding this comment

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

This method name came to be back when there was a choice between imageName and imageNameFuture. Maybe a better name now is toStringWithCompletedImageName ?

@rnorth
Copy link
Member

rnorth commented Apr 13, 2020

This was released in https://github.com/testcontainers/testcontainers-java/releases/tag/1.14.0 🎉

Thanks for the contribution!

quincy pushed a commit to quincy/testcontainers-java that referenced this pull request May 28, 2020
* clean up imports in GenericContainer

* include image name in RemoteDockerImage.toString() to fix testcontainers#2443

* test RemoteDockerImage directly

* handle failures getting the image name

* use completeExceptionally instead of mocking

* tweak assertions

* more assertion tweaks

* add isDone check to RemoteDockerImage.toString -- still figuring out why test fails

* go back to using lombok @tostring, exclude dockerClient while we're at it

* use `Futures.lazyTransform` that also proxies `isDone`

* `imageNameToString` should not be public

* Include the message on error

Co-authored-by: Byron David <david.byron@avast.com>
Co-authored-by: David Byron <dbyron@dbyron.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants