This repository has been archived by the owner on Apr 17, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 472
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
health: catch all exceptions for registries
The fact that `RegistryClient.reachable?` might raise an exception is fine in some situations on the API, but it prevents us from knowing from other errors, and it also makes things harder in other places of the code that rely on this check. Hence, let's rescue this exception and return its value properly. Signed-off-by: Miquel Sabaté Solà <[email protected]>
- Loading branch information
Showing
5 changed files
with
39 additions
and
4 deletions.
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
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 |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#!/usr/bin/env bats -t | ||
|
||
load helpers | ||
|
||
function setup() { | ||
__setup minimal | ||
} | ||
|
||
@test "health runs just fine" { | ||
helper_runner curl.rb /api/v1/health | ||
[[ "${lines[-2]}" =~ "database is up-to-date" ]] | ||
[[ "${lines[-2]}" =~ "clair is reachable" ]] | ||
[[ "${lines[-2]}" =~ "registry is reachable" ]] | ||
} | ||
|
||
@test "health reports an invalid registry" { | ||
# Modify the registry hostname to some unknown hostname. | ||
ruby_puts "Registry.get.update(hostname:\"wrong.whatever\")" | ||
|
||
helper_runner curl.rb /api/v1/health | ||
[ $status -eq 1 ] | ||
[[ "${lines[-2]}" =~ "SocketError: connection refused" ]] | ||
} |
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