Ever wanted to brew your beer using microservices? This repository will allow you to do so!
This repository is used throughout the Spring Cloud libraries builds as end to end testing set up. Check Acceptance Tests Readme for more information.
Since pictures say more than words...
Here is the business flow of the app. Below you'll see more detailed explanation with numbers corresponding to the numbers in the diagram
And here additional tech related applications:
Here is the UI
- Go to the presenting service (http://localhost:9991) and order ingredients (1)
- A request from the presenting service is sent to the aggregating service when order is placed (2)
- A "PROCESS-ID" header is set and will be passed through each part of beer brewing
Brewing service contains the following functionalities:
- Service contains a warehouse ("database") where is stores the ingredients
- Basing on the order placed it will contact the Zuul proxy to fetch ingredients (3)
- Once the ingredients have been received an event is emitted (7)
- You have to have all 4 ingredients reach their threshold (1000) to start maturing the beer
- Once the brewing has been started an event is emitted (7)
- Once the threshold is met the application sends a request to the maturing service (8)
- Each time a request is sent to the aggregating service it returns as a response its warehouse state
- Returns a fixed value of ingredients (5)
- It receives a request with ingredients needed to brew a beer
- The brewing process starts thanks to the
Thread.sleepmethod - Once it's done an event is emitted (9)
- And a request to the bottling service is sent with number of worts (10)
- Presenting service is called to update the current status of the beer brewing process
- Waits some time to bottle the beer
- Once it's done an event is emitted (11)
- Presenting service is called to update the current status of the beer brewing process (12)
- Listens to events and stores them in the "database"
- Proxy over the "adapters" to external world to fetch ingredients
- Routes all requests to the respective "ingredient adapter" (4)
- For simplicity we have one ingredient adapter called "ingredients" that returns a stubbed quantity
- Returns back the ingredients to the aggregating (6)
├── acceptance-tests (code containing acceptace-tests of brewery)
├── brewing (service that creates beer - consists of aggregating, maturing, bottling, reporting and ingredients functionalities)
├── common (common code for the services)
├── docker (docker scripts for additional apps - e.g. graphite)
├── config-server (set up for the config server)
├── eureka (Eureka server needed for Eureka tests)
├── git-props (properties for config-server to pick)
├── gradle (gradle related stuff)
├── img (the fabulous diagram of the brewery)
├── presenting (UI of the brewery)
├── zipkin-server (Zipkin Server for Sleuth Stream tests)
├── zookeeper (embedded zookeeper)
└── zuul (Zuul proxy that forwards requests to ingredients)
./gradlew clean build
E.g. brewing module
./gradlew brewing:clean brewing:build
The easiest way is to:
- GO to the cloned
brewerywhere you have therunAcceptanceTests.shscript (which in fact is already a symbolic link toacceptance-tests/scripts/runDockerAcceptanceTests.shfor your convenience) - You can execute that script with such options
-twhat do you want to test (SLEUTH,ZOOKEEPER,CONSUL,SLEUTH,SLEUTH_STREAM)-vin which version of the BOM (defaults toBrixton.BUILD-SNAPSHOT)-hwhere is your docker host? (defaults to '127.0.0.1' - provide your docker-machine host here)-ris brewery repo already in place and needs to be reset? (defaults tonotresetting of repo)-kshould the apps and all running docker containers be killed after the tests are executed? pass-kto turn on (defaults tonotkilling the apps)-nshould the apps and all running docker containers be killed now and nothing else should happen? pass-nto turn on (defaults tonotdoing that)-xshould the apps be booted no tests should be ran? pass-xto turn on (defaults tonotdoing that)-sshould the building of apps be skipped? pass-sto turn on (defaults tono- the apps will be cleaned and built)
- For more options just run
runAcceptanceTests.shwithout any options or with--helpswitch
Once you run the script, the brewery app will be cloned, built with proper lib versions and proper tests will be executed.
You can run this script to have the setup done for you in no time (example for SLEUTH tests execution):
git clone https://github.com/spring-cloud-samples/brewery.git
cd brewery
bash runAcceptanceTests.sh -t SLEUTH
Execute:
bash runAcceptanceTests.sh -x
Execute:
bash runAcceptanceTests.sh -x -t EUREKA
Execute:
bash runAcceptanceTests.sh -t CONSUL -k
I want to run end to end tests of Consul on my docker-machine (ip. 1.2.3.4) and kill all the apps after the tests finish
Execute:
bash runAcceptanceTests.sh -t CONSUL -k -h 1.2.3.4
Execute:
bash runAcceptanceTests.sh -t CONSUL -k -s
Execute:
bash runAcceptanceTests.sh -n
To run a single module just execute (e.g. presenting module):
./gradlew presenting:bootRun -Dspring.profiles.active=dev
The code is ported from https://github.com/uservices-hackathon
The authors of the initial version of the code are:
- Marcin Grzejszczak (marcingrzejszczak)
- Tomasz Szymanski (szimano)


