Skip to content

Commit

Permalink
Merge pull request #26 from ba-st/fix_healthcheck_docker_endpoints
Browse files Browse the repository at this point in the history
Fix healthcheck docker endpoints
  • Loading branch information
gcotelli authored Feb 18, 2022
2 parents 880a1ba + b107bdf commit a2b0b29
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 19 deletions.
16 changes: 15 additions & 1 deletion compose-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,23 @@ if [[ -z "${GITHUB_HEAD_REF##*/}" ]]; then
else
echo "BRANCH_NAME=${GITHUB_HEAD_REF##*/}" > .env
fi
docker-compose -f api-tests/docker-compose.yml up -d
echo "Building API"
docker-compose -f api-tests/docker-compose.yml build api
echo "Starting Consul Agent"
docker-compose -f api-tests/docker-compose.yml up -d consul-agent
sleep 1
echo "Starting API"
docker-compose -f api-tests/docker-compose.yml up -d api
sleep 10
echo "Testing API"
curl --fail http://localhost:8080/echo/hello
curl --fail http://localhost:8500/v1/agent/services
curl --fail http://localhost:8500/v1/health/checks/echo
HEALTH_STATUS=$(curl -s http://localhost:8500/v1/health/checks/echo | jq '.[0].Status')
echo "$HEALTH_STATUS"
if [ "$HEALTH_STATUS" != '"passing"' ]; then
echo "Error: Echo service is unhealthy" >&2
docker-compose -f api-tests/docker-compose.yml down
exit 1
fi
docker-compose -f api-tests/docker-compose.yml down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ StargateConsulExampleTest >> testPrintHelpOn [
self assert: help equals: ( 'NAME
stargate-consul-example [<1s>] - I provide a RESTful API over HTTP
SYNOPSYS
stargate-consul-example --stargate.public-url=%<publicURL%> --stargate.port=%<port%> --stargate.operations-secret=%<operationsSecret%> --stargate.consul-agent-location=%<consulAgentLocation%>
stargate-consul-example --stargate.public-url=%<publicURL%> --stargate.port=%<port%> --stargate.operations-secret=%<operationsSecret%> --stargate.consul-agent-location=%<consulAgentLocation%> [--stargate.scheme=%<scheme%>]
PARAMETERS
--stargate.public-url=%<publicURL%>
Public URL where the API is deployed. Used to create hypermedia links.
Expand All @@ -89,6 +89,8 @@ PARAMETERS
Secret key for checking JWT signatures.
--stargate.consul-agent-location=%<consulAgentLocation%>
Location of the Consul Agent. Leave empty to disable the plugin.
--stargate.scheme=%<scheme%>
Transport scheme. It''s used to configure Consul HTTP checks. Defaults to http.
ENVIRONMENT
STARGATE__PUBLIC_URL
Public URL where the API is deployed. Used to create hypermedia links.
Expand All @@ -98,6 +100,8 @@ ENVIRONMENT
Secret key for checking JWT signatures.
STARGATE__CONSUL_AGENT_LOCATION
Location of the Consul Agent. Leave empty to disable the plugin.
STARGATE__SCHEME
Transport scheme. It''s used to configure Consul HTTP checks. Defaults to http.
' expandMacrosWith: StargateConsulExample version )
]

Expand Down
20 changes: 14 additions & 6 deletions source/Stargate-Consul/ConsulAwareStargateApplication.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,21 @@ ConsulAwareStargateApplication class >> isAbstract [
^ self = ConsulAwareStargateApplication
]

{ #category : #'*Stargate-Consul' }
{ #category : #private }
ConsulAwareStargateApplication class >> stargateConfigurationParameters [

^ super stargateConfigurationParameters , { MandatoryConfigurationParameter
named: 'Consul Agent Location'
describedBy: 'Location of the Consul Agent. Leave empty to disable the plugin'
inside: self sectionsForStargateConfiguration
convertingWith: #asUrl }
^ super stargateConfigurationParameters , {
(MandatoryConfigurationParameter
named: 'Consul Agent Location'
describedBy:
'Location of the Consul Agent. Leave empty to disable the plugin'
inside: self sectionsForStargateConfiguration
convertingWith: #asUrl).
(OptionalConfigurationParameter
named: 'Scheme'
describedBy: 'Transport scheme. It''s used to configure Consul HTTP checks'
inside: self sectionsForStargateConfiguration
defaultingTo: 'http') }
]

{ #category : #'private - building' }
Expand Down Expand Up @@ -91,6 +98,7 @@ ConsulAwareStargateApplication >> healthCheckEndpoint [
baseUrl := self
withDockerHostnameDo: [ :hostname |
ZnUrl new
scheme: self stargateConfiguration scheme;
host: hostname;
port: self stargateConfiguration port;
yourself
Expand Down
11 changes: 0 additions & 11 deletions source/Stargate-Consul/ConsulAwareStargateApplication.extension.st

This file was deleted.

0 comments on commit a2b0b29

Please sign in to comment.