Skip to content

Commit e80c93b

Browse files
adrianprecubpivovarit
authored andcommitted
BAEL-2039: chaos monkey for spring boot (eugenp#4889)
1 parent e7485a1 commit e80c93b

5 files changed

Lines changed: 95 additions & 0 deletions

File tree

‎spring-boot/pom.xml‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,12 @@
149149
<artifactId>rome</artifactId>
150150
<version>${rome.version}</version>
151151
</dependency>
152+
153+
<dependency>
154+
<groupId>de.codecentric</groupId>
155+
<artifactId>chaos-monkey-spring-boot</artifactId>
156+
<version>${chaos.monkey.version}</version>
157+
</dependency>
152158
</dependencies>
153159

154160
<build>
@@ -219,6 +225,7 @@
219225
<tomee-servlet-api.version>8.5.11</tomee-servlet-api.version>
220226
<togglz.version>2.4.1.Final</togglz.version>
221227
<rome.version>1.9.0</rome.version>
228+
<chaos.monkey.version>2.0.0</chaos.monkey.version>
222229
<graphql-spring-boot-starter.version>3.6.0</graphql-spring-boot-starter.version>
223230
<graphql-java-tools.version>3.2.0</graphql-java-tools.version>
224231
<guava.version>18.0</guava.version>
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package com.baeldung.chaosmonkey;
2+
3+
import org.springframework.boot.SpringApplication;
4+
import org.springframework.boot.autoconfigure.SpringBootApplication;
5+
6+
/**
7+
* Created by adi on 8/2/18.
8+
*/
9+
@SpringBootApplication(scanBasePackages = { "com.baeldung.chaosmonkey" })
10+
public class SpringBootChaosMonkeyApp {
11+
12+
public static void main(String[] args) {
13+
SpringApplication.run(SpringBootChaosMonkeyApp.class, args);
14+
}
15+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package com.baeldung.chaosmonkey.controller;
2+
3+
import com.baeldung.chaosmonkey.service.PermissionsService;
4+
import org.springframework.beans.factory.annotation.Autowired;
5+
import org.springframework.web.bind.annotation.GetMapping;
6+
import org.springframework.web.bind.annotation.RequestMapping;
7+
import org.springframework.web.bind.annotation.RestController;
8+
9+
import java.util.List;
10+
11+
/**
12+
* Created by adi on 8/2/18.
13+
*/
14+
@RestController
15+
@RequestMapping("/permissions")
16+
public class PermissionsController {
17+
18+
@Autowired private PermissionsService permissionsService;
19+
20+
@GetMapping
21+
public List<String> getAllPermissions() {
22+
return permissionsService.getAllPermissions();
23+
}
24+
25+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package com.baeldung.chaosmonkey.service;
2+
3+
import org.springframework.stereotype.Service;
4+
5+
import java.util.Arrays;
6+
import java.util.List;
7+
8+
/**
9+
* Created by adi on 8/2/18.
10+
*/
11+
@Service
12+
public class PermissionsService {
13+
14+
public List<String> getAllPermissions() {
15+
return Arrays.asList("CREATE", "READ", "UPDATE", "DELETE");
16+
}
17+
}

‎spring-boot/src/main/resources/application.properties‎

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,34 @@ servlet.mapping=/dispatcherExampleURL
4343
#spring.banner.image.invert= //TODO
4444

4545
contactInfoType=email
46+
47+
#chaos monkey for spring boot props
48+
management.endpoint.chaosmonkey.enabled=true
49+
management.endpoint.chaosmonkeyjmx.enabled=true
50+
51+
spring.profiles.active=chaos-monkey
52+
#Determine whether should execute or not
53+
chaos.monkey.enabled=true
54+
#How many requests are to be attacked. 1: attack each request; 5: each 5th request is attacked
55+
chaos.monkey.assaults.level=1
56+
#Minimum latency in ms added to the request
57+
chaos.monkey.assaults.latencyRangeStart=3000
58+
#Maximum latency in ms added to the request
59+
chaos.monkey.assaults.latencyRangeEnd=15000
60+
#Latency assault active
61+
chaos.monkey.assaults.latencyActive=true
62+
#Exception assault active
63+
chaos.monkey.assaults.exceptionsActive=false
64+
#AppKiller assault active
65+
chaos.monkey.assaults.killApplicationActive=false
66+
#Controller watcher active
67+
chaos.monkey.watcher.controller=false
68+
#RestController watcher active
69+
chaos.monkey.watcher.restController=false
70+
#Service watcher active
71+
chaos.monkey.watcher.service=true
72+
#Repository watcher active
73+
chaos.monkey.watcher.repository=false
74+
#Component watcher active
75+
chaos.monkey.watcher.component=false
76+

0 commit comments

Comments
 (0)