Skip to content

Commit

Permalink
[#3] WIP on Eureka first
Browse files Browse the repository at this point in the history
  • Loading branch information
marcingrzejszczak committed Dec 22, 2015
1 parent d216039 commit cbbd178
Show file tree
Hide file tree
Showing 16 changed files with 94 additions and 18 deletions.
3 changes: 2 additions & 1 deletion acceptance-tests/scripts/runDockerAcceptanceTests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -132,10 +132,11 @@ if [[ "${TESTS_PASSED}" == "yes" ]] ; then
exit 0
else
echo -e "\n\nTests failed..."
NUMBER_OF_LINES_TO_LOG=500
docker ps | sed -n '1!p' > /tmp/containers.txt
while read field1 field2 field3; do
echo -e "\n\nContainer name [$field2] with id [$field1] logs: \n\n"
docker logs -t $field1
docker logs --tail=$NUMBER_OF_LINES_TO_LOG -t $field1
done < /tmp/containers.txt
exit 1
fi
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@ class SleuthBreweryAcceptanceSpec extends AbstractBreweryAcceptanceSpec {
and: 'entry will be present in Zipkin'
entry_for_trace_id_is_present_in_Zipkin(referenceProcessId)
where:
// will add FEIGN once REST_TEMPLATE tests stabilize
communicationType << [CommunicationType.REST_TEMPLATE]
communicationType << [CommunicationType.REST_TEMPLATE, CommunicationType.FEIGN]
referenceProcessId = new JdkIdGenerator().generateId().toString()
}

Expand Down
12 changes: 12 additions & 0 deletions aggregating/src/main/resources/bootstrap-eureka.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#spring.cloud.config.failFast: true
spring:
cloud:
config:
discovery:
enabled: true
serviceId: configserverrr
eureka:
instance:
leaseRenewalIntervalInSeconds: 10
client:
registryFetchIntervalSeconds: 5
6 changes: 6 additions & 0 deletions bottling/src/main/resources/bootstrap-eureka.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#spring.cloud.config.failFast: true
spring:
cloud:
config:
discovery:
enabled: true
4 changes: 3 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,8 @@ configure(subprojects - techProjects) {

compile "org.springframework.boot:spring-boot-starter-web"
compile "org.springframework.boot:spring-boot-starter-actuator"
compile "org.springframework.boot:spring-boot-starter-aop"
compile 'org.springframework.retry:spring-retry'
compile "org.springframework:spring-context-support"
compile 'com.fasterxml.jackson.core:jackson-databind'
if (!whatToTest('CONSUL') && !whatToTest('EUREKA')) {
Expand All @@ -171,7 +173,7 @@ configure(subprojects - techProjects) {
}

wrapper {
gradleVersion '2.9'
gradleVersion '2.10'
}

bootRun {
Expand Down
1 change: 1 addition & 0 deletions config-server/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
dependencies {
compile "org.springframework.cloud:spring-cloud-config-server"
if (whatToTest('EUREKA')) { compile "org.springframework.cloud:spring-cloud-starter-eureka" }
}

createDockerTaskWithPort(8888)
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package io.spring.cloud.samples.brewery.configserver;

import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile;

@Configuration
@Profile("eureka")
@EnableDiscoveryClient
public class EurekaConfiguration {
}
12 changes: 12 additions & 0 deletions config-server/src/main/resources/application-eureka.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
eureka:
client:
registerWithEureka: true
fetchRegistry: true
serviceUrl:
defaultZone: http://discovery:8761/eureka/
instance:
preferIpAddress: true

ribbon:
eureka:
enabled: true
2 changes: 2 additions & 0 deletions config-server/src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,7 @@ spring:
git:
uri: https://github.com/spring-cloud-samples/brewery.git
searchPaths: git-props
application:
name: configserverrr

spring.zipkin.enabled: false
10 changes: 9 additions & 1 deletion docker-compose-EUREKA.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,21 @@ PORT_TO_CHECK=8888

docker-compose -f $dockerComposeFile up -d configserver

echo "Waiting for the Config Server app to boot for [$(( WAIT_TIME * RETRIES ))] seconds"
echo -e "\n\nWaiting for the Config Server app to boot for [$(( WAIT_TIME * RETRIES ))] seconds"
for i in $( seq 1 "${RETRIES}" ); do
sleep "${WAIT_TIME}"
curl -m 5 "${HEALTH_HOST}:${PORT_TO_CHECK}/health" && READY_FOR_TESTS="yes" && break
echo "Fail #$i/${RETRIES}... will try again in [${WAIT_TIME}] seconds"
done

echo -e "\n\nChecking for the presence of config server in Service Discovery for [$(( WAIT_TIME * RETRIES ))] seconds"
for i in $( seq 1 "${RETRIES}" ); do
sleep "${WAIT_TIME}"
curl -m 5 http://localhost:8888/health | grep "\"services\":\[\"configserverrr\"\]" && READY_FOR_TESTS="yes" && break
echo "Fail #$i/${RETRIES}... will try again in [${WAIT_TIME}] seconds"
done


if [[ "${READY_FOR_TESTS}" == "no" ]] ; then
echo "Config server failed to start..."
exit 1
Expand Down
16 changes: 4 additions & 12 deletions docker-compose-EUREKA.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,70 +2,62 @@ aggregating:
build: aggregating/build/docker
environment:
spring.profiles.active: eureka
spring.cloud.config.uri: http://configserver:8888
links:
- discovery
- configserver
ports:
- 9992:9992

maturing:
build: maturing/build/docker
environment:
spring.profiles.active: eureka
spring.cloud.config.uri: http://configserver:8888
links:
- discovery
- configserver
ports:
- 9993:9993

bottling:
build: bottling/build/docker
environment:
spring.profiles.active: eureka
spring.cloud.config.uri: http://configserver:8888
links:
- discovery
- configserver
ports:
- 9994:9994

presenting:
build: presenting/build/docker
environment:
spring.profiles.active: eureka
spring.cloud.config.uri: http://configserver:8888
links:
- discovery
- configserver
ports:
- 9991:9991

zuul:
build: zuul/build/docker
environment:
spring.profiles.active: eureka
spring.cloud.config.uri: http://configserver:8888
links:
- discovery
- configserver
ports:
- 9995:9995

ingredients:
build: ingredients/build/docker
environment:
spring.profiles.active: eureka
spring.cloud.config.uri: http://configserver:8888
links:
- discovery
- configserver
ports:
- 9996:9996

configserver:
build: config-server/build/docker
environment:
spring.profiles.active: eureka
links:
- discovery
ports:
- 8888:8888

Expand Down
8 changes: 7 additions & 1 deletion eureka/src/main/resources/bootstrap.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
spring:
application:
name: discovery
name: discovery

eureka:
instance:
leaseRenewalIntervalInSeconds: 10
client:
registryFetchIntervalSeconds: 5
6 changes: 6 additions & 0 deletions ingredients/src/main/resources/bootstrap-eureka.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#spring.cloud.config.failFast: true
spring:
cloud:
config:
discovery:
enabled: true
6 changes: 6 additions & 0 deletions maturing/src/main/resources/bootstrap-eureka.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#spring.cloud.config.failFast: true
spring:
cloud:
config:
discovery:
enabled: true
6 changes: 6 additions & 0 deletions presenting/src/main/resources/bootstrap-eureka.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#spring.cloud.config.failFast: true
spring:
cloud:
config:
discovery:
enabled: true
6 changes: 6 additions & 0 deletions zuul/src/main/resources/bootstrap-eureka.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#spring.cloud.config.failFast: true
spring:
cloud:
config:
discovery:
enabled: true

0 comments on commit cbbd178

Please sign in to comment.