Giter Site home page Giter Site logo

asunder123 / spring-boot-restcontroller Goto Github PK

View Code? Open in Web Editor NEW

This project forked from mechero/spring-boot-restcontroller

2.0 0.0 1.0 48.5 MB

Sample code for a RestController in Spring using Swagger

Home Page: https://thepracticaldeveloper.com/2017/03/04/restcontroller-spring-boot-example-with-springfox-swagger/

Java 80.43% Shell 9.76% Dockerfile 9.81%

spring-boot-restcontroller's Introduction

Spring Boot @RestController Example with Chaos Monkey Enabled in Spring Application Properties

Description

This project contains the sample code used in The Practical Developer Blog. It's a Spring Boot application with one plain Java object (SpanishGreeting) and a Spring Controller SpanishGreetingController.

The main goal of the project is to show how to write a @RestController in Spring Boot and include documentation with Swagger.

How does it work?

You can use the endpoints behind http://localhost:8082/spanish-greetings. If you append /random to a GET request you'll receive a random Spanish greeting (which are actually hard-coded). You can also GET them by id (only from 1 to 3). To create a new one, you need to perform a POST operation.

Actually, much better if you just start the application and navigate to http://localhost:8082/swagger-ui.html. There you'll find a nice API documentation thanks to Swagger. Moreover, you can play with it.

Swagger Documentation

Upon Succesful Initialization of Chaos Monkey you should see something like this :

image

In addition to the end points and controller, chaos testing can be done as shown using postman for the endpoints exposed under actuator:

image image image image image image

Change the Assaults Configuration to invoke Methods within the Application:

image

Confirm Response: image

Initiate the Attack Vector: image

Sample Response 1: image

Sample Response 2: image

Confirmation of Runtime Exceptions Activated: image

Logs Confirming Chaos Monkey Bringing Down Application: image

Before changing the attack vector assaults configuration is default as shown : image

Logs: image

After changing attack vector: image

Initating Attack: image

Confirmation of Shutdown via Logs : image

#CPU Attack wit hMemory Assaults: image

image

Configuration changes to pom.xml and prometheus.yml :

pom.xml:

image

prometheus.yml:

image

Prometheus UI showing targets up :

image

CPU attack assault in Spring Boot Application:

image

Spike in Cpu Utilization seen in Prometheus:

image

Injected Latency attack :

image image

After disabling chaos

image

spring-boot-restcontroller's People

Contributors

asunder123 avatar mechero avatar

Stargazers

 avatar  avatar

Forkers

raviib002

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.