File tree 14 files changed +156
-4
lines changed
14 files changed +156
-4
lines changed Original file line number Diff line number Diff line change
1
+ all : killer-whiles
2
+
3
+ killer-whiles :
4
+ (cd examples/killer-whiles && make)
5
+
6
+ .PHONY : killer-whiles
Original file line number Diff line number Diff line change
1
+ CFLAGS =-O0
2
+
3
+ all : mystery000 mystery001 faas
4
+
5
+ % .o : % .c
6
+ cc -o $@ $< $(CFLAGS )
7
+
8
+ faas :
9
+ # link our fake faas services
10
+ sudo ln -f -s /home/chaos/src/examples/killer-whiles/faas001_a.service /lib/systemd/system/faas001_a.service
11
+ sudo ln -f -s /home/chaos/src/examples/killer-whiles/faas001_b.service /lib/systemd/system/faas001_b.service
12
+ sudo systemctl daemon-reload
13
+ # link our fake load-balancer
14
+ sudo ln -f -s /home/chaos/src/examples/killer-whiles/nginx.loadbalancer.conf /etc/nginx/conf.d/nginx.loadbalancer.conf
15
+ sudo systemctl restart nginx
16
+
17
+ .PHONY : fass
Original file line number Diff line number Diff line change
1
+ echo " Listing backend services"
2
+ ps auxf | grep killer-whiles | grep python
3
+ echo
4
+
5
+ echo " Killing instance A (port 8001)"
6
+ ps auxf | grep 8001 | awk ' {system("sudo kill " $2)}'
7
+ sleep 0.5
8
+ systemctl status faas001_a
9
+ echo
10
+
11
+ echo " Wait some time in-between killings"
12
+ sleep 2
13
+ echo
14
+
15
+ echo " Killing instance A (port 8002)"
16
+ ps auxf | grep 8002 | awk ' {system("sudo kill " $2)}'
17
+ sleep 0.5
18
+ systemctl status faas001_b
19
+ echo
20
+
21
+ echo " Listing backend services"
22
+ ps auxf | grep killer-whiles | grep python
23
+ echo " Done here!"
Original file line number Diff line number Diff line change
1
+ [Unit]
2
+ Description =FizzBuzz as a Service API prototype - instance A
3
+
4
+ [Service]
5
+ ExecStart =python3 -m http.server 8001 --directory /home/chaos/src/examples/killer-whiles/static
6
+ Restart =always
Original file line number Diff line number Diff line change
1
+ [Unit]
2
+ Description =FizzBuzz as a Service API prototype - instance B
3
+
4
+ [Service]
5
+ ExecStart =python3 -m http.server 8002 --directory /home/chaos/src/examples/killer-whiles/static
6
+ Restart =always
Original file line number Diff line number Diff line change
1
+ # restart instance A a few times, spaced out by 1.5 second delays
2
+ i=" 0"
3
+ while [ $i -le 5 ]
4
+ do
5
+ echo " Killing faas001_a ${i} th time"
6
+ ps auxf | grep killer-whiles | grep python | grep 8001 | awk ' {system("sudo kill " $2)}'
7
+ sleep 0.5
8
+ i=$[$i +1]
9
+ done
10
+
11
+ systemctl status faas001_a --no-pager
12
+
13
+ sleep 2
14
+
15
+ # restart instance B a few times, spaced out by 1.5 second delays
16
+ i=" 0"
17
+ while [ $i -le 5 ]
18
+ do
19
+ echo " Killing faas001_b ${i} th time"
20
+ ps auxf | grep killer-whiles | grep python | grep 8002 | awk ' {system("sudo kill " $2)}'
21
+ sleep 0.5
22
+ i=$[$i +1]
23
+ done
24
+
25
+ systemctl status faas001_b --no-pager
Original file line number Diff line number Diff line change
1
+ int main ()
2
+ {
3
+ return 1 /0 ;
4
+ }
Original file line number Diff line number Diff line change
1
+ #include <stdio.h>
2
+ #include <stdlib.h>
3
+ #include <unistd.h>
4
+
5
+ int main ()
6
+ {
7
+ int wait = 1 ;
8
+ int block_size = 64 * 1024 * 1024 ;
9
+ int step = 1024 * 1024 ;
10
+ char * allocated_block ;
11
+
12
+ while (1 ) {
13
+
14
+ if ((allocated_block = (char * )malloc (block_size )) == NULL ) {
15
+ //printf("Couldn't malloc %d!\n", block_size);
16
+ if (block_size > 2 * step ){
17
+ block_size -= step ;
18
+ }
19
+ } else {
20
+ // slowly write data to our newly allocated memory to actually claim it and use some CPU
21
+ for (int i = 0 ; i < block_size ; i ++ ){
22
+ * (allocated_block + i ) = 'Y' ;
23
+ }
24
+ }
25
+ sleep (wait );
26
+ }
27
+
28
+ return 0 ;
29
+ }
Original file line number Diff line number Diff line change
1
+ # http {
2
+ # http block already in /etc/nginx/nginx.conf
3
+ upstream backend {
4
+ server 127.0.0.1:8001 max_fails=1 fail_timeout=1s;
5
+ server 127.0.0.1:8002 max_fails=1 fail_timeout=1s;
6
+ }
7
+ server {
8
+ listen 8003;
9
+
10
+ location / {
11
+ proxy_pass http://backend;
12
+ proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
13
+ }
14
+ }
15
+ # }
Original file line number Diff line number Diff line change
1
+ # print the command
2
+ set -o xtrace
3
+
4
+ # run the benchmark
5
+ ab -t 30 -c 10 -l http://127.0.0.1:8003/api/v1/
Original file line number Diff line number Diff line change
1
+ {
2
+ "FizzBuzz": true
3
+ }
Original file line number Diff line number Diff line change
1
+ ---
2
+ packages_to_install :
3
+ - git
4
+ - vim
5
+ - curl
6
+ - nginx
7
+ - apache2-utils
Original file line number Diff line number Diff line change 1
1
---
2
- - name : Install git
2
+ - name : Preinstall packages
3
3
become : true
4
4
apt :
5
- name : git
5
+ name : " {{ item }} "
6
6
state : present
7
7
update_cache : yes
8
+ loop : " {{ packages_to_install }}"
8
9
9
10
- name : Check out the book source code to home
10
11
git :
11
12
repo : ' https://github.com/seeker89/chaos-engineering-in-action.git'
12
13
dest : /home/chaos/src
14
+
15
+ - name : Make all the examples
16
+ shell : make
17
+ args :
18
+ chdir : /home/chaos/src
Original file line number Diff line number Diff line change @@ -239,13 +239,13 @@ d-i partman-auto/choose_recipe select atomic
239
239
240
240
# Partitioning
241
241
d-i partman-basicfilesystems/no_swap boolean false
242
-
243
- d-i partman-auto/expert_recipe string boot-root : \
242
+ d-i partman-auto/expert_recipe string boot-root :: \
244
243
5120 1 -1 ext4 \
245
244
$primary{ } $bootable{ } \
246
245
method{ format } format{ } \
247
246
use_filesystem{ } filesystem{ ext4 } \
248
247
label { root } mountpoint{ / } .
248
+ d-i partman-auto/choose_recipe select boot-root
249
249
250
250
# If you just want to change the default filesystem from ext3 to something
251
251
# else, you can do that without providing a full recipe.
You can’t perform that action at this time.
0 commit comments