-
Notifications
You must be signed in to change notification settings - Fork 634
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
Provide exception messages that occurred during stop #1435
Merged
rohanKanojia
merged 5 commits into
fabric8io:master
from
doyleyoung:list_shutdown_errors
Mar 8, 2021
Merged
Changes from 2 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
11f39cf
Provide exception messages that caused stop exceptions, rather than g…
doyleyoung b8fb8c8
Merge branch 'master' into list_shutdown_errors
rohanKanojia ef9801f
Merge branch 'master' into list_shutdown_errors
rhuss 43e6f76
Update test for review comments
doyleyoung 794271a
Merge branch 'list_shutdown_errors' of github.com:doyleyoung/docker-m…
doyleyoung File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,7 @@ | |
import io.fabric8.maven.docker.access.ExecException; | ||
import io.fabric8.maven.docker.config.StopMode; | ||
import io.fabric8.maven.docker.config.VolumeConfiguration; | ||
import io.fabric8.maven.docker.util.GavLabel; | ||
import org.apache.commons.io.IOUtils; | ||
import org.apache.maven.execution.MavenSession; | ||
import org.apache.maven.project.MavenProject; | ||
|
@@ -44,6 +45,7 @@ | |
|
||
import static org.junit.Assert.assertEquals; | ||
import static org.junit.Assert.assertTrue; | ||
import static org.junit.Assert.fail; | ||
|
||
/** | ||
* This test need to be refactored. In fact, testing Mojos must be setup correctly at all. Blame on me that there are so | ||
|
@@ -277,6 +279,38 @@ public void testWithException() throws Exception { | |
runService.stopContainer(container, createImageConfig(SHUTDOWN_WAIT, 0), false, false); | ||
} | ||
|
||
@Test | ||
public void testWithMultipleStopExceptions() throws Exception { | ||
GavLabel testLabel = new GavLabel("Im:A:Test"); | ||
|
||
String firstName = "first-container:latest"; | ||
ImageConfiguration first = new ImageConfiguration(); | ||
first.setName(firstName); | ||
|
||
String secondName = "second-container:latest"; | ||
ImageConfiguration second = new ImageConfiguration(); | ||
second.setName(secondName); | ||
|
||
tracker.registerContainer(firstName, first, testLabel); | ||
tracker.registerContainer(secondName, second, testLabel); | ||
|
||
LogOutputSpecFactory logOutputSpecFactory = new LogOutputSpecFactory(true, true, null); | ||
|
||
new Expectations(){{ | ||
docker.stopContainer(firstName, 0); result = new DockerAccessException("TEST one"); | ||
docker.stopContainer(secondName, 0); result = new DockerAccessException("TEST two"); | ||
}}; | ||
|
||
runService = new RunService(docker, queryService, tracker, logOutputSpecFactory, log); | ||
|
||
try { | ||
runService.stopStartedContainers(false, true, true, testLabel); | ||
fail("Should have thrown exception"); | ||
} catch (DockerAccessException | ExecException e) { | ||
assertEquals(e.getLocalizedMessage(), "(TEST two,TEST one)"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit, these arguments should be in opposite order: |
||
} | ||
} | ||
|
||
@Test | ||
public void testVolumesDuringStart() throws DockerAccessException { | ||
ServiceHub hub = new ServiceHubFactory().createServiceHub(project, session, docker, log, new LogOutputSpecFactory(true, true, null)); | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 maybe we can improve this by using
assertThrows
method like this:WDYT?