Code Monkey home page Code Monkey logo

brewery's Introduction

Build Status

Brewery

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.

How does the brewery work?

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

Diagram

And here additional tech related applications:

Diagram

And here how the flow of apps look like (screenshot taken from Zipkin)

Diagram

Presenting service (point of entry to the system)

Here is the UI

UI

  • Go to the presenting service (http://localhost:9991 or to https://brewery-presenting.${PCF_DOMAIN}) and order ingredients. PCF_DOMAIN is the domain set to your CF installation. If you deploy to Pivotal Web Services it will default to cfapps.io (so the link for PWS will be https://brewery-presenting.cfapps.io) (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

Brewing service contains the following functionalities:

Aggregating

  • Service contains a warehouse ("database") where is stores the ingredients
  • Spring Cloud Gateway will be used as proxy (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

Maturing

  • It receives a request with ingredients needed to brew a beer
  • The brewing process starts thanks to the Thread.sleep method
  • 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

Bottling

  • 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)

Ingredients Service

  • Returns a fixed value of ingredients (5)

Reporting Service

  • Listens to events and stores them in the "database"

Proxy (Spring Cloud Gateway)

  • 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)

Project structure

├── acceptance-tests (code containing acceptace-tests of brewery)
├── brewing          (service that creates beer - consists of aggregating, maturing, bottling 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)
├── img              (the fabulous diagram of the brewery)
├── ingredients      (service returns ingredients)
├── presenting       (UI of the brewery)
├── reporting        (service that listens to events)
└── proxy            (Spring Cloud Gateway that forwards requests to ingredients)

How to build it?

./mvnw clean install

How to build one module?

E.g. brewing module

./mvnw clean install -pl brewing

How to run it?

Prerequisite

YOU NEED DOCKER-COMPOSE INSTALLED TO RUN THE BREWERY ON YOUR LOCAL MACHINE!

Running Brewery

The easiest way is to:

  • GO to the cloned brewery where you have the runAcceptanceTests.sh script
  • For all options just run runAcceptanceTests.sh without any options or with --help switch

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

Examples

I want to just run all the apps and have fun

Execute:

bash runAcceptanceTests.sh -x

I want to just run all the apps with Eureka and have fun

Execute:

bash runAcceptanceTests.sh -x -t EUREKA

I want to run end to end tests of Consul and kill all the apps after the tests finish

Execute:

bash runAcceptanceTests.sh -t CONSUL -ke

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 -ke -h 1.2.3.4

I want to run end to end tests of Consul, kill all the apps after the tests finish and skip build

Execute:

bash runAcceptanceTests.sh -t CONSUL -ke -s

I just want to kill all the brewery related apps

Execute:

bash runAcceptanceTests.sh -n

How to run a single module?

To run a single module just execute (e.g. presenting module):

./mvnw spring-boot:run -Dspring.profiles.active=dev -pl presenting

Authors

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)

brewery's People

Contributors

chrisjs avatar jonatan-ivanov avatar marcingrzejszczak avatar olgamaciaszek avatar spencergibb avatar wybczu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

brewery's Issues

BYOZ (bring your own zipkin)

I'd like to use brewery as a load producer on an existing zipkin setup. For simplicitly, it could be localhost, but anyway would be nice if there's a way to opt-out of brewery starting a zipkin.

when i run local in eclipse,

Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [org.springframework.cloud.sleuth.Tracer] found for dependency [org.springframework.cloud.sleuth.Tracer]: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {}
at org.springframework.beans.factory.support.DefaultListableBeanFactory.raiseNoMatchingBeanFound(DefaultListableBeanFactory.java:1406) ~[spring-beans-4.3.2.RELEASE.jar:4.3.2.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1057) ~[spring-beans-4.3.2.RELEASE.jar:4.3.2.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1019) ~[spring-beans-4.3.2.RELEASE.jar:4.3.2.RELEASE]
at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:835) ~[spring-beans-4.3.2.RELEASE.jar:4.3.2.RELEASE]
at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:741) ~[spring-beans-4.3.2.RELEASE.jar:4.3.2.RELEASE]
... 17 common frames omitted

Run All target with errors

I just cloned the repo and ran ./runAcceptanceTests.sh -x within the brewery directory and I got 👍

> Task :common:compileJava FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':common:compileJava'.
> Could not resolve all files for configuration ':common:compileClasspath'.
   > Could not find spring-boot-2.3.0.BUILD-SNAPSHOT.jar (org.springframework.boot:spring-boot:2.3.0.BUILD-SNAPSHOT:20200406.215655-501).
     Searched in the following locations:
         https://repo.spring.io/snapshot/org/springframework/boot/spring-boot/2.3.0.BUILD-SNAPSHOT/spring-boot-2.3.0.BUILD-20200406.215655-501.jar

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.3/userguide/command_line_interface.html#sec:command_line_warnings

BUILD FAILED in 46s

what would be wrong ?

Build failed, unresolve dependency 'com.fasterxml.jackson.dataformat:jackson-dataformat-smile:jar'

My system is an Ubuntu 14.04 LTS with java 1.8.0_66.

The result of ./gradlew clean build

:acceptance-tests:clean UP-TO-DATE
:brewing:clean UP-TO-DATE
:common:clean UP-TO-DATE
:config-server:clean UP-TO-DATE
:eureka:clean UP-TO-DATE
:presenting:clean UP-TO-DATE
:zipkin-server:clean UP-TO-DATE
:zookeeper:clean UP-TO-DATE
:zuul:clean UP-TO-DATE
:common:compileJava
Download http://repo.spring.io/snapshot/org/springframework/cloud/spring-cloud-sleuth-core/1.0.0.BUILD-SNAPSHOT/spring-cloud-sleuth-core-1.0.0.BUILD-20160112.084458-234.pom

FAILURE: Build failed with an exception.

* What went wrong:
Could not resolve all dependencies for configuration ':common:compile'.
> Could not find org.springframework.cloud:spring-cloud-sleuth-stream:.
  Required by:
      io.spring.cloud.samples.brewery:common:CD-000
> Could not resolve org.springframework.cloud:spring-cloud-sleuth-core:1.0.0.BUILD-SNAPSHOT.
  Required by:
      io.spring.cloud.samples.brewery:common:CD-000 > org.springframework.cloud:spring-cloud-starter-sleuth:1.0.0.BUILD-SNAPSHOT
   > Could not resolve org.springframework.cloud:spring-cloud-sleuth-core:1.0.0.BUILD-SNAPSHOT.
      > Could not parse POM http://repo.spring.io/snapshot/org/springframework/cloud/spring-cloud-sleuth-core/1.0.0.BUILD-SNAPSHOT/spring-cloud-sleuth-core-1.0.0.BUILD-20160112.084458-234.pom
         > Unable to resolve version for dependency 'org.assertj:assertj-core:jar'
> Could not resolve org.springframework.cloud:spring-cloud-netflix-core:1.1.0.BUILD-SNAPSHOT.
  Required by:
      io.spring.cloud.samples.brewery:common:CD-000 > org.springframework.cloud:spring-cloud-starter-hystrix:1.1.0.BUILD-SNAPSHOT
   > Could not resolve org.springframework.cloud:spring-cloud-netflix-core:1.1.0.BUILD-SNAPSHOT.
      > Could not parse POM http://repo.spring.io/snapshot/org/springframework/cloud/spring-cloud-netflix-core/1.1.0.BUILD-SNAPSHOT/spring-cloud-netflix-core-1.1.0.BUILD-20160112.000848-235.pom
         > Unable to resolve version for dependency 'com.fasterxml.jackson.dataformat:jackson-dataformat-smile:jar'

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

I have clean my gradle cache, no effect. Any ideas ?

Zipkin fan out reporter

During the tests write a span reporter that sends two places to the console and also to zipkin

Run all target fails with no manifest attribute in config-server/build/libs/nohup.log

bash runAcceptanceTests.sh -t SLEUTH
bash runAcceptanceTests.sh -x

all fail with the same error:

config-server/build/libs/nohup.log:
kein Hauptmanifestattribut, in config-server/build/libs/config-server-1.0.0-plain.jar

-> googling the error finds that the main class is missing from the manifest in config-server-1.0.0-plain.jar?

Log:

Booting up RabbitMQ
Starting brewery_rabbitmq_1 ... done
Waiting for RabbitMQ to boot for [350] seconds
Connection to 127.0.0.1 port 9672 [tcp/*] succeeded!
Waiting for Zookeeper to boot for [350] seconds
Recreating brewery_zookeeper_1 ... done
Connection to 127.0.0.1 port 2181 [tcp/eforward] succeeded!

Booting up Zipkin stuff
brewery_rabbitmq_1 is up-to-date
Starting brewery_query_1 ...
Starting brewery_query_1 ... done

Waiting for Zipkin to boot for [350] seconds
{
"status" : "UP",
"zipkin" : {
"status" : "UP",
"details" : {
"InMemoryStorage{}" : {
"status" : "UP"
}
}
}
}Waiting for the Config Server app to boot for [350] seconds

Trying to run [nohup java -Xmx128m -Xss1024k -jar config-server/build/libs/*.jar >config-server/build/libs/nohup.log &]
[config-server] process pid is [32159]
System props are []
Logs are under [build/config-server.log] or from nohup [config-server/build/libs/nohup.log]

curl: (7) Failed to connect to 127.0.0.1 port 8888 after 2 ms: Connection refused
Fail #1/70... will try again in [5] seconds
curl: (7) Failed to connect to 127.0.0.1 port 8888 after 3 ms: Connection refused
Fail #2/70... will try again in [5] seconds

Running the Acceptance tests requires some undocumented Docker setup

Having cloned the repo and built it with gradlew clean build I'm unable to run the acceptance tests. I have installed docker and docker-compose for the first time but that isn't enough to get the tests to run. Fails with

ERROR: Couldn't connect to Docker daemon - you might need to run docker-machine start default.

Scripts are misleading

there is runAcceptanceTests.sh in root
and there is script in acceptance tests - actually the main one.

It should be the other way round most likely. Anyways it has to be cleared

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.