Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit cb4ea78

Browse files
committed
Improve code, add functionality to decorators, fix bugs
1 parent 6488570 commit cb4ea78

File tree

10 files changed

+805
-98
lines changed

10 files changed

+805
-98
lines changed

‎LICENSE‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2018 Adrian Hornsby
3+
Copyright (c) 2019 Adrian Hornsby
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

‎README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
* Support for HTTP Error status code injection using ```error_code```
1010
* Support for disk space failure injection using ```file_size```
1111
* Using for SSM Parameter Store to control the experiment using ```isEnabled```
12-
* Per Lambda function injection control using Environment variable (```FAILURE_INJECTION_PARAM```) (thanks to Gunnar Grosch)
12+
* Per Lambda function injection control using Environment variable (```FAILURE_INJECTION_PARAM```)
1313
* Support for Serverless Framework using ```sls deploy``` (thanks to Gunnar Grosch)
1414
* Support for adding rate of failure using ```rate```. (Default rate = 1)
1515

‎example/lambda_function.py‎

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
import os
2+
from chaos_lib import (
3+
corrupt_delay, corrupt_exception, corrupt_statuscode, SessionWithDelay)
4+
5+
os.environ['CHAOS_PARAM'] = 'chaoslambda.config'
6+
7+
def session_request_with_delay():
8+
session = SessionWithDelay(delay=300)
9+
session.get('https://stackoverflow.com/')
10+
pass
11+
12+
13+
@corrupt_exception
14+
def handler_with_exception(event, context):
15+
return {
16+
'statusCode': 200,
17+
'body': 'Hello from Lambda!'
18+
}
19+
20+
21+
@corrupt_exception(exception_type=ValueError)
22+
def handler_with_exception_arg(event, context):
23+
return {
24+
'statusCode': 200,
25+
'body': 'Hello from Lambda!'
26+
}
27+
28+
29+
@corrupt_exception(exception_type=TypeError, exception_msg='foobar')
30+
def handler_with_exception_arg2(event, context):
31+
return {
32+
'statusCode': 200,
33+
'body': 'Hello from Lambda!'
34+
}
35+
36+
37+
@corrupt_statuscode
38+
def handler_with_statuscode(event, context):
39+
return {
40+
'statusCode': 200,
41+
'body': 'Hello from Lambda!'
42+
}
43+
44+
45+
@corrupt_statuscode(error_code=500)
46+
def handler_with_statuscode_arg(event, context):
47+
return {
48+
'statusCode': 200,
49+
'body': 'Hello from Lambda!'
50+
}
51+
52+
53+
@corrupt_delay
54+
def handler_with_delay(event, context):
55+
return {
56+
'statusCode': 200,
57+
'body': 'Hello from Lambda!'
58+
}
59+
60+
61+
@corrupt_delay(delay=1000)
62+
def handler_with_delay_arg(event, context):
63+
return {
64+
'statusCode': 200,
65+
'body': 'Hello from Lambda!'
66+
}
67+
68+
69+
@corrupt_delay(delay=0)
70+
def handler_with_delay_zero(event, context):
71+
return {
72+
'statusCode': 200,
73+
'body': 'Hello from Lambda!'
74+
}

‎lambda_function.py‎

Lines changed: 0 additions & 41 deletions
This file was deleted.

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /